diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 88282447c51..47a984cd467 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -65,12 +65,12 @@ if (!$sortfield) $sortfield = "aa.account_number"; if (!$sortorder) $sortorder = "ASC"; $arrayfields = array( - 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), - 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), + 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), - 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), - 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), + 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) ); @@ -93,24 +93,24 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (!empty($cancel)) $action = ''; + if (!empty($cancel)) $action = ''; - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { - $search_account = ""; - $search_label = ""; + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $search_account = ""; + $search_label = ""; $search_labelshort = ""; $search_accountparent = ""; - $search_pcgtype = ""; + $search_pcgtype = ""; $search_array_options = array(); - } - if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on - || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified - { - if ($chartofaccounts > 0) - { + } + if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on + || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified + { + if ($chartofaccounts > 0) + { // Get language code for this $chartofaccounts $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; @@ -147,34 +147,34 @@ if (empty($reshook)) } } - if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } - } + if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } + } - if ($action == 'disable') { - if ($accounting->fetch($id)) { - $mode = GETPOST('mode', 'int'); - $result = $accounting->accountDeactivate($id, $mode); - } + if ($action == 'disable') { + if ($accounting->fetch($id)) { + $mode = GETPOST('mode', 'int'); + $result = $accounting->accountDeactivate($id, $mode); + } - $action = 'update'; - if ($result < 0) { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } - } elseif ($action == 'enable') { - if ($accounting->fetch($id)) { - $mode = GETPOST('mode', 'int'); - $result = $accounting->account_activate($id, $mode); - } - $action = 'update'; - if ($result < 0) { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } - } + $action = 'update'; + if ($result < 0) { + setEventMessages($accounting->error, $accounting->errors, 'errors'); + } + } elseif ($action == 'enable') { + if ($accounting->fetch($id)) { + $mode = GETPOST('mode', 'int'); + $result = $accounting->account_activate($id, $mode); + } + $action = 'update'; + if ($result < 0) { + setEventMessages($accounting->error, $accounting->errors, 'errors'); + } + } } @@ -273,9 +273,9 @@ if ($resql) if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if (!empty($conf->use_javascript_ajax)) - { - print ' + if (!empty($conf->use_javascript_ajax)) + { + print ' '; - } + } print '
'; if ($optioncss != '') print ''; @@ -296,48 +296,48 @@ if ($resql) print ''; print ''; - $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); - print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); // Box to select active chart of account - print $langs->trans("Selectchartofaccounts")." : "; - print ''; + $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1"; + $sql .= " WHERE a.active = 1"; + dol_syslog('accountancy/admin/account.php $sql='.$sql); + print $sql; + $resqlchart = $db->query($sql); + if ($resqlchart) { + $numbis = $db->num_rows($resqlchart); + $i = 0; + while ($i < $numbis) { + $obj = $db->fetch_object($resqlchart); - print ''; + print ''; - $i++; - } - } else dol_print_error($db); - print ""; - print ajax_combobox("chartofaccounts"); - print ''; + $i++; + } + } else dol_print_error($db); + print ""; + print ajax_combobox("chartofaccounts"); + print ''; - print '
'; + print '
'; print '
'; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $moreforfilter = ''; - $massactionbutton = ''; + $moreforfilter = ''; + $massactionbutton = ''; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; // Line for search fields print ''; @@ -358,7 +358,7 @@ if ($resql) print ''; print ''; - print ''; + print ''; if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); @@ -422,7 +422,7 @@ if ($resql) print ''; $accountparent->id = $obj->rowid2; $accountparent->label = $obj->label2; - $accountparent->account_number = $obj->account_number2; // Sotre an account number for output + $accountparent->account_number = $obj->account_number2; // Sotre an account number for output print $accountparent->getNomUrl(1); print "\n"; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index d3bd17d95a5..acec1468d79 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -472,13 +472,13 @@ if ($id) if ($valuetoshow != '') { print ''; } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index d015d8f07b5..b4f90f19675 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -108,16 +108,16 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) setEventMessages($object->error, $object->errors, 'errors'); } elseif ($res < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; } if (!$error) { - setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); - $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); - header("Location: ".$urltogo); - exit; + setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); + header("Location: ".$urltogo); + exit; } } } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) { @@ -158,15 +158,15 @@ 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) { diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 9469a1e64f1..c9adac2f5a3 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -135,249 +135,249 @@ $sourceList = array(); if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { - $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert = explode(',', $tabfieldinsert[$id]); - $listfieldmodify = explode(',', $tabfieldinsert[$id]); - $listfieldvalue = explode(',', $tabfieldvalue[$id]); + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); - // Check that all fields are filled - $ok = 1; - foreach ($listfield as $f => $value) - { + // Check that all fields are filled + $ok = 1; + foreach ($listfield as $f => $value) + { if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'range_account' && empty($_POST['range_account'])) continue; if ($value == 'country' || $value == 'country_id') continue; if (!GETPOSTISSET($value) || GETPOST($value) == '') - { - $ok = 0; - $fieldnamekey = $listfield[$f]; - // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; - if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; - if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; - if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; - if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; + { + $ok = 0; + $fieldnamekey = $listfield[$f]; + // We take translate key of field + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; + if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; + if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; + if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; + if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated'; - setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); - } - } - if (isset($_POST["code"])) - { - if ($_POST["code"] == '0') - { - $ok = 0; - setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); - } - } - if (!is_numeric(GETPOST('position', 'alpha'))) - { - $langs->loadLangs(array("errors")); + setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + } + } + if (isset($_POST["code"])) + { + if ($_POST["code"] == '0') + { + $ok = 0; + setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); + } + } + if (!is_numeric(GETPOST('position', 'alpha'))) + { + $langs->loadLangs(array("errors")); $ok = 0; setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors'); - } + } // Clean some parameters 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 - // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd', 'alpha')) - { - if ($tabrowid[$id]) - { - // Recupere id libre pour insertion - $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); - } else { - dol_print_error($db); - } - } + // Si verif ok et action add, on ajoute la ligne + if ($ok && GETPOST('actionadd', 'alpha')) + { + if ($tabrowid[$id]) + { + // Recupere id libre pour insertion + $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); + } else { + dol_print_error($db); + } + } - // 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("; + // 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("; - // List of values - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.","; - $i = 0; - foreach ($listfieldinsert as $f => $value) - { - if ($value == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } - if ($i) $sql .= ","; - if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = '' - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql .= ",1)"; + // List of values + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.","; + $i = 0; + foreach ($listfieldinsert as $f => $value) + { + if ($value == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql .= ","; + if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $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 - } else { - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); - } else { - dol_print_error($db); - } - } - } + 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 + } else { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); + } else { + dol_print_error($db); + } + } + } - // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify', 'alpha')) - { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + // Si verif ok et action modify, on modifie la ligne + if ($ok && GETPOST('actionmodify', 'alpha')) + { + 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)) - { - $sql .= $tabrowid[$id]."="; - $sql .= "'".$db->escape($rowid)."', "; - } - $i = 0; - foreach ($listfieldmodify as $field) - { - if ($field == 'fk_country' && $_POST['country'] > 0) { - $_POST[$listfieldvalue[$i]] = $_POST['country']; - } elseif ($field == 'entity') { - $_POST[$listfieldvalue[$i]] = $conf->entity; - } - if ($i) $sql .= ","; - $sql .= $field."="; - if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = '' - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; - $i++; - } - $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); + // Modify entry + $sql = "UPDATE ".$tabname[$id]." SET "; + // Modifie valeur des champs + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) + { + $sql .= $tabrowid[$id]."="; + $sql .= "'".$db->escape($rowid)."', "; + } + $i = 0; + foreach ($listfieldmodify as $field) + { + if ($field == 'fk_country' && $_POST['country'] > 0) { + $_POST[$listfieldvalue[$i]] = $_POST['country']; + } elseif ($field == 'entity') { + $_POST[$listfieldvalue[$i]] = $conf->entity; + } + if ($i) $sql .= ","; + $sql .= $field."="; + if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + $i++; + } + $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); - dol_syslog("actionmodify", LOG_DEBUG); - //print $sql; - $resql = $db->query($sql); - if (!$resql) - { - setEventMessages($db->error(), null, 'errors'); - } - } - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition + dol_syslog("actionmodify", LOG_DEBUG); + //print $sql; + $resql = $db->query($sql); + if (!$resql) + { + setEventMessages($db->error(), null, 'errors'); + } + } + //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } if (GETPOST('actioncancel', 'alpha')) { - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition + //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } 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." = ".((int) $rowid); + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid); - dol_syslog("delete", LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') - { - setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); - } else { - dol_print_error($db); - } - } + dol_syslog("delete", LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') + { + setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); + } else { + dol_print_error($db); + } + } } // 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." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // 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." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // 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." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } // 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." = ".((int) $rowid); - } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; - } + if ($rowid) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid); + } elseif ($code) { + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; + } - $result = $db->query($sql); - if (!$result) - { - dol_print_error($db); - } + $result = $db->query($sql); + if (!$result) + { + dol_print_error($db); + } } @@ -401,7 +401,7 @@ print ''.$langs->trans("AccountingAccountGroupsDesc" // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -410,407 +410,407 @@ if ($action == 'delete') */ if ($id) { - // Complete requete recherche valeurs avec critere de tri - $sql = $tabsql[$id]; + // Complete requete recherche valeurs avec critere de tri + $sql = $tabsql[$id]; - if ($search_country_id > 0) - { - if (preg_match('/ WHERE /', $sql)) $sql .= " AND "; - else $sql .= " WHERE "; - $sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; - } + if ($search_country_id > 0) + { + if (preg_match('/ WHERE /', $sql)) $sql .= " AND "; + else $sql .= " WHERE "; + $sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; + } - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield = 'country_code'; - $sql .= $db->order($sortfield, $sortorder); - $sql .= $db->plimit($listlimit + 1, $offset); - //print $sql; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield = 'country_code'; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($listlimit + 1, $offset); + //print $sql; - $fieldlist = explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'; - 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; - } + 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 '
'; + print '
'; - // Form to add a new line - if ($tabname[$id]) - { - $alabelisused = 0; + // Form to add a new line + if ($tabname[$id]) + { + $alabelisused = 0; - $fieldlist = explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); - // Line for title - print ''; - foreach ($fieldlist as $field => $value) - { - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees - $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - $class = "left"; - 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"); - } - 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] == '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] == 'range_account') { - $valuetoshow = $langs->trans("Comment"); - } - if ($fieldlist[$field] == 'category_type') { - $valuetoshow = $langs->trans("Calculated"); - } - - if ($valuetoshow != '') { - print ''; - } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Line to enter new values - print ''; - - $obj = new stdClass(); - // If data was already input, we define them in obj to populate input fields. - if (GETPOST('actionadd', 'alpha')) - { - foreach ($fieldlist as $key=>$val) - { - if (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; - - if (empty($reshook)) - { - fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'add'); - } - - print ''; - print ""; - - $colspan = count($fieldlist) + 3; - if ($id == 32) $colspan++; - - print ''; // Keep   to have a line with enough height - } - - // List of available record in database - dol_syslog("htdocs/admin/dict", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - $param = '&id='.$id; - if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; - $paramwithsearch = $param; - if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; - if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; - if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); - // There is several pages - if ($num > $listlimit) - { - print ''; - } - - // Title line with search boxes - print ''; - $filterfound = 0; - foreach ($fieldlist as $field => $value) - { - $showfield = 1; // By defaut - - if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } - - if ($showfield) - { - if ($value == 'country') - { - print ''; - $filterfound++; - } else { - print ''; - } - } - } - print ''; - print ''; - print ''; - print ''; - print ''; - - // Title of lines - print ''; - foreach ($fieldlist as $field => $value) - { - // Determine le nom du champ par rapport aux noms possibles - // dans les dictionnaires de donnees - $showfield = 1; // By defaut - $class = "left"; - $sortable = 1; - $valuetoshow = ''; - - $valuetoshow = ucfirst($fieldlist[$field]); // By defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - 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] == 'type') { - $valuetoshow = $langs->trans("Type"); - } - if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow = $langs->trans("Label"); - } - if ($fieldlist[$field] == 'country') { - $valuetoshow = $langs->trans("Country"); - } - if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { - $showfield = 0; - } - 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] == 'type_template') { - $valuetoshow = $langs->trans("TypeOfTemplate"); - } + // Line for title + print ''; + foreach ($fieldlist as $field => $value) + { + // Determine le nom du champ par rapport aux noms possibles + // dans les dictionnaires de donnees + $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + $class = "left"; + 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"); + } + 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] == '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] == 'range_account') { - $valuetoshow = $langs->trans("Comment"); - } + $valuetoshow = $langs->trans("Comment"); + } if ($fieldlist[$field] == 'category_type') { - $valuetoshow = $langs->trans("Calculated"); - } - // Affiche nom du champ - if ($showfield) { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' '); - } - } + $valuetoshow = $langs->trans("Calculated"); + } + + if ($valuetoshow != '') { + print ''; + } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + // Line to enter new values + print ''; + + $obj = new stdClass(); + // If data was already input, we define them in obj to populate input fields. + if (GETPOST('actionadd', 'alpha')) + { + foreach ($fieldlist as $key=>$val) + { + if (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; + + if (empty($reshook)) + { + fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'add'); + } + + print ''; + print ""; + + $colspan = count($fieldlist) + 3; + if ($id == 32) $colspan++; + + print ''; // Keep   to have a line with enough height + } + + // List of available record in database + dol_syslog("htdocs/admin/dict", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + $param = '&id='.$id; + if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; + $paramwithsearch = $param; + if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; + if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; + if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); + // There is several pages + if ($num > $listlimit) + { + print ''; + } + + // Title line with search boxes + print ''; + $filterfound = 0; + foreach ($fieldlist as $field => $value) + { + $showfield = 1; // By defaut + + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } + + if ($showfield) + { + if ($value == 'country') + { + print ''; + $filterfound++; + } else { + print ''; + } + } + } + print ''; + print ''; + print ''; + print ''; + print ''; + + // Title of lines + print ''; + foreach ($fieldlist as $field => $value) + { + // Determine le nom du champ par rapport aux noms possibles + // dans les dictionnaires de donnees + $showfield = 1; // By defaut + $class = "left"; + $sortable = 1; + $valuetoshow = ''; + + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + 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] == 'type') { + $valuetoshow = $langs->trans("Type"); + } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { + $valuetoshow = $langs->trans("Label"); + } + if ($fieldlist[$field] == 'country') { + $valuetoshow = $langs->trans("Country"); + } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; + } + 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] == 'type_template') { + $valuetoshow = $langs->trans("TypeOfTemplate"); + } + if ($fieldlist[$field] == 'range_account') { + $valuetoshow = $langs->trans("Comment"); + } + if ($fieldlist[$field] == 'category_type') { + $valuetoshow = $langs->trans("Calculated"); + } + // Affiche nom du champ + if ($showfield) { + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "", $sortfield, $sortorder, $class.' '); + } + } print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center '); - print getTitleFieldOfList(''); - print getTitleFieldOfList(''); - print getTitleFieldOfList(''); - print ''; + print getTitleFieldOfList(''); + print getTitleFieldOfList(''); + print getTitleFieldOfList(''); + print ''; - if ($num) - { - // Lines with values - while ($i < $num) - { - $obj = $db->fetch_object($resql); - //print_r($obj); - print ''; - 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; + if ($num) + { + // Lines with values + while ($i < $num) + { + $obj = $db->fetch_object($resql); + //print_r($obj); + print ''; + 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; - // Show fields - if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit'); + // Show fields + if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit'); - print ''; - print ''; - print ''; - print ''; - } else { - $tmpaction = 'view'; - $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + print ''; + print ''; + print ''; + print ''; + } else { + $tmpaction = 'view'; + $parameters = array('var'=>$var, '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)) - { - foreach ($fieldlist as $field => $value) - { - $showfield = 1; - $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; - if ($value == 'category_type') - { - $valuetoshow = yn($valuetoshow); - } elseif ($valuetoshow == 'all') { - $valuetoshow = $langs->trans('All'); - } elseif ($fieldlist[$field] == 'country') { - if (empty($obj->country_code)) - { - $valuetoshow = '-'; - } else { - $key = $langs->trans("Country".strtoupper($obj->country_code)); - $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); - } - } 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') { - $langs->loadLangs(array("propal")); - $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] == 'region_id' || $fieldlist[$field] == 'country_id') { - $showfield = 0; - } + if (empty($reshook)) + { + foreach ($fieldlist as $field => $value) + { + $showfield = 1; + $class = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; + if ($value == 'category_type') + { + $valuetoshow = yn($valuetoshow); + } elseif ($valuetoshow == 'all') { + $valuetoshow = $langs->trans('All'); + } elseif ($fieldlist[$field] == 'country') { + if (empty($obj->country_code)) + { + $valuetoshow = '-'; + } else { + $key = $langs->trans("Country".strtoupper($obj->country_code)); + $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); + } + } 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') { + $langs->loadLangs(array("propal")); + $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] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; + } - $class = 'tddict'; + $class = 'tddict'; // Show value for field if ($showfield) print ''; - } - } + } + } - // Can an entry be erased or disabled ? - $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default - if (isset($obj->code)) - { - if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } - } + // Can an entry be erased or disabled ? + $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default + if (isset($obj->code)) + { + if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } + } - $canbemodified = $iserasable; + $canbemodified = $iserasable; - $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); - if ($param) $url .= '&'.$param; - $url .= '&'; + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + if ($param) $url .= '&'.$param; + $url .= '&'; - // Active - print '"; + // Active + print '"; - // Modify link - if ($canbemodified) print ''; - else print ''; + // Modify link + if ($canbemodified) print ''; + else print ''; - // Delete link - if ($iserasable) - { - print ''; - } else print ''; + // Delete link + if ($iserasable) + { + print ''; + } else print ''; - // Link to setup the group - print ''; - } - print "\n"; - $i++; - } - } - } else { - dol_print_error($db); - } + // Link to setup the group + print ''; + } + print "\n"; + $i++; + } + } + } else { + dol_print_error($db); + } - 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 ''; - print ''; - print '
'; - print ''; - print '
 
'; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); - print '
'; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); - print ''; - if ($filterfound) - { - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - } - 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 ''; + print ''; + print '
'; + print ''; + print '
 
'; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print '
'; + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); + print ''; + if ($filterfound) + { + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + } + print '
'; - print ''; - print ''; - print ''; - print '
'; - print ''; - print '
'; + print ''; + print ''; + print ''; + print '
'; + print ''; + print '
'.$valuetoshow.''; - if ($canbedisabled) print ''.$actl[$obj->active].''; - else { - print $langs->trans("AlwaysActive"); - } - print "'; + if ($canbedisabled) print ''.$actl[$obj->active].''; + else { + print $langs->trans("AlwaysActive"); + } + print "'.img_edit().' '.img_edit().' '; - if ($user->admin) print ''.img_delete().''; - //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin - print ' '; + if ($user->admin) print ''.img_delete().''; + //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin + print ' '; - if (empty($obj->formula)) - { - print ''; - print $langs->trans("ListOfAccounts"); - print ''; - } - print '
'; + if (empty($obj->formula)) + { + print ''; + print $langs->trans("ListOfAccounts"); + print ''; + } + print '
'; + print ''; print '
'; - print '
'; + print ''; } print '
'; @@ -865,7 +865,7 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co print ''; } } elseif ($fieldlist[$field] == 'category_type') { - print ''; + print ''; print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { diff --git a/htdocs/accountancy/admin/closure.php b/htdocs/accountancy/admin/closure.php index a425fd45768..7e781b3fc71 100644 --- a/htdocs/accountancy/admin/closure.php +++ b/htdocs/accountancy/admin/closure.php @@ -39,8 +39,8 @@ $action = GETPOST('action', 'aZ09'); $list_account_main = array( - 'ACCOUNTING_RESULT_PROFIT', - 'ACCOUNTING_RESULT_LOSS' + 'ACCOUNTING_RESULT_PROFIT', + 'ACCOUNTING_RESULT_LOSS' ); /* @@ -48,17 +48,17 @@ $list_account_main = array( */ if ($action == 'update') { - $error = 0; + $error = 0; - $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); + $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); - if (!empty($defaultjournal)) { - if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } + if (!empty($defaultjournal)) { + if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } foreach ($list_account_main as $constname) { $constvalue = GETPOST($constname, 'alpha'); @@ -99,20 +99,20 @@ print ''; print ''; foreach ($list_account_main as $key) { - print ''; - // Param - $label = $langs->trans($key); - $keydesc = $key.'_Desc'; + print ''; + // Param + $label = $langs->trans($key); + $keydesc = $key.'_Desc'; - $htmltext = $langs->trans($keydesc); - print ''; - // Value - print ''; - print ''; + $htmltext = $langs->trans($keydesc); + print ''; + // Value + print ''; + print ''; } // Journal diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index b2262c603f9..ba45220c8cc 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09'); // Parameters ACCOUNTING_EXPORT_* $main_option = array( - 'ACCOUNTING_EXPORT_PREFIX_SPEC', + 'ACCOUNTING_EXPORT_PREFIX_SPEC', ); $configuration = AccountancyExport::getTypeConfig(); @@ -58,22 +58,22 @@ $listcr = $configuration['cr']; $model_option = array( - '1' => array( - 'label' => 'ACCOUNTING_EXPORT_FORMAT', - 'param' => $listformat, - ), - '2' => array( - 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV', - 'param' => '', - ), - '3' => array( - 'label' => 'ACCOUNTING_EXPORT_ENDLINE', - 'param' => $listcr, - ), - '4' => array( - 'label' => 'ACCOUNTING_EXPORT_DATE', - 'param' => '', - ), + '1' => array( + 'label' => 'ACCOUNTING_EXPORT_FORMAT', + 'param' => $listformat, + ), + '2' => array( + 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV', + 'param' => '', + ), + '3' => array( + 'label' => 'ACCOUNTING_EXPORT_ENDLINE', + 'param' => $listcr, + ), + '4' => array( + 'label' => 'ACCOUNTING_EXPORT_DATE', + 'param' => '', + ), ); @@ -105,22 +105,22 @@ if ($action == 'update') { } } - foreach ($listparam[$modelcsv] as $key => $value) { - $constante = $key; + foreach ($listparam[$modelcsv] as $key => $value) { + $constante = $key; - if (strpos($constante, 'ACCOUNTING') !== false) { - $constvalue = GETPOST($key, 'alpha'); - if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } - } + if (strpos($constante, 'ACCOUNTING') !== false) { + $constvalue = GETPOST($key, 'alpha'); + if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + } if (!$error) { - // reload - $configuration = AccountancyExport::getTypeConfig(); - $listparam = $configuration['param']; - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + // reload + $configuration = AccountancyExport::getTypeConfig(); + $listparam = $configuration['param']; + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } @@ -148,36 +148,36 @@ print 'jQuery(document).ready(function () {'."\n"; print ' function initfields()'."\n"; print ' {'."\n"; foreach ($listparam as $key => $param) { - print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n"; - print ' {'."\n"; - print ' //console.log("'.$param['label'].'");'."\n"; - if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) { - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) { - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) { - print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n"; - } - if (empty($param['ACCOUNTING_EXPORT_DATE'])) { - print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n"; - } else { - print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n"; - print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n"; - } - print ' }'."\n"; + print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n"; + print ' {'."\n"; + print ' //console.log("'.$param['label'].'");'."\n"; + if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) { + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) { + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) { + print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n"; + } + if (empty($param['ACCOUNTING_EXPORT_DATE'])) { + print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n"; + } else { + print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n"; + print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n"; + } + print ' }'."\n"; } print ' }'."\n"; print ' initfields();'."\n"; @@ -262,17 +262,17 @@ if ($num2) { foreach ($model_option as $key) { print ''; - // Param - $label = $key['label']; + // Param + $label = $key['label']; print ''; // Value - print ''; } diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 1ddcddf13e6..4aa1fd99ff4 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -113,7 +113,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'); diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 819160e7d23..68a9660a0e9 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -420,15 +420,15 @@ if ($id) $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate $class = "left"; - if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Label"); } - if ($fieldlist[$field] == 'nature') { - $valuetoshow = $langs->trans("NatureOfJournal"); - } + if ($fieldlist[$field] == 'nature') { + $valuetoshow = $langs->trans("NatureOfJournal"); + } if ($valuetoshow != '') { print ''; + print ''; + print '
'; - print $form->textwithpicto($label, $htmltext); - print ''; // Do not force class=right, or it align also the content of the select box - print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); - print '
'; + print $form->textwithpicto($label, $htmltext); + print ''; // Do not force class=right, or it align also the content of the select box + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print '
'.$langs->trans($label).''; - if (is_array($key['param'])) { - print $form->selectarray($label, $key['param'], $conf->global->$label, 0); - } else { - print ''; - } + print ''; + if (is_array($key['param'])) { + print $form->selectarray($label, $key['param'], $conf->global->$label, 0); + } else { + print ''; + } print '
'; @@ -540,14 +540,14 @@ if ($id) $valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate if ($fieldlist[$field] == 'code') { - $valuetoshow = $langs->trans("Code"); - } + $valuetoshow = $langs->trans("Code"); + } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { - $valuetoshow = $langs->trans("Label"); - } + $valuetoshow = $langs->trans("Label"); + } if ($fieldlist[$field] == 'nature') { - $valuetoshow = $langs->trans("NatureOfJournal"); - } + $valuetoshow = $langs->trans("NatureOfJournal"); + } // Affiche nom du champ if ($showfield) { @@ -594,7 +594,7 @@ if ($id) if (empty($reshook)) { - $langs->load("accountancy"); + $langs->load("accountancy"); foreach ($fieldlist as $field => $value) { $showfield = 1; @@ -607,7 +607,7 @@ if ($id) $valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]}); } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { $valuetoshow = $langs->trans($obj->label); - } + } $class = 'tddict'; // Show value for field @@ -619,15 +619,15 @@ if ($id) $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default 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; - } + $iserasable = 0; + $canbedisabled = 0; + } elseif ($obj->code == 'RECEP') { + $iserasable = 0; + $canbedisabled = 0; + } elseif ($obj->code == 'EF0') { + $iserasable = 0; + $canbedisabled = 0; + } } $canbemodified = $iserasable; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index d88800016a8..3c0523ac877 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -42,7 +42,7 @@ if (empty($conf->accounting->enabled)) { accessforbidden(); } if (!$user->rights->accounting->bind->write) - accessforbidden(); + accessforbidden(); // search & action GETPOST $action = GETPOST('action', 'aZ09'); @@ -100,14 +100,14 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers { - $search_ref = ''; - $search_label = ''; - $search_desc = ''; + $search_ref = ''; + $search_label = ''; + $search_desc = ''; $search_vat = ''; - $search_onsell = ''; - $search_onpurchase = ''; - $search_current_account = ''; - $search_current_account_valid = '-1'; + $search_onsell = ''; + $search_onpurchase = ''; + $search_current_account = ''; + $search_current_account_valid = '-1'; } // Sales or Purchase mode ? @@ -117,8 +117,8 @@ if ($action == 'update') { $accounting_product_modes = array( 'ACCOUNTANCY_SELL', - 'ACCOUNTANCY_SELL_INTRA', - 'ACCOUNTANCY_SELL_EXPORT', + 'ACCOUNTANCY_SELL_INTRA', + 'ACCOUNTANCY_SELL_EXPORT', 'ACCOUNTANCY_BUY', 'ACCOUNTANCY_BUY_INTRA', 'ACCOUNTANCY_BUY_EXPORT' @@ -172,22 +172,22 @@ if ($action == 'update') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $sql .= " SET accountancy_code_sell = ".$accounting->account_number; } - if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $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; - } + if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + $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 .= " WHERE rowid = ".((int) $productid); dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { - $ok++; - $db->commit(); + $ok++; + $db->commit(); } else { - $ko++; - $db->rollback(); + $ko++; + $db->rollback(); } } @@ -253,7 +253,7 @@ $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; + $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; @@ -271,9 +271,9 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_buy", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_buy", $search_current_account); + } } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account); @@ -283,17 +283,17 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $sql .= natural_search("p.accountancy_code_buy_export", $search_current_account); } } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell", $search_current_account); + } } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); + } } else { - if (strlen(trim($search_current_account))) { - $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); - } + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); + } } if ($search_current_account_valid == 'withoutvalidaccount') { @@ -301,7 +301,7 @@ if ($search_current_account_valid == 'withoutvalidaccount') } if ($search_current_account_valid == 'withvalidaccount') { - $sql .= " AND aa.account_number IS NOT NULL"; + $sql .= " AND aa.account_number IS NOT NULL"; } // Add search filter like if (strlen(trim($search_ref))) { @@ -324,13 +324,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -342,32 +342,32 @@ 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); + $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_vat > 0) $param .= '&search_vat='.urlencode($search_vat); - 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); + 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 '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); + print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); print '
'; print ''.$langs->trans("InitAccountancyDesc").'
'; print '
'; - // Select mode + // Select mode print ''; print ''; print ''; @@ -377,13 +377,13 @@ if ($result) print "\n"; if ($mysoc->isInEEC()) { - print ''; - print '\n"; + print ''; + print '\n"; } - print ''; - print '\n"; + print ''; + print '\n"; print ''; print '\n"; if ($mysoc->isInEEC()) @@ -405,8 +405,8 @@ if ($result) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $buttonsave = ''; - //print '
'.$buttonsave.'
'; + $buttonsave = ''; + //print '
'.$buttonsave.'
'; $texte = $langs->trans("ListOfProductsServices"); print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1); @@ -444,22 +444,22 @@ if ($result) print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); + if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); // On sell / On purchase - if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell_intra"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_sell_export"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); - $fieldtosortaccount = "p.accountancy_code_buy"; - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell_intra"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { + print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_sell_export"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount = "p.accountancy_code_buy"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); $fieldtosortaccount = "p.accountancy_code_buy_intra"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { @@ -475,8 +475,8 @@ if ($result) $product_static = new Product($db); $i = 0; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) + { $obj = $db->fetch_object($result); // Ref produit as link @@ -494,12 +494,12 @@ if ($result) $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell_intra; + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell_intra; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { - $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell_export; - } else { + $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell_export; + } else { $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell_id = $aarowid_prodsell; } @@ -560,11 +560,11 @@ if ($result) if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) { - // TODO ADJUST DESCRIPTION SIZE - // print ''; - // TODO: we should set a user defined value to adjust user square / wide screen size - $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; - print ''; + // TODO ADJUST DESCRIPTION SIZE + // print ''; + // TODO: we should set a user defined value to adjust user square / wide screen size + $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; + print ''; } // VAT @@ -581,30 +581,30 @@ if ($result) // Current accounting account print ''; // New account to set $defaultvalue = ''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - // Accounting account buy + // Accounting account buy print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - // Accounting account sell intra (In EEC) - print ''; - } else { - // Accounting account sell export (Out of EEC) - print ''; - } + // Accounting account sell intra (In EEC) + print ''; + } else { + // Accounting account sell export (Out of EEC) + print ''; + } // Checkbox select print ''; + print ''; } // Action column print '\n"; + print "\n"; if (!$i) $totalarray['nbfield']++; } @@ -1065,9 +1065,9 @@ print ''; // TODO Replace this with mass delete action if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
'."\n"; - print ''.$langs->trans("DeleteMvt").''; - print '
'; + print '
'."\n"; + print ''.$langs->trans("DeleteMvt").''; + print '
'; } print ''; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 7c6d6719235..45e8c6aee70 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -138,7 +138,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { @@ -172,55 +172,55 @@ if (empty($reshook)) if (!empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); + $param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int'); } if (!empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); + $param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int'); } if (!empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; - $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); } if (!empty($search_accountancy_code_start)) { $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); } if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); } if (!empty($search_label_account)) { $filter['t.label_compte'] = $search_label_account; - $param .= '&search_label_compte=' . urlencode($search_label_account); + $param .= '&search_label_compte='.urlencode($search_label_account); } if (!empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num=' . urlencode($search_mvt_num); + $param .= '&search_mvt_num='.urlencode($search_mvt_num); } if (!empty($search_doc_ref)) { $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref=' . urlencode($search_doc_ref); + $param .= '&search_doc_ref='.urlencode($search_doc_ref); } if (!empty($search_label_operation)) { $filter['t.label_operation'] = $search_label_operation; - $param .= '&search_label_operation=' . urlencode($search_label_operation); + $param .= '&search_label_operation='.urlencode($search_label_operation); } if (!empty($search_direction)) { $filter['t.sens'] = $search_direction; - $param .= '&search_direction=' . urlencode($search_direction); + $param .= '&search_direction='.urlencode($search_direction); } if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code=' . urlencode($search_ledger_code); + $param .= '&search_ledger_code='.urlencode($search_ledger_code); } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; - $param .= '&search_debit=' . urlencode($search_debit); + $param .= '&search_debit='.urlencode($search_debit); } if (!empty($search_credit)) { $filter['t.credit'] = $search_credit; - $param .= '&search_credit=' . urlencode($search_credit); + $param .= '&search_credit='.urlencode($search_credit); } if (!empty($search_lettering_code)) { $filter['t.lettering_code'] = $search_lettering_code; @@ -426,7 +426,7 @@ print ''; // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { @@ -446,19 +446,19 @@ if (!empty($arrayfields['t.piece_num']['checked'])) } // Ref document if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''; + print ''; } // Label operation if (!empty($arrayfields['t.label_operation']['checked'])) { - print ''; + print ''; } // Debit if (!empty($arrayfields['t.debit']['checked'])) { - print ''; + print ''; } // Credit if (!empty($arrayfields['t.credit']['checked'])) { - print ''; + print ''; } // Lettering code if (!empty($arrayfields['t.lettering_code']['checked'])) @@ -534,7 +534,7 @@ while ($i < min($num, $limit)) $balance = $sous_total_debit - $sous_total_credit; print ''; print ''; - if ($balance > 0 ) + if ($balance > 0) { print '' : ''; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; if (!$i) $totalarray['nbfield']++; } @@ -680,7 +680,7 @@ while ($i < min($num, $limit)) // Amount credit if (!empty($arrayfields['t.credit']['checked'])) { - print ''; + print ''; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; $totalarray['val']['totalcredit'] += $line->credit; @@ -733,7 +733,7 @@ print ''; $balance = $sous_total_debit - $sous_total_credit; print ''; print ''; -if ($balance > 0 ) +if ($balance > 0) { print ''; + print ''; + print ''; } print ''; } diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 1a37bb1019b..90f3d4c04ef 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -50,7 +50,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { if (!$cancel) { - if ($codeventil < 0) $codeventil = 0; + if ($codeventil < 0) $codeventil = 0; $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql .= " SET fk_code_ventilation = ".$codeventil; @@ -60,12 +60,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else { - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); - if ($backtopage) - { - header("Location: ".$backtopage); - exit(); - } + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + if ($backtopage) + { + header("Location: ".$backtopage); + exit(); + } } } else { header("Location: ./lines.php"); diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 80ed833b828..20010cc8f5c 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -45,14 +45,14 @@ $hookmanager->initHooks(array('accountancyindex')); if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) { - require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - $zone = GETPOST('areacode', 'aZ09'); - $userid = GETPOST('userid', 'int'); - $boxorder = GETPOST('boxorder', 'aZ09'); - $boxorder .= GETPOST('boxcombo', 'aZ09'); + require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); - $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); - if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); } @@ -64,11 +64,11 @@ llxHeader('', $langs->trans("AccountancyArea")); if ($conf->accounting->enabled) { - $step = 0; + $step = 0; - $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) + $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default. + $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default. $showtutorial = ''; if (!$helpisexpanded) @@ -92,9 +92,9 @@ if ($conf->accounting->enabled) print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial); - print '
'; // hideobject is to start hidden - print "
\n"; - print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; + print '
'; // hideobject is to start hidden + print "
\n"; + print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; print "
\n"; print "
\n"; print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; @@ -132,9 +132,9 @@ if ($conf->accounting->enabled) if (!empty($conf->tax->enabled)) { $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); - print "
\n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); + print "
\n"; } /*if (! empty($conf->salaries->enabled)) { @@ -146,9 +146,9 @@ if ($conf->accounting->enabled) }*/ if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''); - print "
\n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''); + print "
\n"; } /* if (! empty($conf->loan->enabled)) @@ -177,7 +177,7 @@ if ($conf->accounting->enabled) print '
'; - // Step A - E + // Step A - E print "
\n"; print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionFreq"), '', ''); @@ -199,7 +199,7 @@ if ($conf->accounting->enabled) { $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'')."\n"; - print "
\n"; + print "
\n"; } $step++; @@ -214,36 +214,36 @@ if ($conf->accounting->enabled) print '
'; - print '
'; + print '
'; - print '
'; + print '
'; - /* + /* * Show boxes */ - $boxlist .= '
'; + $boxlist .= '
'; - $boxlist .= '
'; + $boxlist .= '
'; - $boxlist .= $resultboxes['boxlista']; + $boxlist .= $resultboxes['boxlista']; - $boxlist .= '
'; + $boxlist .= '
'; - $boxlist .= '
'; + $boxlist .= '
'; - $boxlist .= $resultboxes['boxlistb']; + $boxlist .= $resultboxes['boxlistb']; - $boxlist .= '
'; - $boxlist .= "\n"; + $boxlist .= '
'; + $boxlist .= "\n"; - $boxlist .= '
'; + $boxlist .= '
'; - print $boxlist; + print $boxlist; - print '
'; + print '
'; } else { - print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy'); + print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy'); print ''.$langs->trans("Module10Desc")."
\n"; } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 29777316a64..baafcfe5e87 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -394,9 +394,9 @@ if ($result) { $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; $paymentvariousstatic->fetch($paymentvariousstatic->id); $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word - $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word - $tabpay[$obj->rowid]["account_various"] = $account_various; - $tabtp[$obj->rowid][$account_subledger] += $obj->amount; + $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word + $tabpay[$obj->rowid]["account_various"] = $account_various; + $tabtp[$obj->rowid][$account_subledger] += $obj->amount; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id']; @@ -668,7 +668,7 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->label_compte = $accountingaccount->label; } elseif ($tabtype[$key] == 'payment_various') { $bookkeeping->subledger_account = $k; - $bookkeeping->subledger_label = $tabcompany[$key]['name']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; $accountingaccount->fetch(null, $bookkeeping->numero_compte, true); @@ -954,8 +954,8 @@ if (empty($action) || $action == 'view') { $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal='.$id_journal; @@ -991,11 +991,11 @@ if (empty($action) || $action == 'view') { if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print ''; if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' - || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { - print ''; + || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + print ''; } else { - if ($in_bookkeeping == 'notyet') print ''; - else print ''.$langs->trans("WriteBookKeeping").''; + if ($in_bookkeeping == 'notyet') print ''; + else print ''.$langs->trans("WriteBookKeeping").''; } print '
'; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index bf8275cee1c..26e2b4cdf77 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -110,11 +110,11 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { // Already in bookkeeping or not if ($in_bookkeeping == 'already') { - $sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; + $sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; } if ($in_bookkeeping == 'notyet') { - $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; + $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; } $sql .= " ORDER BY er.date_debut"; @@ -370,8 +370,8 @@ if ($action == 'writebookkeeping') { if ($error >= 10) { - setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); - break; // Break in the foreach + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach } } } @@ -433,48 +433,48 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! print "\n"; foreach ($taber as $key => $val) { - $date = dol_print_date($val["date"], 'day'); + $date = dol_print_date($val["date"], 'day'); - $userstatic->id = $tabuser[$key]['id']; - $userstatic->name = $tabuser[$key]['name']; + $userstatic->id = $tabuser[$key]['id']; + $userstatic->name = $tabuser[$key]['name']; - // Fees - foreach ($tabht[$key] as $k => $mt) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k, true); - if ($mt) { - print '"'.$date.'"'.$sep; - print '"'.$val["ref"].'"'.$sep; - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep; - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; - print '"'.($mt < 0 ? price(-$mt) : '').'"'; - print "\n"; - } - } - // VAT - foreach ($tabtva[$key] as $k => $mt) { - if ($mt) { - print '"'.$date.'"'.$sep; - print '"'.$val["ref"].'"'.$sep; - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep; - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; - print '"'.($mt < 0 ? price(-$mt) : '').'"'; - print "\n"; - } - } + // Fees + foreach ($tabht[$key] as $k => $mt) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k, true); + if ($mt) { + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'; + print "\n"; + } + } + // VAT + foreach ($tabtva[$key] as $k => $mt) { + if ($mt) { + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'; + print "\n"; + } + } - // Third party - foreach ($tabttc[$key] as $k => $mt) { - print '"'.$date.'"'.$sep; - print '"'.$val["ref"].'"'.$sep; - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; - print '"'.dol_trunc($userstatic->name).'"'.$sep; - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; - print '"'.($mt >= 0 ? price($mt) : '').'"'; - } - print "\n"; + // Third party + foreach ($tabttc[$key] as $k => $mt) { + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.dol_trunc($userstatic->name).'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'; + } + print "\n"; } } @@ -489,8 +489,8 @@ if (empty($action) || $action == 'view') { $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal='.$id_journal; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 8e409b497b5..a656643be57 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -719,8 +719,8 @@ if (empty($action) || $action == 'view') { } $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal='.$id_journal; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 589bad72749..debe1fa8cb0 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -130,7 +130,7 @@ if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'notyet') { $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; - // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account + // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account } $sql .= " ORDER BY f.datef"; //print $sql; @@ -658,8 +658,8 @@ if (empty($action) || $action == 'view') { } $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $varlink = 'id_journal='.$id_journal; diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index d6b289a76c8..cf13302d866 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -54,7 +54,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) { if (!$cancel) { - if ($codeventil < 0) $codeventil = 0; + if ($codeventil < 0) $codeventil = 0; $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sql .= " SET fk_code_ventilation = ".$codeventil; @@ -64,12 +64,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) if (!$resql) { setEventMessages($db->lasterror(), null, 'errors'); } else { - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); - if ($backtopage) - { - header("Location: ".$backtopage); - exit(); - } + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + if ($backtopage) + { + header("Location: ".$backtopage); + exit(); + } } } else { header("Location: ./lines.php"); diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 17d5f51d6eb..51577218eb9 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -50,27 +50,27 @@ $action = GETPOST('action', 'aZ09'); // if ($action == 'updateall') { - $db->begin(); - $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; - $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); - $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); - $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); - $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); - // Use vat for invoice creation - if ($conf->facture->enabled) { - $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - } - } - if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { - setEventMessages('ErrorFailedToSaveDate', null, 'errors'); - $db->rollback(); - } else { - setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); - $db->commit(); - } + $db->begin(); + $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; + $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); + // Use vat for invoice creation + if ($conf->facture->enabled) { + $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); + } + } + if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { + setEventMessages('ErrorFailedToSaveDate', null, 'errors'); + $db->rollback(); + } else { + setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); + $db->commit(); + } } // Action to update or add a constant @@ -99,18 +99,18 @@ if ($action == 'update' || $action == 'add') { // Action to enable of a submodule of the adherent module if ($action == 'set') { - $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); - if ($result < 0) { - print $db->error(); - } + $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); + if ($result < 0) { + print $db->error(); + } } // Action to disable a submodule of the adherent module if ($action == 'unset') { - $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); - if ($result < 0) { - print $db->error(); - } + $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); + if ($result < 0) { + print $db->error(); + } } @@ -169,7 +169,7 @@ if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty( print ''; print "\n"; diff --git a/htdocs/adherents/admin/adherent_extrafields.php b/htdocs/adherents/admin/adherent_extrafields.php index ae4f1989114..a391770fdd5 100644 --- a/htdocs/adherents/admin/adherent_extrafields.php +++ b/htdocs/adherents/admin/adherent_extrafields.php @@ -95,7 +95,7 @@ if ($action == 'create') { print '

'; print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -107,7 +107,7 @@ if ($action == 'edit' && !empty($attrname)) { print '

'; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 330568c20bf..d0cdb098bae 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -54,22 +54,22 @@ if ($action == 'update') { $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE'); - $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); - if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); - else { - $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity); - } + $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); + if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); + else { + $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity); + } - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -97,8 +97,8 @@ print ''; print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user'); if ($conf->use_javascript_ajax) { - print "\n".''."\n"; + print ''."\n"; } diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 3af330f0066..2e74fdde9be 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -65,8 +65,8 @@ $result = $object->fetch($id); if ($result > 0) { $object->fetch_thirdparty(); - $adht = new AdherentType($db); - $result = $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $result = $adht->fetch($object->typeid); } @@ -79,17 +79,17 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; - $search_agenda_label = ''; - } + $search_agenda_label = ''; + } } @@ -136,31 +136,31 @@ if ($object->id > 0) { print dol_get_fiche_end(); - //print '
'; - //print '
'; + //print '
'; + //print '
'; $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); - } + if (!empty($conf->agenda->enabled)) { + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); + } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - print '
'; + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { + print '
'; - $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + $param = '&id='.$id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); - } + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } } // End of page diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index aa9797959a7..46c4b07b57c 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -27,15 +27,15 @@ */ abstract class ActionsAdherentCardCommon { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $dirmodule; - public $targetmodule; - public $canvas; - public $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container public $tpl = array(); @@ -54,52 +54,52 @@ abstract class ActionsAdherentCardCommon /** - * Get object + * Get object * - * @param int $id Object id - * @return object Object loaded - */ - public function getObject($id) - { - //$ret = $this->getInstanceDao(); + * @param int $id Object id + * @return object Object loaded + */ + public function getObject($id) + { + //$ret = $this->getInstanceDao(); - /*if (is_object($this->object) && method_exists($this->object,'fetch')) + /*if (is_object($this->object) && method_exists($this->object,'fetch')) { if (! empty($id)) $this->object->fetch($id); } else {*/ - $object = new Adherent($this->db); - if (!empty($id)) $object->fetch($id); - $this->object = $object; - //} - } + $object = new Adherent($this->db); + if (!empty($id)) $object->fetch($id); + $this->object = $object; + //} + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set content of ->tpl array, to use into template - * - * @param string $action Type of action - * @param int $id Id - * @return string HTML output - */ - public function assign_values(&$action, $id) - { - // phpcs:enable - global $conf, $langs, $user, $canvas; - global $form, $formcompany, $objsoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set content of ->tpl array, to use into template + * + * @param string $action Type of action + * @param int $id Id + * @return string HTML output + */ + public function assign_values(&$action, $id) + { + // phpcs:enable + global $conf, $langs, $user, $canvas; + global $form, $formcompany, $objsoc; - if ($action == 'add' || $action == 'update') $this->assign_post(); + if ($action == 'add' || $action == 'update') $this->assign_post(); - foreach ($this->object as $key => $value) { - $this->tpl[$key] = $value; - } + foreach ($this->object as $key => $value) { + $this->tpl[$key] = $value; + } - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; - if ($action == 'create' || $action == 'edit') { - if ($conf->use_javascript_ajax) { + if ($action == 'create' || $action == 'edit') { + if ($conf->use_javascript_ajax) { $this->tpl['ajax_selectcountry'] = "\n".''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) { - $this->tpl['company'] = $objsoc->getNomUrl(1); - $this->tpl['company_id'] = $objsoc->id; - } else { - $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); - } + if (is_object($objsoc) && $objsoc->id > 0) { + $this->tpl['company'] = $objsoc->getNomUrl(1); + $this->tpl['company_id'] = $objsoc->id; + } else { + $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); + } - // Civility - $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); + // Civility + $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); - // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { - if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; - if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; - if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; - if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone; - if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile; - if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; - } + // Predefined with third party + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { + if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; + if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; + if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; + if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone; + if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile; + if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; + } - // Zip - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + // Zip + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); - // Town - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + // Town + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; + if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; - // Country - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); - $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + // Country + $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - // State - if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); - else $this->tpl['select_state'] = $countrynotdefined; + // State + if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); + else $this->tpl['select_state'] = $countrynotdefined; - // Physical or Moral - $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral")); - $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); - } + // Physical or Moral + $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral")); + $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); + } - if ($action == 'view' || $action == 'edit' || $action == 'delete') { - // Emailing - if (!empty($conf->mailing->enabled)) { + if ($action == 'view' || $action == 'edit' || $action == 'delete') { + // Emailing + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } - // Dolibarr user - if ($this->object->user_id) { + // Dolibarr user + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); - } + } - if ($action == 'view' || $action == 'delete') { - $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); + if ($action == 'view' || $action == 'delete') { + $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) { - $objsoc = new Societe($this->db); + if ($this->object->socid > 0) { + $objsoc = new Societe($this->db); - $objsoc->fetch($this->object->socid); - $this->tpl['company'] = $objsoc->getNomUrl(1); - } else { - $this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty"); - } + $objsoc->fetch($this->object->socid); + $this->tpl['company'] = $objsoc->getNomUrl(1); + } else { + $this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty"); + } - $this->tpl['civility'] = $this->object->getCivilityLabel(); + $this->tpl['civility'] = $this->object->getCivilityLabel(); - $this->tpl['address'] = dol_nl2br($this->object->address); + $this->tpl['address'] = dol_nl2br($this->object->address); - $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); + $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); - $img = picto_from_langcode($this->object->country_code); - $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; + $img = picto_from_langcode($this->object->country_code); + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; - $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); - $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); + $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); - $this->tpl['note'] = nl2br($this->object->note); - } + $this->tpl['note'] = nl2br($this->object->note); + } - if ($action == 'create_user') { - // Full firstname and lastname separated with a dot : firstname.lastname - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login = dol_buildlogin($this->object->lastname, $this->object->firstname); + if ($action == 'create_user') { + // Full firstname and lastname separated with a dot : firstname.lastname + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password = getRandomPassword(false); - $password = $generated_password; + $generated_password = getRandomPassword(false); + $password = $generated_password; - // Create a form array - $formquestion = array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), - array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); + // Create a form array + $formquestion = array( + array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), + array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); - $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateAdherent"), "confirm_create_user", $formquestion, 'no'); - } - } + $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateAdherent"), "confirm_create_user", $formquestion, 'no'); + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Assign POST values into object - * - * @return string HTML output - */ - private function assign_post() - { - // phpcs:enable - global $langs, $mysoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Assign POST values into object + * + * @return string HTML output + */ + private function assign_post() + { + // phpcs:enable + global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->fk_soc = $_POST["fk_soc"]; - $this->object->lastname = $_POST["lastname"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->email = $_POST["email"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->fk_soc = $_POST["fk_soc"]; + $this->object->lastname = $_POST["lastname"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->email = $_POST["email"]; + $this->object->note = $_POST["note"]; + $this->object->canvas = $_POST["canvas"]; - // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_object($resql); + // We set country_id, and country_code label of the chosen country + if ($this->object->country_id) { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; - } else { - dol_print_error($this->db); - } - } - } + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; + } else { + dol_print_error($this->db); + } + } + } } diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index db2473c55d9..43d6622f8c9 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -31,21 +31,21 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/canvas/actions_adherentcard_common.cl class ActionsAdherentCardDefault extends ActionsAdherentCardCommon { /** - * Constructor - * - * @param DoliDB $db Handler acces data base - * @param string $dirmodule Name of directory of module - * @param string $targetmodule Name of directory of module where canvas is stored - * @param string $canvas Name of canvas - * @param string $card Name of tab (sub-canvas) + * Constructor + * + * @param DoliDB $db Handler acces data base + * @param string $dirmodule Name of directory of module + * @param string $targetmodule Name of directory of module where canvas is stored + * @param string $canvas Name of canvas + * @param string $card Name of tab (sub-canvas) */ public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { - $this->db = $db; - $this->dirmodule = $dirmodule; - $this->targetmodule = $targetmodule; - $this->canvas = $canvas; - $this->card = $card; + $this->db = $db; + $this->dirmodule = $dirmodule; + $this->targetmodule = $targetmodule; + $this->canvas = $canvas; + $this->card = $card; } /** @@ -67,7 +67,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -77,47 +77,47 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon */ public function assign_values(&$action, $id) { - // phpcs:enable + // phpcs:enable global $limit, $offset, $sortfield, $sortorder; global $conf, $db, $langs, $user; global $form; $ret = $this->getObject($id); - parent::assign_values($action, $id); + parent::assign_values($action, $id); - $this->tpl['title'] = $this->getTitle($action); - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['title'] = $this->getTitle($action); + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; if ($action == 'view') { - // Card header - $head = member_prepare_head($this->object); - $title = $this->getTitle($action); + // Card header + $head = member_prepare_head($this->object); + $title = $this->getTitle($action); - $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); - $this->tpl['showend'] = dol_get_fiche_end(); + $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); + $this->tpl['showend'] = dol_get_fiche_end(); - $objsoc = new Societe($db); - $objsoc->fetch($this->object->socid); + $objsoc = new Societe($db); + $objsoc->fetch($this->object->socid); - $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); - $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); - } else { + $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); + } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->adherent->supprimer) { - $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); - } + if ($action == 'delete' && $user->rights->adherent->supprimer) { + $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); + } } if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); + $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -129,11 +129,11 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon */ public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { - // phpcs:enable + // phpcs:enable global $conf, $langs; - //$this->getFieldList(); + //$this->getFieldList(); - $this->list_datas = array(); + $this->list_datas = array(); } } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 8789b2fcb34..539e174681f 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -118,21 +118,21 @@ if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['acti control->tpl['showend']; if (empty($user->socid)) { - echo '
'; + echo '
'; - if ($user->rights->adherent->creer) { - echo ''.$langs->trans('Modify').''; - } + if ($user->rights->adherent->creer) { + echo ''.$langs->trans('Modify').''; + } - if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { - echo ''.$langs->trans("CreateDolibarrLogin").''; - } + if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { + echo ''.$langs->trans("CreateDolibarrLogin").''; + } - if ($user->rights->adherent->supprimer) { - echo ''.$langs->trans('Delete').''; - } + if ($user->rights->adherent->supprimer) { + echo ''.$langs->trans('Delete').''; + } - echo '

'; + echo '

'; } echo $this->control->tpl['actionstodo']; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 4bffb8bc0db..096a0195668 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -218,7 +218,7 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $birthdate = ''; - if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) + if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) { $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); } diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 958750178f1..b62f58117a2 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -56,163 +56,163 @@ $extrafields->fetch_name_optionals_label($object->table_element); */ if ($mode == 'cardlogin' && empty($foruserlogin)) { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); } if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { - $arrayofmembers = array(); + $arrayofmembers = array(); - // request taking into account member with up to date subscriptions - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; - $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; - $sql .= " t.libelle as type,"; - $sql .= " c.code as country_code, c.label as country"; - // Add fields from extrafields - if (!empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); - $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; - $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; - $sql .= " AND d.entity IN (".getEntity('adherent').")"; - if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; - if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; - $sql .= " ORDER BY d.rowid ASC"; + // request taking into account member with up to date subscriptions + $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; + $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; + $sql .= " t.libelle as type,"; + $sql .= " c.code as country_code, c.label as country"; + // Add fields from extrafields + if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; + $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; + if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; + if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; + $sql .= " ORDER BY d.rowid ASC"; - dol_syslog("Search members", LOG_DEBUG); - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); + dol_syslog("Search members", LOG_DEBUG); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); - if ($objp->country == '-') $objp->country = ''; + if ($objp->country == '-') $objp->country = ''; - $adherentstatic->id = $objp->rowid; - $adherentstatic->lastname = $objp->lastname; - $adherentstatic->firstname = $objp->firstname; + $adherentstatic->id = $objp->rowid; + $adherentstatic->lastname = $objp->lastname; + $adherentstatic->firstname = $objp->firstname; - // Format extrafield so they can be parsed in function complete_substitutions_array - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $adherentstatic->array_options = array(); - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $tmpkey = 'options_'.$key; - if (!empty($objp->$tmpkey)) { - $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; - } - //if (!empty($objp->$key)) - // $objp->array_options[$tmpkey] = $objp->$key; - //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; - } - } + // Format extrafield so they can be parsed in function complete_substitutions_array + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $adherentstatic->array_options = array(); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $tmpkey = 'options_'.$key; + if (!empty($objp->$tmpkey)) { + $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; + } + //if (!empty($objp->$key)) + // $objp->array_options[$tmpkey] = $objp->$key; + //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; + } + } - // List of values to scan for a replacement - $substitutionarray = array( - '__ID__'=>$objp->rowid, - '__LOGIN__'=>$objp->login, - '__FIRSTNAME__'=>$objp->firstname, - '__LASTNAME__'=>$objp->lastname, - '__FULLNAME__'=>$adherentstatic->getFullName($langs), - '__COMPANY__'=>$objp->company, - '__ADDRESS__'=>$objp->address, - '__ZIP__'=>$objp->zip, - '__TOWN__'=>$objp->town, - '__COUNTRY__'=>$objp->country, - '__COUNTRY_CODE__'=>$objp->country_code, - '__EMAIL__'=>$objp->email, - '__BIRTH__'=>dol_print_date($objp->birth, 'day'), - '__TYPE__'=>$objp->type, - '__YEAR__'=>$year, - '__MONTH__'=>$month, - '__DAY__'=>$day, - '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, - '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" - ); - complete_substitutions_array($substitutionarray, $langs, $adherentstatic); + // List of values to scan for a replacement + $substitutionarray = array( + '__ID__'=>$objp->rowid, + '__LOGIN__'=>$objp->login, + '__FIRSTNAME__'=>$objp->firstname, + '__LASTNAME__'=>$objp->lastname, + '__FULLNAME__'=>$adherentstatic->getFullName($langs), + '__COMPANY__'=>$objp->company, + '__ADDRESS__'=>$objp->address, + '__ZIP__'=>$objp->zip, + '__TOWN__'=>$objp->town, + '__COUNTRY__'=>$objp->country, + '__COUNTRY_CODE__'=>$objp->country_code, + '__EMAIL__'=>$objp->email, + '__BIRTH__'=>dol_print_date($objp->birth, 'day'), + '__TYPE__'=>$objp->type, + '__YEAR__'=>$year, + '__MONTH__'=>$month, + '__DAY__'=>$day, + '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, + '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" + ); + complete_substitutions_array($substitutionarray, $langs, $adherentstatic); - // For business cards - if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); - $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); - $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); - $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); + // For business cards + if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { + $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); + $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); + $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); + $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); - if (is_numeric($foruserid) || $foruserlogin) { - $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; - if ($nb <= 0) $nb = 1; // Protection to avoid empty page + if (is_numeric($foruserid) || $foruserlogin) { + $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; + if ($nb <= 0) $nb = 1; // Protection to avoid empty page - for ($j = 0; $j < $nb; $j++) { - $arrayofmembers[] = array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo - ); - } - } else { - $arrayofmembers[] = array( - 'textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo - ); - } - } + for ($j = 0; $j < $nb; $j++) { + $arrayofmembers[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo + ); + } + } else { + $arrayofmembers[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo + ); + } + } - // For labels - if ($mode == 'label') { - if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; - $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); - $textheader = ''; - $textfooter = ''; - $textright = ''; + // For labels + if ($mode == 'label') { + if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; + $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); + $textheader = ''; + $textfooter = ''; + $textright = ''; - $arrayofmembers[] = array('textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo); - } + $arrayofmembers[] = array('textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo); + } - $i++; - } + $i++; + } - // Build and output PDF - if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { - if (!count($arrayofmembers)) { - $mesg = $langs->trans("ErrorRecordNotFound"); - } - if (empty($model) || $model == '-1') { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); - } - if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); - } elseif ($mode == 'label') { - if (!count($arrayofmembers)) { - $mesg = $langs->trans("ErrorRecordNotFound"); - } - if (empty($modellabel) || $modellabel == '-1') { - $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); - } - if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); - } + // Build and output PDF + if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { + if (!count($arrayofmembers)) { + $mesg = $langs->trans("ErrorRecordNotFound"); + } + if (empty($model) || $model == '-1') { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); + } + if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); + } elseif ($mode == 'label') { + if (!count($arrayofmembers)) { + $mesg = $langs->trans("ErrorRecordNotFound"); + } + if (empty($modellabel) || $modellabel == '-1') { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); + } + if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); + } - if ($result <= 0) { - dol_print_error('', $result); - } - } else { - dol_print_error($db); - } + if ($result <= 0) { + dol_print_error('', $result); + } + } else { + dol_print_error($db); + } - if (!$mesg) { - $db->close(); - exit; - } + if (!$mesg) { + $db->close(); + exit; + } } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index d86a9e21d8c..62d0e03e27e 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -32,18 +32,18 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; */ class AdherentStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - public $memberid; - public $socid; - public $userid; + public $memberid; + public $socid; + public $userid; - public $from; - public $field; - public $where; + public $from; + public $field; + public $where; /** @@ -51,15 +51,15 @@ class AdherentStats extends Stats * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param int $userid Id user for filter + * @param int $userid Id user for filter */ public function __construct($db, $socid = 0, $userid = 0) { global $user, $conf; $this->db = $db; - $this->socid = $socid; - $this->userid = $userid; + $this->socid = $socid; + $this->userid = $userid; $object = new Subscription($this->db); @@ -74,16 +74,16 @@ class AdherentStats extends Stats if ($this->memberid) { $this->where .= " AND m.rowid = ".$this->memberid; } - //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; + //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; } /** * Return the number of proposition by month for a given year * - * @param int $year Year - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of nb each month + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of nb each month */ public function getNbByMonth($year, $format = 0) { @@ -95,7 +95,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByMonth($year, $sql, $format); } @@ -103,7 +103,7 @@ class AdherentStats extends Stats /** * Return the number of subscriptions by year * - * @return array Array of nb each year + * @return array Array of nb each year */ public function getNbByYear() { @@ -114,7 +114,7 @@ class AdherentStats extends Stats //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -122,9 +122,9 @@ class AdherentStats extends Stats /** * Return the number of subscriptions by month for a given year * - * @param int $year Year - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of amount each month + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of amount each month */ public function getAmountByMonth($year, $format = 0) { @@ -136,7 +136,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAmountByMonth($year, $sql, $format); } @@ -144,8 +144,8 @@ class AdherentStats extends Stats /** * Return average amount each month * - * @param int $year Year - * @return array Array of average each month + * @param int $year Year + * @return array Array of average each month */ public function getAverageByMonth($year) { @@ -157,7 +157,7 @@ class AdherentStats extends Stats $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -177,7 +177,7 @@ class AdherentStats extends Stats //if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 0e611ff80da..bf57d723589 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -94,17 +94,17 @@ class Members extends DolibarrApi */ public function getByThirdparty($thirdparty) { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -127,23 +127,23 @@ class Members extends DolibarrApi */ public function getByThirdpartyEmail($email) { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $thirdparty = new Societe($this->db); $result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'thirdparty not found'); } $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty->id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -166,23 +166,23 @@ class Members extends DolibarrApi */ public function getByThirdpartyBarcode($barcode) { - if (! DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $thirdparty = new Societe($this->db); $result = $thirdparty->fetch('', '', '', $barcode); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'thirdparty not found'); } $member = new Adherent($this->db); $result = $member->fetch('', '', $thirdparty->id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'member not found'); } - if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { + if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index d5adbb0bc5b..031a7d2b468 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -27,219 +27,219 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; */ class Subscriptions extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'fk_adherent', - 'dateh', - 'datef', - 'amount', - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'fk_adherent', + 'dateh', + 'datef', + 'amount', + ); - /** - * Constructor - */ - public function __construct() - { - global $db, $conf; - $this->db = $db; - } + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + } - /** - * Get properties of a subscription object - * - * Return an array with subscription informations - * - * @param int $id ID of subscription - * @return array|mixed data without useless information - * - * @throws RestException - */ - public function get($id) - { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { - throw new RestException(401); - } + /** + * Get properties of a subscription object + * + * Return an array with subscription informations + * + * @param int $id ID of subscription + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + throw new RestException(401); + } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - return $this->_cleanObjectDatas($subscription); - } + return $this->_cleanObjectDatas($subscription); + } - /** - * List subscriptions - * - * Get a list of subscriptions - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" - * @return array Array of subscription objects - * - * @throws RestException - */ - public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List subscriptions + * + * Get a list of subscriptions + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" + * @return array Array of subscription objects + * + * @throws RestException + */ + public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + throw new RestException(401); + } - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t"; - $sql .= ' WHERE 1 = 1'; - // Add sql filters - if ($sqlfilters) { - if (!DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t"; + $sql .= ' WHERE 1 = 1'; + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit + 1, $offset); - } + $sql .= $this->db->plimit($limit + 1, $offset); + } - $result = $this->db->query($sql); - if ($result) { - $i = 0; - $num = $this->db->num_rows($result); - while ($i < min($limit, $num)) { - $obj = $this->db->fetch_object($result); - $subscription = new Subscription($this->db); - if ($subscription->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($subscription); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror()); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No Subscription found'); - } + $result = $this->db->query($sql); + if ($result) { + $i = 0; + $num = $this->db->num_rows($result); + while ($i < min($limit, $num)) { + $obj = $this->db->fetch_object($result); + $subscription = new Subscription($this->db); + if ($subscription->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($subscription); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No Subscription found'); + } - return $obj_ret; - } + return $obj_ret; + } - /** - * Create subscription object - * - * @param array $request_data Request data - * @return int ID of subscription - */ - public function post($request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create subscription object + * + * @param array $request_data Request data + * @return int ID of subscription + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); - $subscription = new Subscription($this->db); - foreach ($request_data as $field => $value) { - $subscription->$field = $value; - } - if ($subscription->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors)); - } - return $subscription->id; - } + $subscription = new Subscription($this->db); + foreach ($request_data as $field => $value) { + $subscription->$field = $value; + } + if ($subscription->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors)); + } + return $subscription->id; + } - /** - * Update subscription - * - * @param int $id ID of subscription to update - * @param array $request_data Datas - * @return int - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->adherent->creer) { - throw new RestException(401); - } + /** + * Update subscription + * + * @param int $id ID of subscription to update + * @param array $request_data Datas + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $subscription->$field = $value; - } + foreach ($request_data as $field => $value) { + if ($field == 'id') continue; + $subscription->$field = $value; + } - if ($subscription->update(DolibarrApiAccess::$user) > 0) { - return $this->get($id); - } else { - throw new RestException(500, $subscription->error); - } - } + if ($subscription->update(DolibarrApiAccess::$user) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $subscription->error); + } + } - /** - * Delete subscription - * - * @param int $id ID of subscription to delete - * @return array - */ - public function delete($id) - { - // The right to delete a subscription comes with the right to create one. - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { - throw new RestException(401); - } - $subscription = new Subscription($this->db); - $result = $subscription->fetch($id); - if (!$result) { - throw new RestException(404, 'Subscription not found'); - } + /** + * Delete subscription + * + * @param int $id ID of subscription to delete + * @return array + */ + public function delete($id) + { + // The right to delete a subscription comes with the right to create one. + if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + throw new RestException(401); + } + $subscription = new Subscription($this->db); + $result = $subscription->fetch($id); + if (!$result) { + throw new RestException(404, 'Subscription not found'); + } - if (!$subscription->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when deleting subscription'); - } + if (!$subscription->delete(DolibarrApiAccess::$user)) { + throw new RestException(401, 'error when deleting subscription'); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'subscription deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'subscription deleted' + ) + ); + } - /** - * Validate fields before creating an object - * - * @param array|null $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $subscription = array(); - foreach (Subscriptions::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $subscription[$field] = $data[$field]; - } - return $subscription; - } + /** + * Validate fields before creating an object + * + * @param array|null $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $subscription = array(); + foreach (Subscriptions::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $subscription[$field] = $data[$field]; + } + return $subscription; + } } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 5a75fdbae2e..1e6356ee6e4 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -32,435 +32,435 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class Subscription extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'subscription'; + /** + * @var string ID to identify managed object + */ + public $element = 'subscription'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'subscription'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'subscription'; - /** - * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table - */ - public $ismultientitymanaged = 'fk_adherent@adherent'; + /** + * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 'fk_adherent@adherent'; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'payment'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'payment'; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * Date modification record (tms) - * - * @var integer - */ - public $datem; + /** + * Date modification record (tms) + * + * @var integer + */ + public $datem; - /** - * Subscription start date (date subscription) - * - * @var integer - */ - public $dateh; + /** + * Subscription start date (date subscription) + * + * @var integer + */ + public $dateh; - /** - * Subscription end date - * - * @var integer - */ - public $datef; + /** + * Subscription end date + * + * @var integer + */ + public $datef; - /** - * @var int ID - */ - public $fk_type; - public $fk_adherent; + /** + * @var int ID + */ + public $fk_type; + public $fk_adherent; - public $amount; + public $amount; - /** - * @var int ID - */ - public $fk_bank; + /** + * @var int ID + */ + public $fk_bank; - public $fields = array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), - 'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25), - 'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30), - 'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35), - 'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1), - 'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50), - 'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55), - 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60), - 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), - ); + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), + 'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30), + 'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35), + 'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1), + 'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + 'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60), + 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + ); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Function who permitted cretaion of the subscription - * - * @param User $user User that create - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id subscription created if OK - */ - public function create($user, $notrigger = false) - { - global $langs; + /** + * Function who permitted cretaion of the subscription + * + * @param User $user User that create + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id subscription created if OK + */ + public function create($user, $notrigger = false) + { + global $langs; - $error = 0; + $error = 0; - $now = dol_now(); + $now = dol_now(); - // Check parameters - if ($this->datef <= $this->dateh) { - $this->error = $langs->trans("ErrorBadValueForDate"); - return -1; - } - if (empty($this->datec)) $this->datec = $now; + // Check parameters + if ($this->datef <= $this->dateh) { + $this->error = $langs->trans("ErrorBadValueForDate"); + return -1; + } + if (empty($this->datec)) $this->datec = $now; - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); - if ($this->fk_type == null) { // If type not defined, we use the type of member - $type = $member->typeid; - } else { - $type = $this->fk_type; - } - $sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->idate($this->dateh)."',"; - $sql .= " '".$this->db->idate($this->datef)."',"; - $sql .= " ".$this->amount.","; - $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')"; + if ($this->fk_type == null) { // If type not defined, we use the type of member + $type = $member->typeid; + } else { + $type = $this->fk_type; + } + $sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->dateh)."',"; + $sql .= " '".$this->db->idate($this->datef)."',"; + $sql .= " ".$this->amount.","; + $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')"; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror(); + } - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); - $this->fk_type = $type; - } + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->fk_type = $type; + } - if (!$error && !$notrigger) { - $this->context = array('member'=>$member); - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error && !$notrigger) { + $this->context = array('member'=>$member); + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Method to load a subscription - * - * @param int $rowid Id subscription - * @return int <0 if KO, =0 if not found, >0 if OK - */ - public function fetch($rowid) - { - $sql = "SELECT rowid, fk_type, fk_adherent, datec,"; - $sql .= " tms,"; - $sql .= " dateadh as dateh,"; - $sql .= " datef,"; - $sql .= " subscription, note, fk_bank"; - $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; - $sql .= " WHERE rowid=".$rowid; + /** + * Method to load a subscription + * + * @param int $rowid Id subscription + * @return int <0 if KO, =0 if not found, >0 if OK + */ + public function fetch($rowid) + { + $sql = "SELECT rowid, fk_type, fk_adherent, datec,"; + $sql .= " tms,"; + $sql .= " dateadh as dateh,"; + $sql .= " datef,"; + $sql .= " subscription, note, fk_bank"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; + $sql .= " WHERE rowid=".$rowid; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->fk_type = $obj->fk_type; - $this->fk_adherent = $obj->fk_adherent; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->tms); - $this->dateh = $this->db->jdate($obj->dateh); - $this->datef = $this->db->jdate($obj->datef); - $this->amount = $obj->subscription; - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - return 1; - } else { - return 0; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + $this->fk_type = $obj->fk_type; + $this->fk_adherent = $obj->fk_adherent; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->tms); + $this->dateh = $this->db->jdate($obj->dateh); + $this->datef = $this->db->jdate($obj->datef); + $this->amount = $obj->subscription; + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + return 1; + } else { + return 0; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Update subscription - * - * @param User $user User who updated - * @param int $notrigger 0=Disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - $error = 0; + /** + * Update subscription + * + * @param User $user User who updated + * @param int $notrigger 0=Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; - $sql .= " fk_type = ".$this->fk_type.","; - $sql .= " fk_adherent = ".$this->fk_adherent.","; - $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; - $sql .= " subscription = '".price2num($this->amount)."',"; - $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; - $sql .= " datef='".$this->db->idate($this->datef)."',"; - $sql .= " datec='".$this->db->idate($this->datec)."',"; - $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; + $sql .= " fk_type = ".$this->fk_type.","; + $sql .= " fk_adherent = ".$this->fk_adherent.","; + $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; + $sql .= " subscription = '".price2num($this->amount)."',"; + $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; + $sql .= " datef='".$this->db->idate($this->datef)."',"; + $sql .= " datec='".$this->db->idate($this->datec)."',"; + $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); - $result = $member->update_end_date($user); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); + $result = $member->update_end_date($user); - if (!$error && !$notrigger) { - $this->context = array('member'=>$member); - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } else { - $error++; - $this->error = $this->db->lasterror(); - } + if (!$error && !$notrigger) { + $this->context = array('member'=>$member); + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Delete a subscription - * - * @param User $user User that delete - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function delete($user, $notrigger = false) - { - $error = 0; + /** + * Delete a subscription + * + * @param User $user User that delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function delete($user, $notrigger = false) + { + $error = 0; - // It subscription is linked to a bank transaction, we get it - if ($this->fk_bank > 0) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountline = new AccountLine($this->db); - $result = $accountline->fetch($this->fk_bank); - } + // It subscription is linked to a bank transaction, we get it + if ($this->fk_bank > 0) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $accountline = new AccountLine($this->db); + $result = $accountline->fetch($this->fk_bank); + } - $this->db->begin(); + $this->db->begin(); - if (!$error) { - if (!$notrigger) { - // Call triggers - $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } + if (!$error) { + if (!$notrigger) { + // Call triggers + $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->affected_rows($resql); - if ($num) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member = new Adherent($this->db); - $result = $member->fetch($this->fk_adherent); - $result = $member->update_end_date($user); + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->affected_rows($resql); + if ($num) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member = new Adherent($this->db); + $result = $member->fetch($this->fk_adherent); + $result = $member->update_end_date($user); - if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined) + if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined) $result = $accountline->delete($user); // Return false if refused because line is conciliated - if ($result > 0) { - $this->db->commit(); - return 1; - } else { - $this->error = $accountline->error; - $this->db->rollback(); - return -1; - } - } else { - $this->db->commit(); - return 1; - } - } else { - $this->db->commit(); - return 0; - } - } else { - $error++; - $this->error = $this->db->lasterror(); - } - } + if ($result > 0) { + $this->db->commit(); + return 1; + } else { + $this->error = $accountline->error; + $this->db->rollback(); + return -1; + } + } else { + $this->db->commit(); + return 1; + } + } else { + $this->db->commit(); + return 0; + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Return clicable name (with picto eventually) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $notooltip 1=Disable tooltip - * @param string $option Page for link ('', 'nolink', ...) - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine avec URL - */ - public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) - { - global $langs; + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $notooltip 1=Disable tooltip + * @param string $option Page for link ('', 'nolink', ...) + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine avec URL + */ + public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) + { + global $langs; - $result = ''; + $result = ''; - $langs->load("members"); - $label = $langs->trans("ShowSubscription").': '.$this->ref; + $langs->load("members"); + $label = $langs->trans("ShowSubscription").': '.$this->ref; - $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; + $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; - if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; - $picto = 'payment'; + $picto = 'payment'; - $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Retourne le libelle du statut d'une adhesion - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label - */ - public function getLibStatut($mode = 0) - { - return ''; - } + /** + * Retourne le libelle du statut d'une adhesion + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label + */ + public function getLibStatut($mode = 0) + { + return ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status Id status - * @return string Label - */ - public function LibStatut($status) - { - // phpcs:enable - global $langs; - $langs->load("members"); - return ''; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Id status + * @return string Label + */ + public function LibStatut($status) + { + // phpcs:enable + global $langs; + $langs->load("members"); + return ''; + } - /** - * Load information of the subscription object - * - * @param int $id Id subscription - * @return void - */ - public function info($id) - { - $sql = 'SELECT c.rowid, c.datec,'; - $sql .= ' c.tms as datem'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; - $sql .= ' WHERE c.rowid = '.$id; + /** + * Load information of the subscription object + * + * @param int $id Id subscription + * @return void + */ + public function info($id) + { + $sql = 'SELECT c.rowid, c.datec,'; + $sql .= ' c.tms as datem'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; + $sql .= ' WHERE c.rowid = '.$id; - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + } - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index cb6384cfb63..f9c14b91ac3 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -86,7 +86,7 @@ $helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Mi llxHeader("", $title, $helpurl); if ($id > 0) { - $result = $membert->fetch($object->typeid); + $result = $membert->fetch($object->typeid); if ($result > 0) { // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -95,47 +95,47 @@ if ($id > 0) { $totalsize += $file['size']; } - if (!empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'rowid', $linkback); + dol_banner_tab($object, 'rowid', $linkback); - print '
'; + print '
'; - print '
'; + print '
'; print '
'.$langs->trans('Options').''.$langs->trans('Description').'
'.$langs->trans('OptionModeProductSellIntra').''.$langs->trans('OptionModeProductSellIntraDesc'); - print "
'.$langs->trans('OptionModeProductSellIntra').''.$langs->trans('OptionModeProductSellIntraDesc'); + print "
'.$langs->trans('OptionModeProductSellExport').''.$langs->trans('OptionModeProductSellExportDesc'); - print "
'.$langs->trans('OptionModeProductSellExport').''.$langs->trans('OptionModeProductSellExportDesc'); + print "
'.$langs->trans('OptionModeProductBuy').''.$langs->trans('OptionModeProductBuyDesc')."
' . $obj->description . ''.nl2br(dol_trunc($obj->description, $trunclength)).'' . $obj->description . ''.nl2br(dol_trunc($obj->description, $trunclength)).''; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { - print length_accountg($obj->accountancy_code_buy); - if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + print length_accountg($obj->accountancy_code_buy); + if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { - print length_accountg($obj->accountancy_code_buy_intra); - if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { - print length_accountg($obj->accountancy_code_buy_export); - if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { - print length_accountg($obj->accountancy_code_sell); - if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { - print length_accountg($obj->accountancy_code_sell_intra); - if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + print length_accountg($obj->accountancy_code_buy_intra); + if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + print length_accountg($obj->accountancy_code_buy_export); + if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + print length_accountg($obj->accountancy_code_sell); + if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { + print length_accountg($obj->accountancy_code_sell_intra); + if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); } else { - print length_accountg($obj->accountancy_code_sell_export); - if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); - } + print length_accountg($obj->accountancy_code_sell_export); + if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } print ''; //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; @@ -643,25 +643,25 @@ if ($result) print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print ''; - //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; - $codesell = length_accountg($obj->accountancy_code_sell_intra); - //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); - if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); - print ''; - //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code - if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; - $codesell = length_accountg($obj->accountancy_code_sell_export); - if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid - print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); - print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_intra); + //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); + print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; + $codesell = length_accountg($obj->accountancy_code_sell_export); + if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); + print ''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index c3e225e5399..a930ed12852 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -274,11 +274,11 @@ if ($action != 'export_csv') $sous_total_credit = 0; $displayed_account = ""; - $accountingaccountstatic = new AccountingAccount($db); + $accountingaccountstatic = new AccountingAccount($db); $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; - $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features + $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; $sql .= " GROUP BY t.numero_compte"; @@ -292,12 +292,12 @@ if ($action != 'export_csv') foreach ($object->lines as $line) { - $accountingaccountstatic->fetch(null, $line->numero_compte, true); - if (!empty($accountingaccountstatic->account_number)) { - $accounting_account = $accountingaccountstatic->getNomUrl(0, 1); - } else { - $accounting_account = length_accountg($line->numero_compte); - } + $accountingaccountstatic->fetch(null, $line->numero_compte, true); + if (!empty($accountingaccountstatic->account_number)) { + $accounting_account = $accountingaccountstatic->getNomUrl(0, 1); + } else { + $accounting_account = length_accountg($line->numero_compte); + } $link = ''; $total_debit += $line->debit; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index ef9ebe3f9b9..c2a478c79ec 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -114,12 +114,12 @@ if ($action == "confirm_update") { $object->credit = $credit; if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated + $object->montant = $debit; // deprecated $object->amount = $debit; $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated + $object->montant = $credit; // deprecated $object->amount = $credit; $object->sens = 'C'; } @@ -175,13 +175,13 @@ if ($action == "confirm_update") { $object->fk_docdet = (int) GETPOST('fk_docdet', 'int'); if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated + $object->montant = $debit; // deprecated $object->amount = $debit; $object->sens = 'D'; } if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated + $object->montant = $credit; // deprecated $object->amount = $credit; $object->sens = 'C'; } @@ -245,7 +245,7 @@ if ($action == "confirm_update") { $object->journal_label = $journal_label; $object->fk_doc = 0; $object->fk_docdet = 0; - $object->montant = 0; // deprecated + $object->montant = 0; // deprecated $object->amount = 0; $result = $object->createStd($user, 0, $mode); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index d89d0dca60c..6d663edcf4e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -151,7 +151,7 @@ $arrayfields = array( 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0), 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), + 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); @@ -176,145 +176,145 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { - $search_mvt_num = ''; - $search_doc_type = ''; - $search_doc_ref = ''; - $search_doc_date = ''; - $search_accountancy_code = ''; - $search_accountancy_code_start = ''; - $search_accountancy_code_end = ''; - $search_accountancy_aux_code = ''; - $search_accountancy_aux_code_start = ''; - $search_accountancy_aux_code_end = ''; - $search_mvt_label = ''; - $search_direction = ''; - $search_ledger_code = ''; - $search_date_start = ''; - $search_date_end = ''; - $search_date_creation_start = ''; - $search_date_creation_end = ''; - $search_date_modification_start = ''; - $search_date_modification_end = ''; - $search_date_export_start = ''; - $search_date_export_end = ''; - $search_debit = ''; - $search_credit = ''; - $search_lettering_code = ''; + 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_mvt_num = ''; + $search_doc_type = ''; + $search_doc_ref = ''; + $search_doc_date = ''; + $search_accountancy_code = ''; + $search_accountancy_code_start = ''; + $search_accountancy_code_end = ''; + $search_accountancy_aux_code = ''; + $search_accountancy_aux_code_start = ''; + $search_accountancy_aux_code_end = ''; + $search_mvt_label = ''; + $search_direction = ''; + $search_ledger_code = ''; + $search_date_start = ''; + $search_date_end = ''; + $search_date_creation_start = ''; + $search_date_creation_end = ''; + $search_date_modification_start = ''; + $search_date_modification_end = ''; + $search_date_export_start = ''; + $search_date_export_end = ''; + $search_debit = ''; + $search_credit = ''; + $search_lettering_code = ''; $search_not_reconciled = ''; - } + } - // Must be after the remove filter action, before the export. - $param = ''; - $filter = array(); - if (!empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $tmp = dol_getdate($search_date_start); - $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $tmp = dol_getdate($search_date_end); - $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); - } - if (!empty($search_doc_date)) { - $filter['t.doc_date'] = $search_doc_date; - $tmp = dol_getdate($search_doc_date); - $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); - } - if (!empty($search_doc_type)) { - $filter['t.doc_type'] = $search_doc_type; - $param .= '&search_doc_type='.urlencode($search_doc_type); - } - if (!empty($search_doc_ref)) { - $filter['t.doc_ref'] = $search_doc_ref; - $param .= '&search_doc_ref='.urlencode($search_doc_ref); - } - if (!empty($search_accountancy_code)) { - $filter['t.numero_compte'] = $search_accountancy_code; - $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); - } - if (!empty($search_accountancy_code_start)) { - $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); - } - if (!empty($search_accountancy_code_end)) { - $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); - } - if (!empty($search_accountancy_aux_code)) { - $filter['t.subledger_account'] = $search_accountancy_aux_code; - $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); - } - if (!empty($search_accountancy_aux_code_start)) { - $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; - $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); - } - if (!empty($search_accountancy_aux_code_end)) { - $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; - $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end); - } - if (!empty($search_mvt_label)) { - $filter['t.label_operation'] = $search_mvt_label; - $param .= '&search_mvt_label='.urlencode($search_mvt_label); - } - if (!empty($search_direction)) { - $filter['t.sens'] = $search_direction; - $param .= '&search_direction='.urlencode($search_direction); - } - if (!empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code='.urlencode($search_ledger_code); - } - if (!empty($search_mvt_num)) { - $filter['t.piece_num'] = $search_mvt_num; - $param .= '&search_mvt_num='.urlencode($search_mvt_num); - } - if (!empty($search_date_creation_start)) { - $filter['t.date_creation>='] = $search_date_creation_start; - $tmp = dol_getdate($search_date_creation_start); - $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_creation_end)) { - $filter['t.date_creation<='] = $search_date_creation_end; - $tmp = dol_getdate($search_date_creation_end); - $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); - } - if (!empty($search_date_modification_start)) { - $filter['t.tms>='] = $search_date_modification_start; - $tmp = dol_getdate($search_date_modification_start); - $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_modification_end)) { - $filter['t.tms<='] = $search_date_modification_end; - $tmp = dol_getdate($search_date_modification_end); - $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); - } - if (!empty($search_date_export_start)) { - $filter['t.date_export>='] = $search_date_export_start; - $tmp = dol_getdate($search_date_export_start); - $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); - } - if (!empty($search_date_export_end)) { - $filter['t.date_export<='] = $search_date_export_end; - $tmp = dol_getdate($search_date_export_end); - $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); - } - if (!empty($search_debit)) { - $filter['t.debit'] = $search_debit; - $param .= '&search_debit='.urlencode($search_debit); - } - if (!empty($search_credit)) { - $filter['t.credit'] = $search_credit; - $param .= '&search_credit='.urlencode($search_credit); - } - if (!empty($search_lettering_code)) { - $filter['t.lettering_code'] = $search_lettering_code; - $param .= '&search_lettering_code='.urlencode($search_lettering_code); - } + // Must be after the remove filter action, before the export. + $param = ''; + $filter = array(); + if (!empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $tmp = dol_getdate($search_date_start); + $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $tmp = dol_getdate($search_date_end); + $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); + } + if (!empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $tmp = dol_getdate($search_doc_date); + $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); + } + if (!empty($search_doc_type)) { + $filter['t.doc_type'] = $search_doc_type; + $param .= '&search_doc_type='.urlencode($search_doc_type); + } + if (!empty($search_doc_ref)) { + $filter['t.doc_ref'] = $search_doc_ref; + $param .= '&search_doc_ref='.urlencode($search_doc_ref); + } + if (!empty($search_accountancy_code)) { + $filter['t.numero_compte'] = $search_accountancy_code; + $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); + } + if (!empty($search_accountancy_code_start)) { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); + } + if (!empty($search_accountancy_code_end)) { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); + } + if (!empty($search_accountancy_aux_code)) { + $filter['t.subledger_account'] = $search_accountancy_aux_code; + $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); + } + if (!empty($search_accountancy_aux_code_start)) { + $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; + $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); + } + if (!empty($search_accountancy_aux_code_end)) { + $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; + $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end); + } + if (!empty($search_mvt_label)) { + $filter['t.label_operation'] = $search_mvt_label; + $param .= '&search_mvt_label='.urlencode($search_mvt_label); + } + if (!empty($search_direction)) { + $filter['t.sens'] = $search_direction; + $param .= '&search_direction='.urlencode($search_direction); + } + if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + $param .= '&search_ledger_code='.urlencode($search_ledger_code); + } + if (!empty($search_mvt_num)) { + $filter['t.piece_num'] = $search_mvt_num; + $param .= '&search_mvt_num='.urlencode($search_mvt_num); + } + if (!empty($search_date_creation_start)) { + $filter['t.date_creation>='] = $search_date_creation_start; + $tmp = dol_getdate($search_date_creation_start); + $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_creation_end)) { + $filter['t.date_creation<='] = $search_date_creation_end; + $tmp = dol_getdate($search_date_creation_end); + $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); + } + if (!empty($search_date_modification_start)) { + $filter['t.tms>='] = $search_date_modification_start; + $tmp = dol_getdate($search_date_modification_start); + $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_modification_end)) { + $filter['t.tms<='] = $search_date_modification_end; + $tmp = dol_getdate($search_date_modification_end); + $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); + } + if (!empty($search_date_export_start)) { + $filter['t.date_export>='] = $search_date_export_start; + $tmp = dol_getdate($search_date_export_start); + $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); + } + if (!empty($search_date_export_end)) { + $filter['t.date_export<='] = $search_date_export_end; + $tmp = dol_getdate($search_date_export_end); + $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); + } + if (!empty($search_debit)) { + $filter['t.debit'] = $search_debit; + $param .= '&search_debit='.urlencode($search_debit); + } + if (!empty($search_credit)) { + $filter['t.credit'] = $search_credit; + $param .= '&search_credit='.urlencode($search_credit); + } + if (!empty($search_lettering_code)) { + $filter['t.lettering_code'] = $search_lettering_code; + $param .= '&search_lettering_code='.urlencode($search_lettering_code); + } if (!empty($search_not_reconciled)) { $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); @@ -475,48 +475,48 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { { setEventMessages($object->error, $object->errors, 'errors'); } else { - // Export files + // Export files $accountancyexport = new AccountancyExport($db); $accountancyexport->export($object->lines, $formatexportset); - if (!empty($accountancyexport->errors)) - { - setEventMessages('', $accountancyexport->errors, 'errors'); - } else { - // Specify as export : update field date_export - $error = 0; - $db->begin(); + if (!empty($accountancyexport->errors)) + { + setEventMessages('', $accountancyexport->errors, 'errors'); + } else { + // Specify as export : update field date_export + $error = 0; + $db->begin(); - if (is_array($object->lines)) - { - foreach ($object->lines as $movement) - { - $now = dol_now(); + if (is_array($object->lines)) + { + foreach ($object->lines as $movement) + { + $now = dol_now(); - $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " SET date_export = '".$db->idate($now)."'"; - $sql .= " WHERE rowid = ".$movement->id; + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET date_export = '".$db->idate($now)."'"; + $sql .= " WHERE rowid = ".$movement->id; - dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); - $result = $db->query($sql); - if (!$result) - { - $error++; - break; - } - } - } + dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + $error++; + break; + } + } + } - if (!$error) - { - $db->commit(); - // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); - } else { - $error++; - $db->rollback(); - setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); - } - } + if (!$error) + { + $db->commit(); + // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); + } else { + $error++; + $db->rollback(); + setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); + } + } exit; } } @@ -629,9 +629,9 @@ else $buttonLabel = $langs->trans("ExportList"); // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; + $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; } else { - $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; + $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; } $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; @@ -791,14 +791,14 @@ if (!empty($arrayfields['t.tms']['checked'])) // Date export if (!empty($arrayfields['t.date_export']['checked'])) { - print ''; - print '
'; - print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); - print '
'; - print '
'; - print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); - print '
'; - print '
'; + print '
'; + print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print '
'; @@ -854,7 +854,7 @@ while ($i < min($num, $limit)) $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->amount; // deprecated + $line->montant = $obj->amount; // deprecated $line->amount = $obj->amount; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; @@ -893,65 +893,65 @@ while ($i < min($num, $limit)) // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { - if ($line->doc_type == 'customer_invoice') - { - $langs->loadLangs(array('bills')); + if ($line->doc_type == 'customer_invoice') + { + $langs->loadLangs(array('bills')); - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $objectstatic = new Facture($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'facture'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $objectstatic = new Facture($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'facture'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } elseif ($line->doc_type == 'supplier_invoice') - { - $langs->loadLangs(array('bills')); + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'supplier_invoice') + { + $langs->loadLangs(array('bills')); - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $objectstatic = new FactureFournisseur($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'invoice_supplier'; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $objectstatic = new FactureFournisseur($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'invoice_supplier'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); - } elseif ($line->doc_type == 'expense_report') - { - $langs->loadLangs(array('trips')); + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); + } elseif ($line->doc_type == 'expense_report') + { + $langs->loadLangs(array('trips')); - require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $objectstatic = new ExpenseReport($db); - $objectstatic->fetch($line->fk_doc); - //$modulepart = 'expensereport'; + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $objectstatic = new ExpenseReport($db); + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'expensereport'; - $filename = dol_sanitizeFileName($line->doc_ref); - $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; - $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - } else { - // Other type - } + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } else { + // Other type + } - print ''; + print ''; - print ''; - // Picto + Ref - print '
'; + print ''; + // Picto + Ref + print '
'; - if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') - { - print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); - print $documentlink; - } else { - print $line->doc_ref; - } - print '
'; + if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') + { + print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print $documentlink; + } else { + print $line->doc_ref; + } + print '
'; - print "
'.$langs->trans("Balance").':'; print price($sous_total_debit - $sous_total_credit); @@ -665,7 +665,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['t.label_operation']['checked'])) { // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->subledger_account)) == 0 ? '' . $line->label_operation . '' . $line->label_operation . '
(' . length_accounta($line->subledger_account) . ')
'.$line->label_operation.''.$line->label_operation.'
('.length_accounta($line->subledger_account).')
' . ($line->credit ? price($line->credit) : '') . ''.($line->credit ? price($line->credit) : '').'
'.$langs->trans("Balance").':'; print price($sous_total_debit - $sous_total_credit); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php index 8e6387d4608..e831e21f814 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php @@ -195,17 +195,17 @@ dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEB if ($resql) { $i = 0; - $param = "&socid=".$socid; + $param = "&socid=".$socid; print '
'; - print ''; + print ''; print ''; - $letteringbutton = ''; + $letteringbutton = ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; /* print ''; @@ -244,13 +244,13 @@ if ($resql) { print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center '); - print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); + print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $solde = 0; $tmp = ''; - while ($obj = $db->fetch_object($resql)) { + while ($obj = $db->fetch_object($resql)) { if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); @@ -265,20 +265,20 @@ if ($resql) { print ''; // Journal - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $obj->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); - print ''; + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $obj->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); + print ''; - if (empty($obj->lettering_code)) { - print ''; - print ''."\n"; - } else { - print ''; - print ''; - } + if (empty($obj->lettering_code)) { + print ''; + print ''."\n"; + } else { + print ''; + print ''; + } print "\n"; } @@ -299,9 +299,9 @@ if ($resql) { print "
'.price(round($solde, 2)).''.$journaltoshow.''.$journaltoshow.''; - print img_edit(); - print ''.$obj->lettering_code.''; + print img_edit(); + print ''.$obj->lettering_code.'
"; - print '
'."\n"; - print $letteringbutton; - print '
'; + print '
'."\n"; + print $letteringbutton; + print '
'; print ""; $db->free($resql); diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php index afdf5f902f7..16aa51beded 100644 --- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php +++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php @@ -193,17 +193,17 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param = "&socid=".$socid; + $param = "&socid=".$socid; print '
'; - print ''; + print ''; print ''; - $letteringbutton = ''; + $letteringbutton = ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; /* print ''; @@ -242,7 +242,7 @@ if ($resql) { print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center '); - print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); + print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); print "\n"; $solde = 0; @@ -261,21 +261,21 @@ if ($resql) { print ''; print ''; - // Journal - $accountingjournal = new AccountingJournal($db); - $result = $accountingjournal->fetch('', $obj->code_journal); - $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); - print ''; + // Journal + $accountingjournal = new AccountingJournal($db); + $result = $accountingjournal->fetch('', $obj->code_journal); + $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); + print ''; if (empty($obj->lettering_code) && empty($obj->date_validated)) { print ''; - print ''."\n"; + print ''."\n"; } else { - print ''; - print ''; - } + print ''; + print ''; + } print "\n"; } @@ -296,9 +296,9 @@ if ($resql) { print "
'.price($obj->credit).''.price(round($solde, 2)).''.$journaltoshow.''.$journaltoshow.''; - print img_edit(); - print ''; + print img_edit(); + print ''.$obj->lettering_code.''.$obj->lettering_code.'
"; - print '
'."\n"; + print '
'."\n"; print $letteringbutton; - print '
'; + print '
'; print ""; $db->free($resql); diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index c7f7f8cf68c..eb43348f1ea 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -31,10 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; */ class AccountancyCategory // extends CommonObject { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error string @@ -63,9 +63,9 @@ class AccountancyCategory // extends CommonObject public $rowid; /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; /** * @var string Accountancy code @@ -73,11 +73,11 @@ class AccountancyCategory // extends CommonObject public $code; /** - * @var string Accountancy Category label - */ - public $label; + * @var string Accountancy Category label + */ + public $label; - /** + /** * @var string Accountancy range account */ public $range_account; @@ -381,8 +381,8 @@ class AccountancyCategory // extends CommonObject * @param int $id Id * @return int <0 if KO, 0 if not found, >0 if OK */ - public function display($id) - { + public function display($id) + { global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; @@ -408,7 +408,7 @@ class AccountancyCategory // extends CommonObject return -1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -417,8 +417,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function getCptBK($id) - { + public function getCptBK($id) + { global $conf; $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref"; @@ -457,7 +457,7 @@ class AccountancyCategory // extends CommonObject return -1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -466,41 +466,41 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function getAccountsWithNoCategory($id) - { - global $conf; + public function getAccountsWithNoCategory($id) + { + global $conf; - $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; - $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; - $sql .= " AND aa.active = 1"; - $sql .= " AND aa.entity = ".$conf->entity; - $sql .= " GROUP BY aa.account_number, aa.label"; - $sql .= " ORDER BY aa.account_number, aa.label"; + $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; + $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; + $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = ".$conf->entity; + $sql .= " GROUP BY aa.account_number, aa.label"; + $sql .= " ORDER BY aa.account_number, aa.label"; - $this->lines_CptBk = array(); + $this->lines_CptBk = array(); - dol_syslog(__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) { - while ($obj = $this->db->fetch_object($resql)) { - $this->lines_cptbk[] = $obj; - } - } + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) { + while ($obj = $this->db->fetch_object($resql)) { + $this->lines_cptbk[] = $obj; + } + } - return $num; - } else { - $this->error = "Error ".$this->db->lasterror(); - $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + return $num; + } else { + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = $this->error; + dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); - return -1; - } - } + return -1; + } + } /** * Function to add an accounting account in an accounting category @@ -510,8 +510,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function updateAccAcc($id_cat, $cpts = array()) - { + public function updateAccAcc($id_cat, $cpts = array()) + { global $conf; $error = 0; @@ -523,7 +523,7 @@ class AccountancyCategory // extends CommonObject $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity = ".$conf->entity; - $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql + $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $this->db->begin(); @@ -539,13 +539,13 @@ class AccountancyCategory // extends CommonObject $accountincptsadded = array(); while ($obj = $this->db->fetch_object($resql)) { - $account_number_formated = length_accountg($obj->account_number); - if (!empty($accountincptsadded[$account_number_formated])) continue; + $account_number_formated = length_accountg($obj->account_number); + if (!empty($accountincptsadded[$account_number_formated])) continue; - if (array_key_exists($account_number_formated, $cpts)) + if (array_key_exists($account_number_formated, $cpts)) { - $accountincptsadded[$account_number_formated] = 1; - // We found an account number that is in list $cpts of account to add + $accountincptsadded[$account_number_formated] = 1; + // We found an account number that is in list $cpts of account to add $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account"; $sql .= " SET fk_accounting_category=".$id_cat; $sql .= " WHERE rowid=".$obj->rowid; @@ -572,7 +572,7 @@ class AccountancyCategory // extends CommonObject return 1; } - } + } /** * Function to delete an accounting account from an accounting category @@ -581,8 +581,8 @@ class AccountancyCategory // extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function deleteCptCat($cpt_id) - { + public function deleteCptCat($cpt_id) + { $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa"; @@ -598,7 +598,7 @@ class AccountancyCategory // extends CommonObject } // Commit or rollback - if ($error) { + if ($error) { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); @@ -606,12 +606,12 @@ class AccountancyCategory // extends CommonObject $this->db->rollback(); return -1 * $error; - } else { + } else { $this->db->commit(); - return 1; - } - } + return 1; + } + } /** * Function to know all category from accounting account @@ -781,7 +781,7 @@ class AccountancyCategory // extends CommonObject 'formula' => $obj->formula, 'position' => $obj->position, 'category_type' => $obj->category_type, - 'bc' => $obj->sens + 'bc' => $obj->sens ); $i++; } diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 0204602438f..845c300c952 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -55,7 +55,7 @@ class AccountancyExport public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_WINFIC = 70; public static $EXPORT_TYPE_OPENCONCERTO = 100; - public static $EXPORT_TYPE_LDCOMPTA = 110; + public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA10 = 120; public static $EXPORT_TYPE_FEC = 1000; @@ -111,7 +111,7 @@ class AccountancyExport self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), - self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), + self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'), @@ -144,9 +144,9 @@ class AccountancyExport self::$EXPORT_TYPE_COGILOG => 'cogilog', self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', - self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', - self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', - self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', + self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', + self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', + self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', self::$EXPORT_TYPE_FEC => 'fec', ); @@ -201,22 +201,22 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => array( 'label' => $langs->trans('Modelcsv_agiris'), ), - self::$EXPORT_TYPE_OPENCONCERTO => array( - 'label' => $langs->trans('Modelcsv_openconcerto'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + self::$EXPORT_TYPE_OPENCONCERTO => array( + 'label' => $langs->trans('Modelcsv_openconcerto'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_SAGE50_SWISS => array( 'label' => $langs->trans('Modelcsv_Sage50_Swiss'), 'ACCOUNTING_EXPORT_FORMAT' => 'csv', ), - self::$EXPORT_TYPE_LDCOMPTA => array( - 'label' => $langs->trans('Modelcsv_LDCompta'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + self::$EXPORT_TYPE_LDCOMPTA => array( + 'label' => $langs->trans('Modelcsv_LDCompta'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_LDCOMPTA10 => array( - 'label' => $langs->trans('Modelcsv_LDCompta10'), - 'ACCOUNTING_EXPORT_FORMAT' => 'csv', - ), + 'label' => $langs->trans('Modelcsv_LDCompta10'), + 'ACCOUNTING_EXPORT_FORMAT' => 'csv', + ), self::$EXPORT_TYPE_FEC => array( 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', @@ -254,7 +254,7 @@ class AccountancyExport $filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $type_export = 'general_ledger'; - global $db; // The tpl file use $db + global $db; // The tpl file use $db include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; @@ -289,21 +289,21 @@ class AccountancyExport case self::$EXPORT_TYPE_AGIRIS : $this->exportAgiris($TData); break; - case self::$EXPORT_TYPE_OPENCONCERTO : - $this->exportOpenConcerto($TData); - break; + case self::$EXPORT_TYPE_OPENCONCERTO : + $this->exportOpenConcerto($TData); + break; case self::$EXPORT_TYPE_SAGE50_SWISS : $this->exportSAGE50SWISS($TData); break; - case self::$EXPORT_TYPE_LDCOMPTA : - $this->exportLDCompta($TData); - break; - case self::$EXPORT_TYPE_LDCOMPTA10 : - $this->exportLDCompta10($TData); - break; - case self::$EXPORT_TYPE_FEC : - $this->exportFEC($TData); - break; + case self::$EXPORT_TYPE_LDCOMPTA : + $this->exportLDCompta($TData); + break; + case self::$EXPORT_TYPE_LDCOMPTA10 : + $this->exportLDCompta10($TData); + break; + case self::$EXPORT_TYPE_FEC : + $this->exportFEC($TData); + break; case self::$EXPORT_TYPE_CHARLEMAGNE : $this->exportCharlemagne($TData); break; @@ -599,7 +599,7 @@ class AccountancyExport $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); if ($data->sens == 'D') { - $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); + $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); } else { @@ -659,10 +659,10 @@ class AccountancyExport print $date.$separator; print $line->code_journal.$separator; if (empty($line->subledger_account)) { - print $line->numero_compte.$separator; - } else { - print $line->subledger_account.$separator; - } + print $line->numero_compte.$separator; + } else { + print $line->subledger_account.$separator; + } //print substr(length_accountg($line->numero_compte), 0, 2) . $separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; @@ -714,36 +714,36 @@ class AccountancyExport } } - /** - * Export format : OpenConcerto - * - * @param array $objectLines data - * @return void - */ - public function exportOpenConcerto($objectLines) - { + /** + * Export format : OpenConcerto + * + * @param array $objectLines data + * @return void + */ + public function exportOpenConcerto($objectLines) + { - $separator = ';'; - $end_line = "\n"; + $separator = ';'; + $end_line = "\n"; - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date.$separator; - print $line->code_journal.$separator; - if (empty($line->subledger_account)) { - print length_accountg($line->numero_compte).$separator; - } else { - print length_accounta($line->subledger_account).$separator; - } - print $line->doc_ref.$separator; - print $line->label_operation.$separator; - print price($line->debit).$separator; - print price($line->credit).$separator; + print $date.$separator; + print $line->code_journal.$separator; + if (empty($line->subledger_account)) { + print length_accountg($line->numero_compte).$separator; + } else { + print length_accounta($line->subledger_account).$separator; + } + print $line->doc_ref.$separator; + print $line->label_operation.$separator; + print price($line->debit).$separator; + print price($line->credit).$separator; - print $end_line; - } - } + print $end_line; + } + } /** * Export format : Configurable CSV @@ -822,25 +822,25 @@ class AccountancyExport print $line->piece_num.$separator; // FEC:EcritureDate - print $date_document . $separator; + print $date_document.$separator; // FEC:CompteNum print $line->numero_compte.$separator; // FEC:CompteLib - print dol_string_unaccent($line->label_compte) . $separator; + print dol_string_unaccent($line->label_compte).$separator; // FEC:CompAuxNum print $line->subledger_account.$separator; // FEC:CompAuxLib - print dol_string_unaccent($line->subledger_label) . $separator; + print dol_string_unaccent($line->subledger_label).$separator; // FEC:PieceRef print $line->doc_ref.$separator; // FEC:PieceDate - print dol_string_unaccent($date_creation) . $separator; + print dol_string_unaccent($date_creation).$separator; // FEC:EcritureLib print $line->label_operation.$separator; @@ -858,7 +858,7 @@ class AccountancyExport print $line->date_lettering.$separator; // FEC:ValidDate - print $date_validation . $separator; + print $date_validation.$separator; // FEC:Montantdevise print $line->multicurrency_amount.$separator; @@ -870,152 +870,152 @@ class AccountancyExport } } - /** - * Export format : SAGE50SWISS - * - * https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984 - * http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf - * - * @param array $objectLines data - * - * @return void - */ - public function exportSAGE50SWISS($objectLines) - { - // SAGE50SWISS - $this->separator = ','; - $this->end_line = "\r\n"; + /** + * Export format : SAGE50SWISS + * + * https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984 + * http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf + * + * @param array $objectLines data + * + * @return void + */ + public function exportSAGE50SWISS($objectLines) + { + // SAGE50SWISS + $this->separator = ','; + $this->end_line = "\r\n"; - // Print header line - print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag"; - print $this->end_line; - $thisPieceNum = ""; - $thisPieceAccountNr = ""; - $aSize = count($objectLines); - foreach ($objectLines as $aIndex=>$line) + // Print header line + print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag"; + print $this->end_line; + $thisPieceNum = ""; + $thisPieceAccountNr = ""; + $aSize = count($objectLines); + foreach ($objectLines as $aIndex=>$line) { - $sammelBuchung = false; - if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) - { - $sammelBuchung = true; - } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) - { - $sammelBuchung = true; - } elseif ($aIndex + 1 < $aSize - && $objectLines[$aIndex + 1]->piece_num == $line->piece_num - && $aIndex - 1 < $aSize - && $objectLines[$aIndex - 1]->piece_num == $line->piece_num - ) - { - $sammelBuchung = true; - } + $sammelBuchung = false; + if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) + { + $sammelBuchung = true; + } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) + { + $sammelBuchung = true; + } elseif ($aIndex + 1 < $aSize + && $objectLines[$aIndex + 1]->piece_num == $line->piece_num + && $aIndex - 1 < $aSize + && $objectLines[$aIndex - 1]->piece_num == $line->piece_num + ) + { + $sammelBuchung = true; + } - //Blg - print $line->piece_num.$this->separator; + //Blg + print $line->piece_num.$this->separator; - // Datum - $date = dol_print_date($line->doc_date, '%d.%m.%Y'); - print $date.$this->separator; + // Datum + $date = dol_print_date($line->doc_date, '%d.%m.%Y'); + print $date.$this->separator; - // Kto - print length_accountg($line->numero_compte).$this->separator; - // S/H - if ($line->sens == 'D') - { - print 'S'.$this->separator; - } else { - print 'H'.$this->separator; - } - //Grp - print self::trunc($line->code_journal, 1).$this->separator; - // GKto - if (empty($line->code_tiers)) - { - if ($line->piece_num == $thisPieceNum) - { - print length_accounta($thisPieceAccountNr).$this->separator; - } else { - print "div".$this->separator; - } - } else { - print length_accounta($line->code_tiers).$this->separator; - } - //SId - print $this->separator; - //SIdx - print "0".$this->separator; - //KIdx - print "0".$this->separator; - //BTyp - print "0".$this->separator; + // Kto + print length_accountg($line->numero_compte).$this->separator; + // S/H + if ($line->sens == 'D') + { + print 'S'.$this->separator; + } else { + print 'H'.$this->separator; + } + //Grp + print self::trunc($line->code_journal, 1).$this->separator; + // GKto + if (empty($line->code_tiers)) + { + if ($line->piece_num == $thisPieceNum) + { + print length_accounta($thisPieceAccountNr).$this->separator; + } else { + print "div".$this->separator; + } + } else { + print length_accounta($line->code_tiers).$this->separator; + } + //SId + print $this->separator; + //SIdx + print "0".$this->separator; + //KIdx + print "0".$this->separator; + //BTyp + print "0".$this->separator; - //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung - if ($sammelBuchung) - { - print "2".$this->separator; - } else { - print "1".$this->separator; - } - // Code - print '""'.$this->separator; - // Netto - if ($line->montant >= 0) - { - print $line->montant.$this->separator; - } else { - print ($line->montant * -1).$this->separator; - } - // Steuer - print "0.00".$this->separator; - // FW-Betrag - print "0.00".$this->separator; - // Tx1 - $line1 = self::toAnsi($line->label_compte, 29); - if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) - { - $line1 = ""; - } - $line2 = self::toAnsi($line->doc_ref, 29); - if (strlen($line1) == 0) - { - $line1 = $line2; - $line2 = ""; - } - if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) - { - $line1 = $line1.' / '.$line2; - $line2 = ""; - } + //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung + if ($sammelBuchung) + { + print "2".$this->separator; + } else { + print "1".$this->separator; + } + // Code + print '""'.$this->separator; + // Netto + if ($line->montant >= 0) + { + print $line->montant.$this->separator; + } else { + print ($line->montant * -1).$this->separator; + } + // Steuer + print "0.00".$this->separator; + // FW-Betrag + print "0.00".$this->separator; + // Tx1 + $line1 = self::toAnsi($line->label_compte, 29); + if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) + { + $line1 = ""; + } + $line2 = self::toAnsi($line->doc_ref, 29); + if (strlen($line1) == 0) + { + $line1 = $line2; + $line2 = ""; + } + if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) + { + $line1 = $line1.' / '.$line2; + $line2 = ""; + } - print '"'.self::toAnsi($line1).'"'.$this->separator; - // Tx2 - print '"'.self::toAnsi($line2).'"'.$this->separator; - //PkKey - print "0".$this->separator; - //OpId - print $this->separator; + print '"'.self::toAnsi($line1).'"'.$this->separator; + // Tx2 + print '"'.self::toAnsi($line2).'"'.$this->separator; + //PkKey + print "0".$this->separator; + //OpId + print $this->separator; - // Flag - print "0"; + // Flag + print "0"; - print $this->end_line; + print $this->end_line; - if ($line->piece_num !== $thisPieceNum) - { - $thisPieceNum = $line->piece_num; - $thisPieceAccountNr = $line->numero_compte; - } - } - } + if ($line->piece_num !== $thisPieceNum) + { + $thisPieceNum = $line->piece_num; + $thisPieceAccountNr = $line->numero_compte; + } + } + } - /** - * Export format : LD Compta version 9 - * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf - * - * @param array $objectLines data - * - * @return void - */ + /** + * Export format : LD Compta version 9 + * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf + * + * @param array $objectLines data + * + * @return void + */ public function exportLDCompta($objectLines) { @@ -1168,23 +1168,23 @@ class AccountancyExport { $soc = $this->db->fetch_object($resql); - $address = array('', '', ''); - if (strpos($soc->address, "\n") !== false) { - $address = explode("\n", $soc->address); - if (is_array($address) && count($address) > 0) { - foreach ($address as $key=>$data) { - $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); - $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); - } - } - } else { - $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); - $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); - $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); - } + $address = array('', '', ''); + if (strpos($soc->address, "\n") !== false) { + $address = explode("\n", $soc->address); + if (is_array($address) && count($address) > 0) { + foreach ($address as $key=>$data) { + $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); + $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); + } + } + } else { + $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); + $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); + $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); + } $type_enregistrement = 'C'; - //TYPE + //TYPE print $type_enregistrement.$separator; //NOCL print $soc->code_client.$separator; @@ -1193,15 +1193,15 @@ class AccountancyExport //LIBI print $separator; //TITR - print $separator; + print $separator; //RSSO print $soc->nom.$separator; //CAD1 - print $address[0].$separator; + print $address[0].$separator; //CAD2 - print $address[1].$separator; + print $address[1].$separator; //CAD3 - print $address[2].$separator; + print $address[2].$separator; //COPO print $soc->zip.$separator; //BUDI @@ -1223,7 +1223,7 @@ class AccountancyExport //COMM print $separator; //SIRE - print str_replace(" ", "", $soc->siret).$separator; + print str_replace(" ", "", $soc->siret).$separator; //RIBP print $separator; //DOBQ @@ -1486,15 +1486,15 @@ class AccountancyExport * * @param string $str Original string to encode and optionaly truncate * @param integer $size Truncate string after $size characters - * @return string String encoded in Windows-1251 charset + * @return string String encoded in Windows-1251 charset */ public static function toAnsi($str, $size = -1) - { + { $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251'); - if ($retVal >= 0 && $size >= 0) - { - $retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); - } - return $retVal; + if ($retVal >= 0 && $size >= 0) + { + $retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); + } + return $retVal; } } diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index c2f3468016c..193a03f1726 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -28,10 +28,10 @@ */ class AccountancySystem { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -44,13 +44,13 @@ class AccountancySystem public $rowid; /** - * @var int ID - */ + * @var int ID + */ public $fk_pcg_version; - /** - * @var string pcg type - */ + /** + * @var string pcg type + */ public $pcg_type; /** @@ -59,18 +59,18 @@ class AccountancySystem public $numero; /** - * @var string Accountancy System label - */ - public $label; + * @var string Accountancy System label + */ + public $label; - /** - * @var string account number - */ + /** + * @var string account number + */ public $account_number; - /** - * @var string account parent - */ + /** + * @var string account parent + */ public $account_parent; /** @@ -78,10 +78,10 @@ class AccountancySystem * * @param DoliDB $db handler */ - public function __construct($db) - { + public function __construct($db) + { $this->db = $db; - } + } /** @@ -93,42 +93,42 @@ class AccountancySystem */ public function fetch($rowid = 0, $ref = '') { - global $conf; + global $conf; - if ($rowid > 0 || $ref) - { - $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; - $sql .= " WHERE"; - if ($rowid) { - $sql .= " a.rowid = ".((int) $rowid); - } elseif ($ref) { - $sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; - } + if ($rowid > 0 || $ref) + { + $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; + $sql .= " WHERE"; + if ($rowid) { + $sql .= " a.rowid = ".((int) $rowid); + } elseif ($ref) { + $sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; + } - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); - if ($obj) { - $this->id = $obj->rowid; - $this->rowid = $obj->rowid; - $this->pcg_version = $obj->pcg_version; - $this->ref = $obj->pcg_version; - $this->label = $obj->label; - $this->active = $obj->active; + if ($obj) { + $this->id = $obj->rowid; + $this->rowid = $obj->rowid; + $this->pcg_version = $obj->pcg_version; + $this->ref = $obj->pcg_version; + $this->label = $obj->label; + $this->active = $obj->active; - return $this->id; - } else { - return 0; - } - } else { - $this->error = "Error ".$this->db->lasterror(); - $this->errors[] = "Error ".$this->db->lasterror(); - } - } - return -1; + return $this->id; + } else { + return 0; + } + } else { + $this->error = "Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); + } + } + return -1; } @@ -138,8 +138,8 @@ class AccountancySystem * @param User $user making insert * @return int if KO, Id of line if OK */ - public function create($user) - { + public function create($user) + { $now = dol_now(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system"; @@ -165,6 +165,6 @@ class AccountancySystem dol_syslog($this->error, LOG_ERR); } - return $result; - } + return $result; + } } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index e7a65ceec97..ebf397c2dfd 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -74,35 +74,35 @@ class AccountingAccount extends CommonObject public $rowid; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * @var string pcg version - */ + * @var string pcg version + */ public $fk_pcg_version; - /** - * @var string pcg type - */ + /** + * @var string pcg type + */ public $pcg_type; - /** - * @var string account number - */ + /** + * @var string account number + */ public $account_number; - /** - * @var int ID parent account - */ + /** + * @var int ID parent account + */ public $account_parent; - /** - * @var int ID category account - */ + /** + * @var int ID category account + */ public $account_category; /** @@ -110,10 +110,10 @@ class AccountingAccount extends CommonObject */ public $status; - /** - * @var string Label of account - */ - public $label; + /** + * @var string Label of account + */ + public $label; /** * @var string Label short of account @@ -121,19 +121,19 @@ class AccountingAccount extends CommonObject public $labelshort; /** - * @var int ID - */ - public $fk_user_author; + * @var int ID + */ + public $fk_user_author; - /** - * @var int ID - */ - public $fk_user_modif; + /** + * @var int ID + */ + public $fk_user_modif; /** * @var int active (duplicate with status) */ - public $active; + public $active; /** * @var int reconcilable @@ -145,13 +145,13 @@ class AccountingAccount extends CommonObject * * @param DoliDB $db Database handle */ - public function __construct($db) - { + public function __construct($db) + { global $conf; $this->db = $db; $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method - } + } /** * Load record in memory @@ -162,7 +162,7 @@ class AccountingAccount extends CommonObject * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') + public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') { global $conf; @@ -182,7 +182,7 @@ class AccountingAccount extends CommonObject $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')'; } if (!empty($limittoachartaccount)) { - $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; + $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); @@ -229,8 +229,8 @@ class AccountingAccount extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - public function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error = 0; $now = dol_now(); @@ -318,7 +318,7 @@ class AccountingAccount extends CommonObject $this->db->commit(); return $this->id; } - } + } /** * Update record @@ -366,8 +366,8 @@ class AccountingAccount extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function checkUsage() - { + public function checkUsage() + { global $langs; $sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet"; @@ -400,8 +400,8 @@ class AccountingAccount extends CommonObject * @param int $notrigger 0=triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) - { + public function delete($user, $notrigger = 0) + { $error = 0; $result = $this->checkUsage(); @@ -436,9 +436,9 @@ class AccountingAccount extends CommonObject } else { return -1; } - } + } - /** + /** * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto @@ -446,12 +446,12 @@ class AccountingAccount extends CommonObject * @param int $nourl 1=Disable url * @param string $moretitle Add more text to title tooltip * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) * @param string $option 'ledger', 'journals', 'accountcard' * @return string String with URL */ - public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') { global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -524,7 +524,7 @@ class AccountingAccount extends CommonObject if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend; return $result; - } + } /** * Information on record @@ -532,8 +532,8 @@ class AccountingAccount extends CommonObject * @param int $id of record * @return void */ - public function info($id) - { + public function info($id) + { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a'; $sql .= ' WHERE a.rowid = '.$id; @@ -568,18 +568,18 @@ class AccountingAccount extends CommonObject * Deactivate an account (for status active or status reconcilable) * * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function accountDeactivate($id, $mode = 0) - { + public function accountDeactivate($id, $mode = 0) + { $result = $this->checkUsage(); $fieldtouse = 'active'; - if ($mode == 1) - { + if ($mode == 1) + { $fieldtouse = 'reconcilable'; - } + } if ($result > 0) { $this->db->begin(); @@ -604,26 +604,26 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account activated * * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function account_activate($id, $mode = 0) - { - // phpcs:enable + public function account_activate($id, $mode = 0) + { + // phpcs:enable $this->db->begin(); - if ($mode == 0) - { - $fieldtouse = 'active'; - } elseif ($mode == 1) - { - $fieldtouse = 'reconcilable'; - } + if ($mode == 0) + { + $fieldtouse = 'active'; + } elseif ($mode == 1) + { + $fieldtouse = 'reconcilable'; + } $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; $sql .= "SET ".$fieldtouse." = '1'"; @@ -631,15 +631,15 @@ class AccountingAccount extends CommonObject dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { $this->db->commit(); return 1; - } else { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; - } - } + } + } /** @@ -653,7 +653,7 @@ class AccountingAccount extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -663,7 +663,7 @@ class AccountingAccount extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->loadLangs(array("users")); diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 882eee71769..c002abf2a89 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -56,29 +56,29 @@ class AccountingJournal extends CommonObject */ public $rowid; - /** - * @var string Accounting journal code - */ + /** + * @var string Accounting journal code + */ public $code; /** - * @var string Accounting Journal label - */ - public $label; + * @var string Accounting Journal label + */ + public $label; - /** - * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new - */ - public $nature; + /** + * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + */ + public $nature; - /** - * @var int is active or not - */ + /** + * @var int is active or not + */ public $active; - /** - * @var array array of lines - */ + /** + * @var array array of lines + */ public $lines; /** @@ -86,10 +86,10 @@ class AccountingJournal extends CommonObject * * @param DoliDB $db Database handle */ - public function __construct($db) - { - $this->db = $db; - } + public function __construct($db) + { + $this->db = $db; + } /** * Load an object from database @@ -155,8 +155,8 @@ class AccountingJournal extends CommonObject * * @return int <0 if KO, >0 if OK */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { $sql = "SELECT rowid, code, label, nature, active"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter @@ -284,7 +284,7 @@ class AccountingJournal extends CommonObject return $this->LibType($this->nature, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return type of an accounting journal * @@ -294,7 +294,7 @@ class AccountingJournal extends CommonObject */ public function LibType($nature, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->loadLangs(array("accountancy")); diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php index 808ccfba0ef..1013ad1b6ce 100644 --- a/htdocs/accountancy/closure/validate.php +++ b/htdocs/accountancy/closure/validate.php @@ -63,24 +63,24 @@ $year_current = $year_start; if ($action == 'validate') { - $now = dol_now(); + $now = dol_now(); - // Update database - $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " SET b.date_validated = '".$db->idate($now)."'"; - $sql .= ' WHERE b.date_validated IS NULL'; + // Update database + $db->begin(); + $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++; - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } else { - $db->commit(); - } - // End clean database + dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); + $resql = $db->query($sql); + if (!$resql1) { + $error++; + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $db->commit(); + } + // End clean database } @@ -135,8 +135,8 @@ if ($resql) { while ($row = $db->fetch_row($resql)) { for ($i = 1; $i <= 12; $i++) { print '
'.$row[$i].'

'; - print ''; - print '
'.$row[13].''; print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0); if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') { - print '
'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'
'; + print '
'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'
'; } print '
'; $linkback = ''.$langs->trans("BackToList").''; - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; - } + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } - // Type - print '\n"; + // Type + print '\n"; - // Morphy - print ''; - /*print ''; + /*print '';*/ - print ''; + print ''; - // Company - print ''; + // Company + print ''; - // Civility - print ''; - print ''; + // Civility + print ''; + print ''; - // Number of Attached Files + // Number of Attached Files print ''; //Total Size Of Attached Files @@ -157,7 +157,7 @@ if ($id > 0) { dol_print_error($db); } } else { - $langs->load("errors"); + $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); } diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index aa7564007a6..fc93f828f6c 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -125,29 +125,29 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo // Search contact/address - if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { - $listofsearchfields['search_member'] = array('text'=>'Member'); - } + if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { + $listofsearchfields['search_member'] = array('text'=>'Member'); + } - if (count($listofsearchfields)) { - print '
'; - print ''; - print '
'; - print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Type").''.$membert->getNomUrl(1)."
'.$langs->trans("Type").''.$membert->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; + // Morphy + print '
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; print $form->showphoto('memberphoto',$object); print '
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'; - $i = 0; - foreach ($listofsearchfields as $key => $value) { - if ($i == 0) print ''; - print ''; - print ''; - if ($i == 0) print ''; - print ''; - $i++; - } - print '
'.$langs->trans("Search").'
:
'; - print ''; - print ''; - print '
'; - } + if (count($listofsearchfields)) { + print '
'; + print ''; + print '
'; + print ''; + $i = 0; + foreach ($listofsearchfields as $key => $value) { + if ($i == 0) print ''; + print ''; + print ''; + if ($i == 0) print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Search").'
:
'; + print '
'; + print '
'; + print '
'; + } } @@ -158,53 +158,53 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel if ($conf->use_javascript_ajax) { print '
'; print ''; - print ''; - print ''; + print ''; - print ''; - print '
'.$langs->trans("Statistics").'
'; + print '
'.$langs->trans("Statistics").'
'; - $SommeA = 0; - $SommeB = 0; - $SommeC = 0; - $SommeD = 0; - $total = 0; - $dataval = array(); - $i = 0; - foreach ($AdherentType as $key => $adhtype) { - $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); - $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); - $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); - $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); - $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; - $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; - $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; - $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; - $i++; - } - $total = $SommeA + $SommeB + $SommeC + $SommeD; - $dataseries = array(); - $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB)); - $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); + $SommeA = 0; + $SommeB = 0; + $SommeC = 0; + $SommeD = 0; + $total = 0; + $dataval = array(); + $i = 0; + foreach ($AdherentType as $key => $adhtype) { + $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); + $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); + $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); + $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); + $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; + $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; + $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; + $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $i++; + } + $total = $SommeA + $SommeB + $SommeC + $SommeD; + $dataseries = array(); + $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB)); + $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); - print '
'.$langs->trans("Total").''; - print $SommeA + $SommeB + $SommeC + $SommeD; - print '
'; - print '
'; + print '
'.$langs->trans("Total").''; + print $SommeA + $SommeB + $SommeC + $SommeD; + print '
'; + print ''; } print '
'; @@ -223,17 +223,17 @@ $sql .= " AND d.rowid = c.fk_adherent"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); - $year = dol_print_date($db->jdate($objp->dateh), "%Y"); - $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; - $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; - $tot += $objp->subscription; - $numb += 1; - $i++; - } + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); + $year = dol_print_date($db->jdate($objp->dateh), "%Y"); + $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; + $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; + $tot += $objp->subscription; + $numb += 1; + $i++; + } } print '
'; @@ -258,12 +258,12 @@ foreach ($Total as $key=>$value) { break; } print ''; - print "$key"; - print "".$Number[$key].""; - print "".price($value).""; - print "".price(price2num($value / $Number[$key], 'MT')).""; - print "\n"; - $i++; + print "$key"; + print "".$Number[$key].""; + print "".price($value).""; + print "".price(price2num($value / $Number[$key], 'MT')).""; + print "\n"; + $i++; } // Total diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 14d886b6cc4..6be535b6e3b 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -38,7 +38,7 @@ $action = GETPOST('action', 'aZ09'); // Protection $socid = 0; if ($user->socid > 0) { - $socid = $user->socid; + $socid = $user->socid; } $object = new Adherent($db); @@ -165,24 +165,24 @@ if ($result > 0) { $search = "(".$object->_load_ldap_dn($info, 2).")"; if (empty($dn)) { - $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; + $langs->load("errors"); + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; } else { - $records = $ldap->getAttribute($dn, $search); + $records = $ldap->getAttribute($dn, $search); - //print_r($records); + //print_r($records); - // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (!is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; - } else { - $result = show_ldap_content($records, 0, $records['count'], true); - } - } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; - } - } + // Show tree + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { + print ''.$langs->trans("ErrorFailedToReadLDAP").''; + } else { + $result = show_ldap_content($records, 0, $records['count'], true); + } + } else { + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + } + } $ldap->unbind(); $ldap->close(); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 05100582ec2..c9aaa856d22 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -204,30 +204,30 @@ if (empty($reshook)) { // Close if ($massaction == 'close' && $user->rights->adherent->creer) { - $tmpmember = new Adherent($db); - $error = 0; - $nbclose = 0; + $tmpmember = new Adherent($db); + $error = 0; + $nbclose = 0; - $db->begin(); + $db->begin(); - foreach ($toselect as $idtoclose) { - $tmpmember->fetch($idtoclose); - $result = $tmpmember->resiliate($user); + foreach ($toselect as $idtoclose) { + $tmpmember->fetch($idtoclose); + $result = $tmpmember->resiliate($user); - if ($result < 0 && !count($tmpmember->errors)) { - setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); - } else { - if ($result > 0) $nbclose++; - } - } + if ($result < 0 && !count($tmpmember->errors)) { + setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); + } else { + if ($result > 0) $nbclose++; + } + } - if (!$error) { - setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); + if (!$error) { + setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + $db->commit(); + } else { + $db->rollback(); + } } // Mass actions @@ -409,7 +409,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($user->rights->adherent->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } print '
'; @@ -560,7 +560,7 @@ if (!empty($arrayfields['d.email']['checked'])) { // End of subscription date if (!empty($arrayfields['d.datefin']['checked'])) { print ''; - $selectarray=array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); + $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); print $form->selectarray('search_filter', $selectarray, $search_filter); print ''; } diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 1ce2da4751b..e611eb3bbcf 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -40,8 +40,8 @@ $result = restrictedArea($user, 'adherent', $id); $object = new Adherent($db); $result = $object->fetch($id); if ($result > 0) { - $adht = new AdherentType($db); - $result = $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $result = $adht->fetch($object->typeid); } $permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php @@ -75,44 +75,44 @@ if ($id) { dol_banner_tab($object, 'id', $linkback); - print '
'; + print '
'; - print '
'; + print '
'; print ''; - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; - } + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } - // Type - print '\n"; + // Type + print '\n"; - // Morphy - print ''; - /*print ''; + /*print '';*/ - print ''; + print ''; - // Company - print ''; + // Company + print ''; - // Civility - print ''; - print ''; + // Civility + print ''; + print ''; - print "
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; + // Morphy + print '
'.$langs->trans("MemberNature").''.$object->getmorphylib().''; print $form->showphoto('memberphoto',$member); print '
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("Company").''.$object->company.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
"; + print ""; - print '
'; + print '
'; - $cssclass = 'titlefield'; - $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + $cssclass = 'titlefield'; + $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index cd0f90d27c6..73c32c59684 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -34,8 +34,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : ''; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -69,7 +69,7 @@ $sql .= " d.morphy as code"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut != -1"; // Not draft +$sql .= " AND d.statut != -1"; // Not draft $sql .= " GROUP BY d.morphy"; $foundphy = $foundmor = 0; @@ -100,7 +100,7 @@ $sql .= " d.morphy as code"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; -$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0) +$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0) $sql .= " GROUP BY d.morphy"; $foundphy = $foundmor = 0; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 7d05678263a..c24cf1fdef4 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -35,8 +35,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : ''; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -68,129 +68,129 @@ print load_fiche_titre($title, '', 'object_group'); dol_mkdir($dir); if ($mode) { - // Define sql - if ($mode == 'memberbycountry') { - $label = $langs->trans("Country"); - $tab = 'statscountry'; + // Define sql + if ($mode == 'memberbycountry') { + $label = $langs->trans("Country"); + $tab = 'statscountry'; - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY c.label, c.code"; - //print $sql; - } + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY c.label, c.code"; + //print $sql; + } if ($mode == 'memberbystate') { - $label = $langs->trans("Country"); - $label2 = $langs->trans("State"); - $tab = 'statsstate'; - - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY co.label, co.code, c.nom"; - //print $sql; - } - if ($mode == 'memberbyregion') { // $label = $langs->trans("Country"); - $label2 = $langs->trans("Region"); //département - $tab = 'statsregion'; //onglet + $label2 = $langs->trans("State"); + $tab = 'statsstate'; - $data = array(); //tableau de donnée - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY co.label, co.code, r.nom"; //+ - //print $sql; - } - if ($mode == 'memberbytown') { - $label = $langs->trans("Country"); - $label2 = $langs->trans("Town"); - $tab = 'statstown'; + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY co.label, co.code, c.nom"; + //print $sql; + } + if ($mode == 'memberbyregion') { // + $label = $langs->trans("Country"); + $label2 = $langs->trans("Region"); //département + $tab = 'statsregion'; //onglet - $data = array(); - $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; - $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; - $sql .= " AND d.statut != -1"; - $sql .= " GROUP BY c.label, c.code, d.town"; - //print $sql; - } + $data = array(); //tableau de donnée + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY co.label, co.code, r.nom"; //+ + //print $sql; + } + if ($mode == 'memberbytown') { + $label = $langs->trans("Country"); + $label2 = $langs->trans("Town"); + $tab = 'statstown'; - $langsen = new Translate('', $conf); - $langsen->setDefaultLang('en_US'); - $langsen->load("dict"); - //print $langsen->trans("Country"."FI");exit; + $data = array(); + $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; + $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql .= " AND d.statut != -1"; + $sql .= " GROUP BY c.label, c.code, d.town"; + //print $sql; + } - // Define $data array - dol_syslog("Count member", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($mode == 'memberbycountry') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + $langsen = new Translate('', $conf); + $langsen->setDefaultLang('en_US'); + $langsen->load("dict"); + //print $langsen->trans("Country"."FI");exit; + + // Define $data array + dol_syslog("Count member", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($mode == 'memberbycountry') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), 'code'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbyregion') { //+ + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbyregion') { //+ $data[] = array( - 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbystate') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbystate') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } - if ($mode == 'memberbytown') { - $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), - 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate), - 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) - ); - } + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } + if ($mode == 'memberbytown') { + $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), + 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), + 'nb'=>$obj->nb, + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) + ); + } - $i++; - } - $db->free($resql); - } else { - dol_print_error($db); - } + $i++; + } + $db->free($resql); + } else { + dol_print_error($db); + } } @@ -201,101 +201,101 @@ print dol_get_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user'); // Print title if ($mode && !count($data)) { - print $langs->trans("NoValidatedMemberYet").'
'; - print '
'; + print $langs->trans("NoValidatedMemberYet").'
'; + print '
'; } else { - if ($mode == 'memberbycountry') print ''.$langs->trans("MembersByCountryDesc").'
'; - elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; - elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; - elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ - else { - print ''.$langs->trans("MembersStatisticsDesc").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByCountries").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByState").'
'; - print '
'; - print ''.$langs->trans("MembersStatisticsByTown").'
'; - print '
'; //+ + if ($mode == 'memberbycountry') print ''.$langs->trans("MembersByCountryDesc").'
'; + elseif ($mode == 'memberbystate') print ''.$langs->trans("MembersByStateDesc").'
'; + elseif ($mode == 'memberbytown') print ''.$langs->trans("MembersByTownDesc").'
'; + elseif ($mode == 'memberbyregion') print ''.$langs->trans("MembersByRegion").'
'; //+ + else { + print ''.$langs->trans("MembersStatisticsDesc").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByCountries").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByState").'
'; + print '
'; + print ''.$langs->trans("MembersStatisticsByTown").'
'; + print '
'; //+ print ''.$langs->trans("MembersStatisticsByRegion").'
'; //+ - } - print '
'; + } + print '
'; } // Show graphics if (count($arrayjs) && $mode == 'memberbycountry') { - $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - if (is_readable($color_file)) include_once $color_file; + $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + if (is_readable($color_file)) include_once $color_file; - // Assume we've already included the proper headers so just call our script inline - // More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR - print "\n\n"; + print "\tvar options = {};\n"; + print "\toptions['dataMode'] = 'regions';\n"; + print "\toptions['showZoomOut'] = false;\n"; + //print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n"; + print "\toptions['width'] = ".$graphwidth.";\n"; + print "\toptions['height'] = ".$graphheight.";\n"; + print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1], 'BBBBBB').", 0x".colorArrayToHex($theme_datacolor[0], '444444')."];\n"; + print "\tvar container = document.getElementById('".$mode."');\n"; + print "\tvar geomap = new google.visualization.GeoMap(container);\n"; + print "\tgeomap.draw(data, options);\n"; + print "};\n"; + print "\n"; - // print the div tag that will contain the map - print '
'."\n"; - print '
'; + // print the div tag that will contain the map + print '
'."\n"; + print '
'; } if ($mode) { - // Print array + // Print array print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; - print ''; - print ''; - if ($label2) print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + if ($label2) print ''; + print ''; + print ''; + print ''; + print ''; - foreach ($data as $val) { - $year = $val['year']; - print ''; - print ''; - if ($label2) print ''; - print ''; - print ''; - print ''; - print ''; - } + foreach ($data as $val) { + $year = $val['year']; + print ''; + print ''; + if ($label2) print ''; + print ''; + print ''; + print ''; + print ''; + } - print '
'.$label.''.$label2.''.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')'.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$label.''.$label2.''.$langs->trans("NbOfMembers").' ('.$langs->trans("AllTime").')'.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$val['label'].''.$val['label2'].''.$val['nb'].''.dol_print_date($val['lastdate'], 'dayhour').''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'.$val['label'].''.$val['label2'].''.$val['nb'].''.dol_print_date($val['lastdate'], 'dayhour').''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'; - print '
'; + print ''; + print '
'; } diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 472a93cfce7..6ac4e3dd78a 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -36,8 +36,8 @@ $socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'adherent', '', '', 'cotisation'); @@ -79,24 +79,24 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscripti $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { - $px1->SetData($data); - $i = $startyear; - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfSubscriptions")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NbOfSubscriptions")); + $px1->SetData($data); + $i = $startyear; + while ($i <= $endyear) { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfSubscriptions")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NbOfSubscriptions")); - $px1->draw($filenamenb, $fileurlnb); + $px1->draw($filenamenb, $fileurlnb); } // Build graphic amount of object @@ -110,24 +110,24 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscr $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { - $px2->SetData($data); - $i = $startyear; - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfSubscriptions")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfSubscriptions")); + $px2->SetData($data); + $i = $startyear; + while ($i <= $endyear) { + $legend[] = $i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfSubscriptions")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode = 'depth'; + $px2->SetTitle($langs->trans("AmountOfSubscriptions")); - $px2->draw($filenameamount, $fileurlamount); + $px2->draw($filenameamount, $fileurlamount); } @@ -171,31 +171,31 @@ print ''; $oldyear = 0; foreach ($data as $val) { - $year = $val['year']; - while ($oldyear > $year + 1) { // If we have empty year - $oldyear--; - print ''; - print ''; - //print ''; - print $oldyear; - //print ''; - print ''; - print '0'; - print '0'; - print '0'; - print ''; - } - print ''; - print ''; - //print ''; - print $year; - //print ''; - print ''; - print ''.$val['nb'].''; - print ''.price(price2num($val['total'], 'MT'), 1).''; - print ''.price(price2num($val['avg'], 'MT'), 1).''; - print ''; - $oldyear = $year; + $year = $val['year']; + while ($oldyear > $year + 1) { // If we have empty year + $oldyear--; + print ''; + print ''; + //print ''; + print $oldyear; + //print ''; + print ''; + print '0'; + print '0'; + print '0'; + print ''; + } + print ''; + print ''; + //print ''; + print $year; + //print ''; + print ''; + print ''.$val['nb'].''; + print ''.price(price2num($val['total'], 'MT'), 1).''; + print ''.price(price2num($val['avg'], 'MT'), 1).''; + print ''; + $oldyear = $year; } print ''; @@ -208,9 +208,9 @@ print '
'; // Show graphs print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); - print "
\n"; - print $px2->show(); + print $px1->show(); + print "
\n"; + print $px2->show(); } print '
'; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index ca88854d27e..748ac19814c 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -550,100 +550,100 @@ if ($rowid > 0) { } print ''; - print "\n"; + print "\n"; print "
\n"; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print ''; + print ''; - /* + /* * Action buttons */ - // Button to create a new subscription if member no draft neither resiliated - if ($user->rights->adherent->cotisation->creer) { - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - print '
'; + // Button to create a new subscription if member no draft neither resiliated + if ($user->rights->adherent->cotisation->creer) { + if ($action != 'addsubscription' && $action != 'create_thirdparty') { + print '
'; - if ($object->statut > 0) print '"; - else print ''; + if ($object->statut > 0) print '"; + else print ''; - print '
'; - } - } + print '
'; + } + } - /* + /* * List of subscriptions */ - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; - $sql .= " c.rowid as crowid, c.subscription,"; - $sql .= " c.datec, c.fk_type as cfk_type,"; - $sql .= " c.dateadh as dateh,"; - $sql .= " c.datef,"; - $sql .= " c.fk_bank,"; - $sql .= " b.rowid as bid,"; - $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; + if ($action != 'addsubscription' && $action != 'create_thirdparty') { + $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; + $sql .= " c.rowid as crowid, c.subscription,"; + $sql .= " c.datec, c.fk_type as cfk_type,"; + $sql .= " c.dateadh as dateh,"; + $sql .= " c.datef,"; + $sql .= " c.fk_bank,"; + $sql .= " b.rowid as bid,"; + $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; $sql .= $db->order($sortfield, $sortorder); - $result = $db->query($sql); - if ($result) { - $subscriptionstatic = new Subscription($db); + $result = $db->query($sql); + if ($result) { + $subscriptionstatic = new Subscription($db); - $num = $db->num_rows($result); + $num = $db->num_rows($result); - print ''."\n"; + print '
'."\n"; - print ''; - print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->banque->enabled)) { - print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - } - print "\n"; + print ''; + print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($conf->banque->enabled)) { + print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + print "\n"; - $accountstatic = new Account($db); - $adh = new Adherent($db); - $adht = new AdherentType($db); + $accountstatic = new Account($db); + $adh = new Adherent($db); + $adht = new AdherentType($db); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); - $adh->id = $objp->rowid; - $adh->typeid = $objp->type; + $adh->id = $objp->rowid; + $adh->typeid = $objp->type; - $subscriptionstatic->ref = $objp->crowid; - $subscriptionstatic->id = $objp->crowid; + $subscriptionstatic->ref = $objp->crowid; + $subscriptionstatic->id = $objp->crowid; - $typeid = $objp->cfk_type; - if ($typeid > 0) { - $adht->fetch($typeid); - } + $typeid = $objp->cfk_type; + if ($typeid > 0) { + $adht->fetch($typeid); + } - print ''; - print ''; - print '\n"; - print ''; - print '\n"; - print '\n"; - print ''; + print ''; + print ''; + print '\n"; + print ''; + print '\n"; + print '\n"; + print ''; if (!empty($conf->banque->enabled)) { print ''; + print '
'; + } + print ''; - // Bank account - print '\n"; + // Bank account + print '\n"; - // Payment mode - print '\n"; + // Payment mode + print '\n"; - // Date of payment - print '\n"; + // Date of payment + print '\n"; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; - } - } + print ''; + print ''; + } + } - print ''; + print ''; - print ''; - print ''; + print ''; - print ''; - print '
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).'
'.$subscriptionstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec), 'dayhour')."'; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''.dol_print_date($db->jdate($objp->dateh), 'day')."'.dol_print_date($db->jdate($objp->datef), 'day')."'.price($objp->subscription).''; if ($objp->bid) { @@ -921,123 +921,123 @@ if ($rowid > 0) { } print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } - print '
'; - } - print '
'.$langs->trans("FinancialAccount").''; - $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); - print "
'.$langs->trans("FinancialAccount").''; + $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); + print "
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); - print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); + print "
'.$langs->trans("DatePayment").''; - print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); - print "
'.$langs->trans("DatePayment").''; + print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); + print "
'.$langs->trans('Numero'); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans('CheckTransmitter'); - print ' ('.$langs->trans("ChequeMaker").')'; - print '
'.$langs->trans('CheckTransmitter'); + print ' ('.$langs->trans("ChequeMaker").')'; + print '
'.$langs->trans('Bank'); - print ' ('.$langs->trans("ChequeBank").')'; - print '
'.$langs->trans('Bank'); + print ' ('.$langs->trans("ChequeBank").')'; + print '
'.$langs->trans("SendAcknowledgementByMail").''; - if (!$object->email) { - print $langs->trans("NoEMail"); - } else { - $adht = new AdherentType($db); - $adht->fetch($object->typeid); + print '
'.$langs->trans("SendAcknowledgementByMail").''; + if (!$object->email) { + print $langs->trans("NoEMail"); + } else { + $adht = new AdherentType($db); + $adht->fetch($object->typeid); - // Send subscription email - $subject = ''; - $msg = ''; + // Send subscription email + $subject = ''; + $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); - $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; - $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; - $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; - $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; - if ($subjecttosend) { - $helpcontent .= $subjecttosend."\n"; - } else { - $langs->load("errors"); - $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; - } - $helpcontent .= "
"; - $helpcontent .= ''.$langs->trans("MailText").':
'; - if ($texttosend) { - $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; - } else { - $langs->load("errors"); - $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; - } - print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); - } - print '
'; + $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; + $helpcontent = ''; + $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; + if ($subjecttosend) { + $helpcontent .= $subjecttosend."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } + $helpcontent .= "
"; + $helpcontent .= ''.$langs->trans("MailText").':
'; + if ($texttosend) { + $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } + print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); + } + print ''; + print ''; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; - print ''; + print ''; - print "\n\n\n"; - } + print "\n\n\n"; + } - //print ''; - //print ''; + //print ''; + //print ''; } else { - $langs->load("errors"); - print $langs->trans("ErrorRecordNotFound"); + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); } // End of page diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 9b5efa214b9..92e495ad93b 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -110,22 +110,22 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_type = ""; - $search_ref = ""; - $search_lastname = ""; - $search_firstname = ""; - $search_login = ""; - $search_note = ""; - $search_amount = ""; - $search_account = ""; - $toselect = ''; - $search_array_options = array(); - } + $search_ref = ""; + $search_lastname = ""; + $search_firstname = ""; + $search_login = ""; + $search_note = ""; + $search_amount = ""; + $search_account = ""; + $toselect = ''; + $search_array_options = array(); + } } @@ -153,8 +153,8 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = e $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")"; if (isset($date_select) && $date_select != '') { - $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'"; - $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'"; + $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'"; + $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'"; } if ($search_ref) { if (is_numeric($search_ref)) $sql .= " AND (c.rowid = ".$db->escape($search_ref).")"; @@ -181,13 +181,13 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - if ($resql) $nbtotalofrecords = $db->num_rows($resql); - else dol_print_error($db); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $resql = $db->query($sql); + if ($resql) $nbtotalofrecords = $db->num_rows($resql); + else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; - $offset = 0; - } + $offset = 0; + } } // Add limit $sql .= $db->plimit($limit + 1, $offset); @@ -241,7 +241,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($user->rights->adherent->cotisation->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); } print '
'; @@ -409,8 +409,8 @@ while ($i < min($num, $limit)) { $adherent->typeid = $obj->type; $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid); - $adht = new AdherentType($db); - $adht->fetch($typeid); + $adht = new AdherentType($db); + $adht->fetch($typeid); print ''; @@ -419,14 +419,14 @@ while ($i < min($num, $limit)) { print ''.$subscription->getNomUrl(1).''; if (!$i) $totalarray['nbfield']++; } - // Type - if (!empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''; - if (!$i) $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['d.fk_type']['checked'])) { + print ''; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''; + if (!$i) $totalarray['nbfield']++; } // Lastname diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 136c1dab8f4..0414bf20a14 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -33,12 +33,12 @@ $langs->load("members"); $total = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - echo ''; - echo ''.$langs->trans("Subscription").''; - echo ''.$objectlink->getNomUrl(1).''; - echo ''; - echo ''.dol_print_date($objectlink->dateh, 'day').''; - echo ''; + echo ''; + echo ''.$langs->trans("Subscription").''; + echo ''.$objectlink->getNomUrl(1).''; + echo ''; + echo ''.dol_print_date($objectlink->dateh, 'day').''; + echo ''; if ($user->rights->adherent->lire) { $total = $total + $objectlink->amount; echo price($objectlink->amount); @@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''; echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; - echo ''; + echo ''; } echo "\n"; diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index d8deebba9ba..1d37f337a78 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -123,7 +123,7 @@ print dol_get_fiche_end(); print '
'; if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { - print ''.$langs->trans("ForceSynchronize").''; + print ''.$langs->trans("ForceSynchronize").''; } print "
\n"; @@ -146,27 +146,27 @@ print ''; $ldap = new Ldap(); $result = $ldap->connect_bind(); if ($result > 0) { - $info = $object->_load_ldap_info(); - $dn = $object->_load_ldap_dn($info, 1); - $search = "(".$object->_load_ldap_dn($info, 2).")"; + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info, 1); + $search = "(".$object->_load_ldap_dn($info, 2).")"; - $records = $ldap->getAttribute($dn, $search); + $records = $ldap->getAttribute($dn, $search); - //print_r($records); + //print_r($records); - // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (!is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; - } else { - $result = show_ldap_content($records, 0, $records['count'], true); - } - } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; - } + // Show tree + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { + if (!is_array($records)) { + print ''.$langs->trans("ErrorFailedToReadLDAP").''; + } else { + $result = show_ldap_content($records, 0, $records['count'], true); + } + } else { + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + } - $ldap->unbind(); - $ldap->close(); + $ldap->unbind(); + $ldap->close(); } else { setEventMessages($ldap->error, $ldap->errors, 'errors'); } diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 6cf349270e8..3aafef6f216 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -154,9 +154,9 @@ $titre = $langs->trans("MemberType".$object->type); // Calculate $cnt_trans $cnt_trans = 0; if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { - $cnt_trans++; - } + foreach ($object->multilangs as $key => $value) { + $cnt_trans++; + } } @@ -179,10 +179,10 @@ print dol_get_fiche_end(); print "\n
\n"; if ($action == '') { - if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''.$langs->trans("Add").''; - if ($cnt_trans > 0) print ''.$langs->trans("Update").''; - } + if ($user->rights->produit->creer || $user->rights->service->creer) { + print ''.$langs->trans("Add").''; + if ($cnt_trans > 0) print ''.$langs->trans("Update").''; + } } print "\n
\n"; @@ -262,7 +262,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { print ''; print ''; print ''; print '\n"; + } + } + closedir($handle); + } + } + } + print '
'.$langs->trans('Language').''; - print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); + print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index 6f2a274aed9..1bf1f5c01ce 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -66,7 +66,7 @@ $v->setPhoneNumber($adherent->phone_pro, "TYPE=WORK;VOICE"); $v->setPhoneNumber($adherent->phone_mobile, "TYPE=CELL;VOICE"); $v->setPhoneNumber($adherent->fax, "TYPE=WORK;FAX"); -$country = $adherent->country_code ? $adherent->country : '' ; +$country = $adherent->country_code ? $adherent->country : ''; $v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK;POSTAL"); $v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK"); @@ -79,9 +79,9 @@ $v->setTitle($adherent->poste); if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (! $adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (! $adherent->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (! $adherent->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + if (!$adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + if (!$adherent->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + if (!$adherent->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); // when company e-mail is empty, use only adherent e-mail if (empty(trim($company->email))) @@ -124,7 +124,7 @@ $db->close(); $output = $v->getVCard(); -$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" +$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); //$filename = dol_sanitizeFileName($filename); diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 0cd9dd52648..1f4236df666 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda')); @@ -86,9 +86,9 @@ if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') | if ($action == "save" && empty($cancel)) { - $i = 0; + $i = 0; - $db->begin(); + $db->begin(); foreach ($triggers as $trigger) { @@ -102,13 +102,13 @@ if ($action == "save" && empty($cancel)) } if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - $db->commit(); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - $db->rollback(); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + $db->commit(); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + $db->rollback(); + } } diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 0c46e84dff6..36c7bc3edf8 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -84,9 +84,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index c743ed06e55..3cf0d49b960 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -54,9 +54,9 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', ' if ($actionsave) { - $db->begin(); + $db->begin(); - $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); + $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); $res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity); $i = 1; $errorsaved = 0; @@ -103,14 +103,14 @@ if ($actionsave) $MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB; } - if (!$error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index a31c4ed1dbe..c390796a55b 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda', 'users')); @@ -80,49 +80,49 @@ if ($action == 'set') $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE'); $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter; dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -135,7 +135,7 @@ elseif ($action == 'setmodel') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); } } @@ -194,115 +194,115 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); + print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - print ''."\n"; + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + print ''."\n"; - clearstatcache(); + clearstatcache(); - foreach ($dirmodels as $reldir) - { - $dir = dol_buildpath($reldir."core/modules/action/doc"); + foreach ($dirmodels as $reldir) + { + $dir = dol_buildpath($reldir."core/modules/action/doc"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db, new ActionComm($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new ActionComm($db)); - print ''."\n"; - print "\n"; - print "\n"; + print ''."\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print '"; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - print ''; - print ''; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + print ''; + print ''; - print "\n"; - } - } - closedir($handle); - } - } - } - print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
"; - print (empty($module->name) ? $name : $module->name); - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) - print $module->info($langs); - else print $module->description; - print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) + print $module->info($langs); + else print $module->description; + print "'."\n"; - if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=action">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - } else { - print img_picto($langs->trans("Enabled"), 'switch_on'); - } - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=action">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + } else { + print img_picto($langs->trans("Enabled"), 'switch_on'); + } + print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; + print "

'; } print ''; @@ -343,13 +343,13 @@ print ''."\n"; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''; - print ''."\n"; - print ''.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").''."\n"; - print ' '."\n"; - print ''."\n"; - $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); - print ''."\n"; + print ''; + print ''."\n"; + print ''.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").''."\n"; + print ' '."\n"; + print ''."\n"; + $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); + print ''."\n"; } // AGENDA_DEFAULT_FILTER_TYPE @@ -359,8 +359,8 @@ print ' '."\n"; print ''."\n"; $multiselect = 0; if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) { - // We use an option here because it adds bugs when used on agenda page "peruser" and "list" - $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); + // We use an option here because it adds bugs when used on agenda page "peruser" and "list" + $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 1, $multiselect); print ''."\n"; diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 51a9d4f327b..e34536e648a 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); @@ -73,49 +73,49 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if ($action == 'set') { dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -128,7 +128,7 @@ elseif ($action == 'setmodel') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); } } @@ -200,31 +200,31 @@ if ($conf->global->MAIN_FEATURES_LEVEL == 2) // AGENDA REMINDER BROWSER if ($conf->global->MAIN_FEATURES_LEVEL == 2) { - print ''."\n"; - print ''.$langs->trans('AGENDA_REMINDER_BROWSER').''."\n"; - print ' '."\n"; - print ''."\n"; + print ''."\n"; + print ''.$langs->trans('AGENDA_REMINDER_BROWSER').''."\n"; + print ' '."\n"; + print ''."\n"; - if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { - print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; - print ''."\n"; - } else { - print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; - print ''."\n"; + if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { + print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; + print ''."\n"; + } else { + print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; + print ''."\n"; - print ''."\n"; - print ''.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').''."\n"; - print ' '."\n"; - print ''."\n"; + print ''."\n"; + print ''.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').''."\n"; + print ' '."\n"; + print ''."\n"; - if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { - print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; - } else { - print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; - } + if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { + print ''.img_picto($langs->trans('Disabled'), 'switch_off').''; + } else { + print ''.img_picto($langs->trans('Enabled'), 'switch_on').''; + } - print ''."\n"; - } + print ''."\n"; + } } print ''; diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index fd80a545aa5..61116a0f18f 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (!$user->admin) - accessforbidden(); + accessforbidden(); // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); @@ -41,23 +41,23 @@ $actionsave = GETPOST('save', 'alpha'); // Sauvegardes parametres if ($actionsave) { - $i = 0; + $i = 0; - $db->begin(); + $db->begin(); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); - $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); + $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); - if ($i >= 4) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($langs->trans("SaveFailed"), null, 'errors'); - } + if ($i >= 4) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("SaveFailed"), null, 'errors'); + } } @@ -163,7 +163,7 @@ $urlvcal .= $urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentit $message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal); $message .= '
'; $urlical = ''; -$urlical .=$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').''; +$urlical .= $urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').''; $message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical); $message .= '
'; $urlrss = ''; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 7ad9e1d0f23..aff2b90d897 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -81,9 +81,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -93,9 +93,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -103,10 +103,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 529e3289a31..0e7a23ae679 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -44,11 +44,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setbarcodeproducton') { - $barcodenumberingmodule = GETPOST('value', 'alpha'); + $barcodenumberingmodule = GETPOST('value', 'alpha'); $res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) { - $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); } } elseif ($action == 'setbarcodeproductoff') { @@ -76,45 +76,45 @@ if ($action == 'setcoder') $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity); if ($res > 0) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'updateengine') { - $sql = "SELECT rowid, coder"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql .= " WHERE entity = ".$conf->entity; - $sql .= " ORDER BY code"; + $sql = "SELECT rowid, coder"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql .= " WHERE entity = ".$conf->entity; + $sql .= " ORDER BY code"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - if (GETPOST('coder'.$obj->rowid, 'alpha')) - { - $coder = GETPOST('coder'.$obj->rowid, 'alpha'); - $code_id = $obj->rowid; + if (GETPOST('coder'.$obj->rowid, 'alpha')) + { + $coder = GETPOST('coder'.$obj->rowid, 'alpha'); + $code_id = $obj->rowid; - $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; - $sqlp .= " SET coder = '".$db->escape($coder)."'"; - $sqlp .= " WHERE rowid = ".((int) $code_id); - $sqlp .= " AND entity = ".$conf->entity; + $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; + $sqlp .= " SET coder = '".$db->escape($coder)."'"; + $sqlp .= " WHERE rowid = ".((int) $code_id); + $sqlp .= " AND entity = ".$conf->entity; - $upsql = $db->query($sqlp); - if (!$upsql) dol_print_error($db); - } + $upsql = $db->query($sqlp); + if (!$upsql) dol_print_error($db); + } - $i++; - } - } + $i++; + } + } } @@ -142,11 +142,11 @@ $dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_pa foreach ($dirbarcode as $reldir) { - $dir = dol_buildpath($reldir); - $newdir = dol_osencode($dir); + $dir = dol_buildpath($reldir); + $newdir = dol_osencode($dir); - // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) - if (!is_dir($newdir)) continue; + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) + if (!is_dir($newdir)) continue; $handle = @opendir($newdir); if (is_resource($handle)) @@ -190,9 +190,9 @@ print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', ''); if (empty($conf->use_javascript_ajax)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } print ''; @@ -236,11 +236,11 @@ if ($resql) foreach ($dirbarcode as $reldir) { - $dir = dol_buildpath($reldir, 0); - $newdir = dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); - // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) - if (!is_dir($newdir)) continue; + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) + if (!is_dir($newdir)) continue; $result = @include_once $newdir.$obj->coder.'.modules.php'; if ($result) break; @@ -254,7 +254,7 @@ if ($resql) if ($module->encodingIsSupported($obj->encoding)) { // Build barcode on disk (not used, this is done to make debug easier) - $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); + $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); // Generate on the fly and output barcode with generator $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); //print $url; @@ -282,8 +282,8 @@ print "
\n"; if (empty($conf->use_javascript_ajax)) { - print '
'; - print '
'; + print '
'; + print ''; } print "
"; @@ -371,48 +371,48 @@ if ($conf->product->enabled) $dir = dol_buildpath($dirroot, 0); $handle = @opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^mod_barcode_product_.*php$/', $file)) - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/^mod_barcode_product_.*php$/', $file)) + { + $file = substr($file, 0, dol_strlen($file) - 4); - try { - dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) - { - dol_syslog($e->getMessage(), LOG_ERR); - } + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } - $modBarCode = new $file(); + $modBarCode = new $file(); - print ''; - print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; - print $modBarCode->info($langs); - print ''; - print ''.$modBarCode->getExample($langs)."\n"; + print ''; + print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; + print $modBarCode->info($langs); + print ''; + print ''.$modBarCode->getExample($langs)."\n"; - if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") - { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - $s = $modBarCode->getToolTip($langs, null, -1); - print $form->textwithpicto('', $s, 1); - print ''; - print "\n"; - } - } - closedir($handle); - } + if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") + { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + $s = $modBarCode->getToolTip($langs, null, -1); + print $form->textwithpicto('', $s, 1); + print ''; + print "\n"; + } + } + closedir($handle); + } } print "\n"; } diff --git a/htdocs/admin/bom_extrafields.php b/htdocs/admin/bom_extrafields.php index 8ae26587ebd..f2022229305 100644 --- a/htdocs/admin/bom_extrafields.php +++ b/htdocs/admin/bom_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -92,9 +92,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -102,10 +102,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 5fa7b78ca8b..566d6b845e8 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -33,7 +33,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'aZ09'); -if (! in_array('clicktodial', $conf->modules)) { +if (!in_array('clicktodial', $conf->modules)) { accessforbidden($langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name"))); } @@ -44,15 +44,15 @@ if (! in_array('clicktodial', $conf->modules)) { if ($action == 'setvalue' && $user->admin) { - $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); - $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); + $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); + $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); - if ($result1 >= 0 && $result2 >= 0) - { + if ($result1 >= 0 && $result2 >= 0) + { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -125,7 +125,7 @@ if (!empty($conf->global->CLICKTODIAL_URL)) if (GETPOST('phonefortest')) $phonefortest = GETPOST('phonefortest'); print '
'; - print ''; + print ''; print $langs->trans("LinkToTestClickToDial", $user->login).' : '; print ''; print ''; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index faf38f44b16..a647d096037 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -40,14 +40,14 @@ $action = GETPOST('action', 'aZ09'); // Other parameters ACCOUNTING_* $list = array( - 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', - 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', - 'ACCOUNTING_SERVICE_BUY_ACCOUNT', - 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_BUY_ACCOUNT', - 'ACCOUNTING_ACCOUNT_CUSTOMER', - 'ACCOUNTING_ACCOUNT_SUPPLIER' + 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', + 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', + 'ACCOUNTING_SERVICE_BUY_ACCOUNT', + 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_BUY_ACCOUNT', + 'ACCOUNTING_ACCOUNT_CUSTOMER', + 'ACCOUNTING_ACCOUNT_SUPPLIER' ); /* @@ -58,52 +58,52 @@ $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : if ($action == 'update') { - $error = 0; + $error = 0; - $accounting_modes = array( - 'RECETTES-DEPENSES', - 'CREANCES-DETTES' - ); + $accounting_modes = array( + 'RECETTES-DEPENSES', + 'CREANCES-DETTES' + ); - $accounting_mode = GETPOST('accounting_mode', 'alpha'); + $accounting_mode = GETPOST('accounting_mode', 'alpha'); - if (in_array($accounting_mode, $accounting_modes)) { - if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } else { - $error++; - } + if (in_array($accounting_mode, $accounting_modes)) { + if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } else { + $error++; + } - foreach ($list as $constname) { - $constvalue = GETPOST($constname, 'alpha'); + foreach ($list 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++; + } + } - $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha'); - if (!empty($report_include_varpay)) - if ($report_include_varpay == 'yes') - if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++; - if ($report_include_varpay == 'no') - if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++; + $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha'); + if (!empty($report_include_varpay)) + if ($report_include_varpay == 'yes') + if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++; + if ($report_include_varpay == 'no') + if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++; - $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha'); - if (!empty($report_include_loan)) - if ($report_include_loan == 'yes') - if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++; - if ($report_include_loan == 'no') - if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++; + $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha'); + if (!empty($report_include_loan)) + if ($report_include_loan == 'yes') + if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++; + if ($report_include_loan == 'no') + if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 4aacdb3cfc2..baf5fae0b34 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -155,7 +155,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp); // Add logic to show/hide buttons if ($conf->use_javascript_ajax) { - ?> + ?> '; - form_constantes($constantes, 2); + form_constantes($constantes, 2); - print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; - print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; + print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; + print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; + print '
'; - print '
'; + print ''; } else { - print dol_get_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user'); + print dol_get_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user'); - $link = ''; - //$link.=img_$langs->trans("Activate") - $link .= img_picto($langs->trans("Disabled"), 'switch_off'); - $link .= ''; - print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); + $link = ''; + //$link.=img_$langs->trans("Activate") + $link .= img_picto($langs->trans("Disabled"), 'switch_off'); + $link .= ''; + print load_fiche_titre($langs->trans('MailmanTitle'), $link, ''); - print dol_get_fiche_end(); + print dol_get_fiche_end(); } if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print $langs->trans("TestSubscribe").'
'; - print $langs->trans("EMail").'
'; + print $langs->trans("TestSubscribe").'
'; + print $langs->trans("EMail").'
'; - print '
'; + print ''; - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print $langs->trans("TestUnSubscribe").'
'; - print $langs->trans("EMail").'
'; + print $langs->trans("TestUnSubscribe").'
'; + print $langs->trans("EMail").'
'; - print '
'; + print ''; } // End of page diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index cc81c78255d..87796f43997 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -67,18 +67,18 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && !$cancel) { - if (! $error && ! GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) { + if (!$error && !GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MAIN_MAIL_EMAIL_FROM")), null, 'errors'); $action = 'edit'; } - if (! $error && ! isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) { + if (!$error && !isValidEmail(GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'))) { $error++; setEventMessages($langs->trans("ErrorBadEMail", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml')), null, 'errors'); $action = 'edit'; } - if (! $error) { + if (!$error) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity); @@ -188,13 +188,13 @@ if ($action == 'edit') jQuery("#smtp_server_mess").show(); jQuery("#smtp_port_mess").show();'; } else { - print ' + print ' jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true); jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide();'; - } - print ' + } + print ' } if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\') { @@ -266,7 +266,7 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").val(0); }); })'; - print ''."\n"; + print ''."\n"; } print '
'; @@ -409,8 +409,8 @@ if ($action == 'edit') print ''; } - // TLS - print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; + // TLS + print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { if (function_exists('openssl_open')) @@ -453,20 +453,20 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - // DKIM Domain - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print ''; + // DKIM Domain + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; + print ''; - // DKIM Selector - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print ''; + // DKIM Selector + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; + print ''; - // DKIM PRIVATE KEY - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print ''; - print ''; + // DKIM PRIVATE KEY + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; + print ''; + print ''; print ''; @@ -635,20 +635,20 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - // Domain - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; - print ''; + // Domain + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; + print ''; - // Selector - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; - print ''; + // Selector + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; + print ''; - // PRIVATE KEY - print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; - print ''; + // PRIVATE KEY + print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; + print ''; } print ''; diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index a464c0fca8e..6a42e14bff6 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -60,7 +60,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - // Send mode parameters + // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"), 'chaine', 0, '', $conf->entity); @@ -382,22 +382,22 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - print ''; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print '
'; } else { - print dol_get_fiche_head($head, 'common_emailing', '', -1); + print dol_get_fiche_head($head, 'common_emailing', '', -1); - print ''.$langs->trans("EMailsDesc")."
\n"; - print "
\n"; + print ''.$langs->trans("EMailsDesc")."
\n"; + print "
\n"; print ''; print ''; @@ -478,10 +478,10 @@ if ($action == 'edit') print dol_get_fiche_end(); - if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) - { - print '
'; - /* + if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + print '
'; + /* // Warning 1 if ($linuxlike) { @@ -491,12 +491,12 @@ if ($action == 'edit') print info_admin($langs->trans("SendmailOptionNotComplete")); } }*/ - // Warning 2 - print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); - } + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } - // Buttons for actions + // Buttons for actions print '
'; @@ -527,8 +527,8 @@ if ($action == 'edit') if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) { - $text = $langs->trans("WarningPHPMail"); - print info_admin($text); + $text = $langs->trans("WarningPHPMail"); + print info_admin($text); } // Run the test to connect @@ -556,7 +556,7 @@ if ($action == 'edit') // Show email send test form if ($action == 'test' || $action == 'testhtml') { - print '
'; + print '
'; print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); print dol_get_fiche_head(''); @@ -592,7 +592,7 @@ if ($action == 'edit') $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode") == 'init') + if (GETPOST("mode") == 'init') { $formmail->clear_attached_files(); } diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 8cbd9675160..c7a86766a32 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -274,7 +274,7 @@ if (empty($reshook)) if (GETPOST($keycode) == '' && $keycode != 'langcode') $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work elseif ($keycode == 'fk_user') { - if (! $user->admin) { // A non admin user can only edit its own template + if (!$user->admin) { // A non admin user can only edit its own template $sql .= " ".((int) $user->id); } else { $sql .= " ".((int) GETPOST($keycode, 'fk_user')); @@ -333,7 +333,7 @@ if (empty($reshook)) if (GETPOST($keycode) == '' || ($keycode != 'langcode' && $keycode != 'position' && $keycode != 'private' && !GETPOST($keycode))) $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work elseif ($keycode == 'fk_user') { - if (! $user->admin) { // A non admin user can only edit its own template + if (!$user->admin) { // A non admin user can only edit its own template $sql .= " ".((int) $user->id); } else { $sql .= " ".((int) GETPOST($keycode, 'fk_user')); @@ -350,7 +350,7 @@ if (empty($reshook)) } $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); - if (! $user->admin) { // A non admin user can only edit its own template + if (!$user->admin) { // A non admin user can only edit its own template $sql .= " AND fk_user = ".$user->id; } //print $sql;exit; @@ -371,7 +371,7 @@ if (empty($reshook)) $rowidcol = "rowid"; $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."=".((int) $rowid); - if (! $user->admin) { // A non admin user can only edit its own template + if (!$user->admin) { // A non admin user can only edit its own template $sql .= " AND fk_user = ".$user->id; } dol_syslog("delete", LOG_DEBUG); @@ -493,7 +493,7 @@ if ($action == 'view') { if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); $align="center"; } + if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); $align = "center"; } if ($fieldlist[$field] == 'private') { $align = 'center'; } if ($fieldlist[$field] == 'position') { $align = 'center'; } @@ -795,13 +795,13 @@ if ($resql) print "\n"; } else { - if ($obj->module) { - $tempmodulekey = $obj->module; - if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { - $i++; - continue; - } - } + if ($obj->module) { + $tempmodulekey = $obj->module; + if (empty($conf->$tempmodulekey) || empty($conf->$tempmodulekey->enabled)) { + $i++; + continue; + } + } $keyforobj = 'type_template'; if (!in_array($obj->$keyforobj, array_keys($elementList))) { diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index e0a42ee3a2d..dda9d0c01a8 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -60,7 +60,7 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - // Send mode parameters + // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_TICKET", GETPOST("MAIN_MAIL_SENDMODE_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity); @@ -359,22 +359,22 @@ if ($action == 'edit') } else print yn(0).' ('.$langs->trans("NotSupported").')'; print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } else { - print dol_get_fiche_head($head, 'common_ticket', '', -1); + print dol_get_fiche_head($head, 'common_ticket', '', -1); - print ''.$langs->trans("EMailsDesc")."
\n"; - print "
\n"; + print ''.$langs->trans("EMailsDesc")."
\n"; + print "
\n"; print ''; print ''; @@ -444,10 +444,10 @@ if ($action == 'edit') print dol_get_fiche_end(); - if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) - { - print '
'; - /* + if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)) + { + print '
'; + /* // Warning 1 if ($linuxlike) { @@ -457,12 +457,12 @@ if ($action == 'edit') print info_admin($langs->trans("SendmailOptionNotComplete")); } }*/ - // Warning 2 - print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); - } + // Warning 2 + print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); + } - // Buttons for actions + // Buttons for actions print '
'; @@ -493,8 +493,8 @@ if ($action == 'edit') if ($conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail' && !in_array($action, array('testconnect', 'test', 'testhtml'))) { - $text = $langs->trans("WarningPHPMail"); - print info_admin($text); + $text = $langs->trans("WarningPHPMail"); + print info_admin($text); } // Run the test to connect @@ -522,7 +522,7 @@ if ($action == 'edit') // Show email send test form if ($action == 'test' || $action == 'testhtml') { - print '
'; + print '
'; print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); print dol_get_fiche_head(''); @@ -558,7 +558,7 @@ if ($action == 'edit') $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode") == 'init') + if (GETPOST("mode") == 'init') { $formmail->clear_attached_files(); } diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index f81a80794d3..f55a2a74874 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -38,8 +38,8 @@ $dirsmartphone = array(); $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'); @@ -244,13 +244,13 @@ if ($action == 'delete') $result = $db->query($sql); $obj = $db->fetch_object($result); - print $form->formconfirm("index.php?menu_handler=".$menu_handler."&menuId=".GETPOST('menuId', 'int'), $langs->trans("DeleteMenu"), $langs->trans("ConfirmDeleteMenu", $obj->title), "confirm_delete"); + print $form->formconfirm("index.php?menu_handler=".$menu_handler."&menuId=".GETPOST('menuId', 'int'), $langs->trans("DeleteMenu"), $langs->trans("ConfirmDeleteMenu", $obj->title), "confirm_delete"); } $newcardbutton = ''; if ($user->admin) { - $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF'])); + $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&action=create&menu_handler='.urlencode($menu_handler).'&backtopage='.urlencode($_SERVER['PHP_SELF'])); } print '
'; @@ -297,7 +297,7 @@ if ($conf->use_javascript_ajax) //il faut d'abord declarer un element racine de l'arbre - $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); + $data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); //puis tous les elements enfants @@ -337,16 +337,16 @@ if ($conf->use_javascript_ajax) $data[] = array( 'rowid'=>$menu['rowid'], - 'module'=>$menu['module'], + 'module'=>$menu['module'], 'fk_menu'=>$menu['fk_menu'], 'title'=>$titre, - 'mainmenu'=>$menu['mainmenu'], + 'mainmenu'=>$menu['mainmenu'], 'leftmenu'=>$menu['leftmenu'], 'fk_mainmenu'=>$menu['fk_mainmenu'], 'fk_leftmenu'=>$menu['fk_leftmenu'], - 'position'=>$menu['position'], + 'position'=>$menu['position'], 'entry'=>$entry, - 'buttons'=>$buttons + 'buttons'=>$buttons ); $i++; } @@ -369,36 +369,36 @@ if ($conf->use_javascript_ajax) // Process remaining records (records that are not linked to root by any path) - $remainingdata = array(); + $remainingdata = array(); foreach ($data as $datar) { - if (empty($datar['rowid']) || $tree_recur_alreadyadded[$datar['rowid']]) continue; - $remainingdata[] = $datar; + if (empty($datar['rowid']) || $tree_recur_alreadyadded[$datar['rowid']]) continue; + $remainingdata[] = $datar; } if (count($remainingdata)) { - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print '
'.$langs->trans("NotTopTreeMenuPersonalized").'
'.$langs->trans("NotTopTreeMenuPersonalized").'
'; - foreach ($remainingdata as $datar) - { - $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); - //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; - tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); - } + print '
'; + foreach ($remainingdata as $datar) + { + $father = array('rowid'=>$datar['rowid'], 'title'=>"???", 'mainmenu'=>$datar['fk_mainmenu'], 'leftmenu'=>$datar['fk_leftmenu'], 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); + //print 'Start with rowid='.$datar['rowid'].' mainmenu='.$father ['mainmenu'].' leftmenu='.$father ['leftmenu'].'
'."\n"; + tree_recur($data, $father, 0, 'iddivjstree'.$datar['rowid'], 1, 1); + } - print '
'; + print ''; } print ''; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 9aec5ef0c29..78b4d10b0c0 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -91,106 +91,106 @@ foreach ($modulesdir as $dir) while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { - $modName = substr($file, 0, dol_strlen($file) - 10); + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); - if ($modName) - { - if (!empty($modNameLoaded[$modName])) - { - $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; - setEventMessages($mesg, null, 'warnings'); - dol_syslog($mesg, LOG_ERR); + if ($modName) + { + if (!empty($modNameLoaded[$modName])) + { + $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.
"; + setEventMessages($mesg, null, 'warnings'); + dol_syslog($mesg, LOG_ERR); continue; - } + } - try { - $res = include_once $dir.$file; - if (class_exists($modName)) + try { + $res = include_once $dir.$file; + if (class_exists($modName)) { try { - $objMod = new $modName($db); + $objMod = new $modName($db); $modNameLoaded[$modName] = $dir; - if (!$objMod->numero > 0 && $modName != 'modUser') - { - dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); - } + if (!$objMod->numero > 0 && $modName != 'modUser') + { + dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); + } $j = $objMod->numero; - $modulequalified = 1; + $modulequalified = 1; - // We discard modules according to features level (PS: if module is activated we always show it) - $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; + // We discard modules according to features level (PS: if module is activated we always show it) + $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified = 0; + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified = 0; if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified = 0; - // We discard modules according to property disabled - //if (! empty($objMod->hidden)) $modulequalified=0; + // We discard modules according to property disabled + //if (! empty($objMod->hidden)) $modulequalified=0; - if ($modulequalified > 0) - { - $publisher = dol_escape_htmltag($objMod->getPublisher()); - $external = ($objMod->isCoreOrExternalModule() == 'external'); - if ($external) - { - if ($publisher) - { - $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; - } else { - $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); - } - } - ksort($arrayofnatures); - } + if ($modulequalified > 0) + { + $publisher = dol_escape_htmltag($objMod->getPublisher()); + $external = ($objMod->isCoreOrExternalModule() == 'external'); + if ($external) + { + if ($publisher) + { + $arrayofnatures['external_'.$publisher] = $langs->trans("External").' - '.$publisher; + } else { + $arrayofnatures['external_'] = $langs->trans("External").' - '.$langs->trans("UnknownPublishers"); + } + } + ksort($arrayofnatures); + } - // Define array $categ with categ with at least one qualified module - if ($modulequalified > 0) - { - $modules[$i] = $objMod; - $filename[$i] = $modName; + // Define array $categ with categ with at least one qualified module + if ($modulequalified > 0) + { + $modules[$i] = $objMod; + $filename[$i] = $modName; - // Gives the possibility to the module, to provide his own family info and position of this family - if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { - if (!is_array($familyinfo)) $familyinfo = array(); - $familyinfo = array_merge($familyinfo, $objMod->familyinfo); - $familykey = key($objMod->familyinfo); - } else { - $familykey = $objMod->family; - } + // Gives the possibility to the module, to provide his own family info and position of this family + if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { + if (!is_array($familyinfo)) $familyinfo = array(); + $familyinfo = array_merge($familyinfo, $objMod->familyinfo); + $familykey = key($objMod->familyinfo); + } else { + $familykey = $objMod->family; + } - $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); - if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) - { - $moduleposition = '80'; // External modules at end by default - } + $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); + if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external')) + { + $moduleposition = '80'; // External modules at end by default + } - $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number - $dirmod[$i] = $dir; - //print $i.'-'.$dirmod[$i].'
'; - // Set categ[$i] - $specialstring = 'unknown'; - if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; - if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories - else $categ[$specialstring] = 1; - $j++; - $i++; - } else dol_syslog("Module ".get_class($objMod)." not qualified"); + $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number + $dirmod[$i] = $dir; + //print $i.'-'.$dirmod[$i].'
'; + // Set categ[$i] + $specialstring = 'unknown'; + if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring = 'expdev'; + if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories + else $categ[$specialstring] = 1; + $j++; + $i++; + } else dol_syslog("Module ".get_class($objMod)." not qualified"); } catch (Exception $e) - { - dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); - } + { + dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); + } } else { print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
"; } } catch (Exception $e) - { - dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); - } - } - } + { + dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); + } + } + } } closedir($handle); } else { @@ -208,16 +208,16 @@ unset($objMod); $i = 0; foreach ($orders as $tmpkey => $tmpvalue) { - $tmpMod = $modules[$tmpkey]; - if ($tmpMod->numero == $id) - { - $key = $i; - $modName = $filename[$tmpkey]; - $dirofmodule = $dirmod[$tmpkey]; - $objMod = $tmpMod; - break; - } - $i++; + $tmpMod = $modules[$tmpkey]; + if ($tmpMod->numero == $id) + { + $key = $i; + $modName = $filename[$tmpkey]; + $dirofmodule = $dirmod[$tmpkey]; + $objMod = $tmpMod; + break; + } + $i++; } $value = $orders[$key]; $tab = explode('_', $value); @@ -296,7 +296,7 @@ $versiontrans .= $objMod->getVersion(1); $imginfo = "info"; if ($objMod->isCoreOrExternalModule() == 'external') { - $imginfo = "info_black"; + $imginfo = "info_black"; } // Define text of description of module @@ -304,138 +304,138 @@ $text = ''; if ($mode == 'desc') { - if ($moduledesc) $text .= '
'.$moduledesc.'


'; + if ($moduledesc) $text .= '
'.$moduledesc.'


'; - $text .= ''.$langs->trans("Version").': '.$version; + $text .= ''.$langs->trans("Version").': '.$version; - $moduledescriptorfile = get_class($objMod).'.class.php'; - $text .= '
'.$langs->trans("DescriptorFile").': '.$moduledescriptorfile; + $moduledescriptorfile = get_class($objMod).'.class.php'; + $text .= '
'.$langs->trans("DescriptorFile").': '.$moduledescriptorfile; - $textexternal = ''; - if ($objMod->isCoreOrExternalModule() == 'external') - { - $textexternal .= '
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule); - if ($objMod->editor_name != 'dolibarr') $textexternal .= '
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); - $editor_url = $objMod->editor_url; - if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; - if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; - $text .= $textexternal; - $text .= '
'; - } else { - $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; - } + $textexternal = ''; + if ($objMod->isCoreOrExternalModule() == 'external') + { + $textexternal .= '
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule); + if ($objMod->editor_name != 'dolibarr') $textexternal .= '
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); + $editor_url = $objMod->editor_url; + if (!preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url; + if (!empty($objMod->editor_url) && !preg_match('/dolibarr\.org/i', $objMod->editor_url)) $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; + $text .= $textexternal; + $text .= '
'; + } else { + $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; + } - $moduledesclong = $objMod->getDescLong(); - if ($moduledesclong) $text .= '

'.$moduledesclong.'
'; + $moduledesclong = $objMod->getDescLong(); + if ($moduledesclong) $text .= '

'.$moduledesclong.'
'; } if ($mode == 'feature') { - $text .= '
'.$langs->trans("DependsOn").': '; - if (count($objMod->depends)) $text .= join(',', $objMod->depends); + $text .= '
'.$langs->trans("DependsOn").': '; + if (count($objMod->depends)) $text .= join(',', $objMod->depends); else $text .= $langs->trans("None"); - $text .= '
'.$langs->trans("RequiredBy").': '; + $text .= '
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) $text .= join(',', $objMod->requiredby); else $text .= $langs->trans("None"); - $text .= '

'; + $text .= '

'; - $text .= '
'.$langs->trans("AddDataTables").': '; + $text .= '
'.$langs->trans("AddDataTables").': '; $sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back')); - if (count($sqlfiles) > 0) - { - $text .= $langs->trans("Yes").' ('; - $i = 0; - foreach ($sqlfiles as $val) - { - $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); - $i++; - } - $text .= ')'; - } else $text .= $langs->trans("No"); + if (count($sqlfiles) > 0) + { + $text .= $langs->trans("Yes").' ('; + $i = 0; + foreach ($sqlfiles as $val) + { + $text .= ($i ? ', ' : '').preg_replace('/\.sql$/', '', preg_replace('/llx_/', '', $val['name'])); + $i++; + } + $text .= ')'; + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddDictionaries").': '; - if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) - { - $i = 0; - foreach ($objMod->dictionaries['tablib'] as $val) - { - $text .= ($i ? ', ' : '').$val; - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddDictionaries").': '; + if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib'])) + { + $i = 0; + foreach ($objMod->dictionaries['tablib'] as $val) + { + $text .= ($i ? ', ' : '').$val; + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddData").': '; - $filedata = dol_buildpath($moduledir.'/sql/data.sql'); - if (dol_is_file($filedata)) - { - $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddData").': '; + $filedata = dol_buildpath($moduledir.'/sql/data.sql'); + if (dol_is_file($filedata)) + { + $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddRemoveTabs").': '; - if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) - { - $i = 0; - foreach ($objMod->tabs as $val) - { - if (is_array($val)) $val = $val['data']; - if (is_string($val)) - { - $tmp = explode(':', $val, 3); - $text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1]; - $i++; - } - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddRemoveTabs").': '; + if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs)) + { + $i = 0; + foreach ($objMod->tabs as $val) + { + if (is_array($val)) $val = $val['data']; + if (is_string($val)) + { + $tmp = explode(':', $val, 3); + $text .= ($i ? ', ' : '').$tmp[0].':'.$tmp[1]; + $i++; + } + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddModels").': '; - if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddModels").': '; + if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddSubstitutions").': '; - if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddSubstitutions").': '; + if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddSheduledJobs").': '; - if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) - { - $i = 0; - foreach ($objMod->cronjobs as $val) - { - $text .= ($i ? ', ' : '').($val['label']); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddSheduledJobs").': '; + if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs)) + { + $i = 0; + foreach ($objMod->cronjobs as $val) + { + $text .= ($i ? ', ' : '').($val['label']); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddTriggers").': '; - $moreinfoontriggerfile = ''; - if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) - { - $yesno = 'Yes'; - } else { - $yesno = 'No'; - } - require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interfaces = new Interfaces($db); - $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers')); + $text .= '
'.$langs->trans("AddTriggers").': '; + $moreinfoontriggerfile = ''; + if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) + { + $yesno = 'Yes'; + } else { + $yesno = 'No'; + } + require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interfaces = new Interfaces($db); + $triggers = $interfaces->getTriggersList(array((($objMod->isCoreOrExternalModule() == 'external') ? '/'.$moduledir : '').'/core/triggers')); foreach ($triggers as $triggercursor) { if ($triggercursor['module'] == $moduledir) @@ -445,110 +445,110 @@ if ($mode == 'feature') } } - $text .= $langs->trans($yesno).$moreinfoontriggerfile; + $text .= $langs->trans($yesno).$moreinfoontriggerfile; - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddBoxes").': '; - if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) - { - $i = 0; - foreach ($objMod->boxes as $val) - { - $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddBoxes").': '; + if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) + { + $i = 0; + foreach ($objMod->boxes as $val) + { + $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddHooks").': '; - if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) - { - $i = 0; - foreach ($objMod->module_parts['hooks'] as $key => $val) - { - if ($key === 'entity') continue; + $text .= '
'.$langs->trans("AddHooks").': '; + if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) + { + $i = 0; + foreach ($objMod->module_parts['hooks'] as $key => $val) + { + if ($key === 'entity') continue; - // For special values - if ($key === 'data') - { - if (is_array($val)) - { - foreach ($val as $value) - { - $text .= ($i ? ', ' : '').($value); - $i++; - } + // For special values + if ($key === 'data') + { + if (is_array($val)) + { + foreach ($val as $value) + { + $text .= ($i ? ', ' : '').($value); + $i++; + } - continue; - } - } + continue; + } + } - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddPermissions").': '; - if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) - { - $i = 0; - foreach ($objMod->rights as $val) - { - $text .= ($i ? ', ' : '').($val[1]); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddPermissions").': '; + if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights)) + { + $i = 0; + foreach ($objMod->rights as $val) + { + $text .= ($i ? ', ' : '').($val[1]); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddMenus").': '; - if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1 - { - $text .= $langs->trans("Yes"); - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddMenus").': '; + if (isset($objMod->menu) && !empty($objMod->menu)) // objMod can be an array or just an int 1 + { + $text .= $langs->trans("Yes"); + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddExportProfiles").': '; - if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) - { - $i = 0; - foreach ($objMod->export_label as $val) - { - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddExportProfiles").': '; + if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label)) + { + $i = 0; + foreach ($objMod->export_label as $val) + { + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddImportProfiles").': '; - if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) - { - $i = 0; - foreach ($objMod->import_label as $val) - { - $text .= ($i ? ', ' : '').($val); - $i++; - } - } else $text .= $langs->trans("No"); + $text .= '
'.$langs->trans("AddImportProfiles").': '; + if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label)) + { + $i = 0; + foreach ($objMod->import_label as $val) + { + $text .= ($i ? ', ' : '').($val); + $i++; + } + } else $text .= $langs->trans("No"); - $text .= '
'; + $text .= '
'; - $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; - $text .= $langs->trans("DetectionNotPossible"); + $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; + $text .= $langs->trans("DetectionNotPossible"); } if ($mode == 'changelog') { - $changelog = $objMod->getChangeLog(); - if ($changelog) $text .= '
'.$changelog.'
'; - else $text .= '
'.$langs->trans("NotAvailable").'
'; + $changelog = $objMod->getChangeLog(); + if ($changelog) $text .= '
'.$changelog.'
'; + else $text .= '
'.$langs->trans("NotAvailable").'
'; } print $text; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index c97ccb182b8..e7b7e2cd59b 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -28,7 +28,7 @@ * \brief Page to activate/disable all modules */ -if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -404,7 +404,7 @@ foreach ($modulesdir as $dir) $familyposition = (empty($familyinfo[$familykey]['position']) ? 0 : $familyinfo[$familykey]['position']); $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other'); - if ($external && ! in_array($familykey, $listOfOfficialModuleGroups)) + if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). if (is_numeric($familyposition)) { diff --git a/htdocs/admin/mrp_extrafields.php b/htdocs/admin/mrp_extrafields.php index e81c7f1cf75..2a48713869c 100644 --- a/htdocs/admin/mrp_extrafields.php +++ b/htdocs/admin/mrp_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -92,9 +92,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -102,10 +102,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 1973ec95909..962adae93aa 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -34,7 +34,7 @@ $langs->loadLangs(array('admin', 'multicurrency')); // Access control if (!$user->admin) { - accessforbidden(); + accessforbidden(); } // Parameters @@ -52,9 +52,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) $value = GETPOST($code, 'alpha'); if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessages($langs->trans("Error"), null, 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -63,9 +63,9 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) $code = $reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessages($langs->trans("Error"), null, 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -132,17 +132,17 @@ if ($action == 'add_currency') } } elseif ($action == 'setapilayer') { - if (GETPOSTISSET('modify_apilayer')) - { - dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha')); - dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); - //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); - } else { - $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); - if ($result > 0) { - setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); - } - } + if (GETPOSTISSET('modify_apilayer')) + { + dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha')); + dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); + //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); + } else { + $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); + if ($result > 0) { + setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); + } + } } @@ -189,10 +189,10 @@ print ''; print ''.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE'); + print ajax_constantonoff('MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE", $arrval, $conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE", $arrval, $conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE); } print ''; @@ -201,26 +201,26 @@ print ''; print ''.$langs->transnoentitiesnoconv("multicurrency_useOriginTx").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_ORIGIN_TX'); + print ajax_constantonoff('MULTICURRENCY_USE_ORIGIN_TX'); } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_ORIGIN_TX", $arrval, $conf->global->MULTICURRENCY_USE_ORIGIN_TX); + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_ORIGIN_TX", $arrval, $conf->global->MULTICURRENCY_USE_ORIGIN_TX); } print ''; // Online payment with currency on document. This option should be on by default. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; - print ''.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").''; - print ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT); - } - print ''; + print ''; + print ''.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").''; + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT); + } + print ''; } /* TODO uncomment when the functionality will integrated @@ -258,9 +258,9 @@ print '
'; if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'; print ''; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index b484e7acea9..13b1b4b3e55 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -61,8 +61,8 @@ if ($action == 'settemplates') $triggername = $reg[1]; $constvalue = GETPOST($key, 'alpha'); $consttype = 'emailtemplate:xxx'; - $tmparray=explode(':', $constvalue); - if (! empty($tmparray[0]) && ! empty($tmparray[1])) { + $tmparray = explode(':', $constvalue); + if (!empty($tmparray[0]) && !empty($tmparray[1])) { $constvalue = $tmparray[0]; $consttype = 'emailtemplate:'.$tmparray[1]; //var_dump($constvalue); @@ -96,19 +96,19 @@ if ($action == 'setvalue' && $user->admin) $db->begin(); $result = dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM", GETPOST("email_from", "restricthtml"), 'chaine', 0, '', $conf->entity); - if ($result < 0) $error++; + if ($result < 0) $error++; - if (!$error) - { - $db->commit(); + if (!$error) + { + $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -116,50 +116,50 @@ if ($action == 'setfixednotif' && $user->admin) { $db->begin(); - if (!$error && is_array($_POST)) - { - $reg = array(); - foreach ($_POST as $key => $val) - { - if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; + if (!$error && is_array($_POST)) + { + $reg = array(); + foreach ($_POST as $key => $val) + { + if (!preg_match('/^NOTIF_(.*)_key$/', $key, $reg)) continue; - $newval = ''; - $newkey = ''; + $newval = ''; + $newkey = ''; - $shortkey = preg_replace('/_key$/', '', $key); - //print $shortkey.'
'; + $shortkey = preg_replace('/_key$/', '', $key); + //print $shortkey.'
'; - if (preg_match('/^NOTIF_(.*)_old_(.*)_key/', $key, $reg)) - { + 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'); //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'); - } + } 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'); + } - if ($newkey && $newval) - { + if ($newkey && $newval) + { $result = dolibarr_set_const($db, $newkey, $newval, 'chaine', 0, '', $conf->entity); - } - } - } + } + } + } if (!$error) - { - $db->commit(); + { + $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -318,66 +318,66 @@ print "\n"; 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'])); + $elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype'])); // Special cases - if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); - elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); - elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); - elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); + if ($notifiedevent['elementtype'] == 'order_supplier') $elementLabel = $langs->trans('SupplierOrder'); + elseif ($notifiedevent['elementtype'] == 'propal') $elementLabel = $langs->trans('Proposal'); + elseif ($notifiedevent['elementtype'] == 'facture') $elementLabel = $langs->trans('Bill'); + elseif ($notifiedevent['elementtype'] == 'commande') $elementLabel = $langs->trans('Order'); elseif ($notifiedevent['elementtype'] == 'ficheinter') $elementLabel = $langs->trans('Intervention'); elseif ($notifiedevent['elementtype'] == 'shipping') $elementLabel = $langs->trans('Shipping'); elseif ($notifiedevent['elementtype'] == 'expensereport') $elementLabel = $langs->trans('ExpenseReport'); - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + } + // New entry input fields + $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 ''; - print ''; - print ''; - print ''; + print ''; + print ''; } print '
'.$elementLabel.''.$notifiedevent['code'].''.$label.''; - // Notification with threshold - foreach ($conf->global as $key => $val) - { + print '
'.$elementLabel.''.$notifiedevent['code'].''.$label.''; + // Notification with threshold + foreach ($conf->global as $key => $val) + { 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); + $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++; } - 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); + 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. - print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); - print '
'; - // Notification with threshold - foreach ($conf->global as $key => $val) - { + print ''; + // Notification with threshold + foreach ($conf->global as $key => $val) + { if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) continue; - print $langs->trans("AmountHT").' >= '; + print $langs->trans("AmountHT").' >= '; print '
'; - } - // New entry input fields + } + // New entry input fields print $langs->trans("AmountHT").' >= '; print '
'; + print ''; // TODO Add link to show message content - print '
'; diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index af352558a71..a71e09fad56 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -38,7 +38,7 @@ $langs->loadLangs(array('admin', 'oauth')); // Security check if (!$user->admin) - accessforbidden(); + accessforbidden(); $action = GETPOST('action', 'aZ09'); @@ -49,23 +49,23 @@ $action = GETPOST('action', 'aZ09'); if ($action == 'update') { - $error = 0; + $error = 0; - foreach ($list as $constname) { - $constvalue = GETPOST($constname[1], 'alpha'); - if (!dolibarr_set_const($db, $constname[1], $constvalue, 'chaine', 0, '', $conf->entity)) - $error++; - $constvalue = GETPOST($constname[2], 'alpha'); - if (!dolibarr_set_const($db, $constname[2], $constvalue, 'chaine', 0, '', $conf->entity)) - $error++; - } + foreach ($list as $constname) { + $constvalue = GETPOST($constname[1], 'alpha'); + if (!dolibarr_set_const($db, $constname[1], $constvalue, 'chaine', 0, '', $conf->entity)) + $error++; + $constvalue = GETPOST($constname[2], 'alpha'); + if (!dolibarr_set_const($db, $constname[2], $constvalue, 'chaine', 0, '', $conf->entity)) + $error++; + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* @@ -97,46 +97,46 @@ $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++; + $i++; - print ''; - // Api Name - $label = $langs->trans($key[0]); - print ''.$label.''; - print ''; - if (!empty($key[3])) print $langs->trans($key[3]); - print ''; - print ''; + print ''; + // Api Name + $label = $langs->trans($key[0]); + print ''.$label.''; + print ''; + if (!empty($key[3])) print $langs->trans($key[3]); + print ''; + print ''; - if ($supported) - { - $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; - print ''; - print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print ''; - print ''; - } else { - print ''; - print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print ''.$langs->trans("FeatureNotYetSupported").''; - print ''; - } + if ($supported) + { + $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php'; + print ''; + print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''; + print ''; + } else { + print ''; + print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''.$langs->trans("FeatureNotYetSupported").''; + print ''; + } - // Api Id - print ''; - print ''; - print ''; - print ''; + // Api Id + print ''; + print ''; + print ''; + print ''; - // Api Secret - print ''; - print ''; - print ''; - print ''; + // Api Secret + print ''; + print ''; + print ''; + print ''; } print ''."\n"; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 99510f4b7c8..4fb0bbb7452 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -156,7 +156,7 @@ if ($mode == 'setup' && $user->admin) // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service). // We pass this param list in to 'state' because we need it before and after the redirect. $shortscope = 'userinfo_email,userinfo_profile,cloud_print'; - if (!empty($conf->global->OAUTH_GSUITE)){ + if (!empty($conf->global->OAUTH_GSUITE)) { $shortscope .= ',admin_directory_user'; } //$scope.=',gmail_full'; diff --git a/htdocs/admin/openinghours.php b/htdocs/admin/openinghours.php index 9d70fdedff7..7cd803d5e69 100644 --- a/htdocs/admin/openinghours.php +++ b/htdocs/admin/openinghours.php @@ -97,37 +97,37 @@ if (empty($action) || $action == 'edit' || $action == 'updateedit') print ''; print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'>'."\n"; - print ''; - print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; - print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc")); - print ''; - print ''."\n"; + print ''; + print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc")); + print ''; + print ''."\n"; - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index 81d0312ab69..5d5573d4579 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -83,9 +83,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -98,9 +98,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -110,10 +110,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 734d617f564..2f7462a3cf0 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -84,9 +84,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 8edf851f49e..d92704c211b 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -47,23 +47,23 @@ if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_pay if ($action == 'updateMask') { - $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); - $maskpayment = GETPOST('maskpayment', 'alpha'); - if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); + $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); + $maskpayment = GETPOST('maskpayment', 'alpha'); + if ($maskconstpayment) $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } if ($action == 'setmod') { - dolibarr_set_const($db, "PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); } if ($action == 'setparams') @@ -72,8 +72,8 @@ if ($action == 'setparams') $res = dolibarr_set_const($db, "FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", $freetext, 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; - $res = dolibarr_set_const($db, "PAYMENTS_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "PAYMENTS_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; if ($error) { @@ -81,7 +81,7 @@ if ($action == 'setparams') } if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -123,105 +123,105 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/payment/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { - $filebis = $file; - $classname = preg_replace('/\.php$/', '', $file); - // For compatibility - if (!is_file($dir.$filebis)) - { - $filebis = $file."/".$file.".modules.php"; - $classname = "mod_payment_".$file; - } - // Check if there is a filter on country - preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + $dir = dol_buildpath($reldir."core/modules/payment/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_payment_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; - $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { - // Charging the numbering class - require_once $dir.$filebis; + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; - $module = new $classname($db); + $module = new $classname($db); - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + // Show modules according to features level + 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()) - { - $var = !$var; - print ''; - echo preg_replace('/\-.*$/', '', preg_replace('/mod_payment_/', '', preg_replace('/\.php$/', '', $file))); - print "\n"; + if ($module->isEnabled()) + { + $var = !$var; + print ''; + echo preg_replace('/\-.*$/', '', preg_replace('/mod_payment_/', '', preg_replace('/\.php$/', '', $file))); + print "\n"; - print $module->info(); + print $module->info(); - print ''; + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - //print "> ".$conf->global->PAYMENT_ADDON." - ".$file; - if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + //print "> ".$conf->global->PAYMENT_ADDON." - ".$file; + if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $payment = new Paiement($db); - $payment->initAsSpecimen(); + $payment = new Paiement($db); + $payment->initAsSpecimen(); - // Example - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $payment); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Example + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $payment); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); - } + if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + } - print ''; + print ''; - print "\n"; - } - } - } - } - closedir($handle); - } - } + print "\n"; + } + } + } + } + closedir($handle); + } + } } print ''; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 363edca6c80..75681ad36c0 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -46,7 +46,7 @@ $cancel = GETPOST('cancel', 'alpha'); */ if ($cancel) { - $action = ''; + $action = ''; } if ($action == 'update') @@ -78,10 +78,10 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 3677daa38a5..4905f4f2497 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -44,18 +44,18 @@ $entity = $conf->entity; if ($action == 'add') { - $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1"; - $sql .= " WHERE id = ".GETPOST("pid", 'int'); - $sql .= " AND entity = ".$conf->entity; - $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1"; + $sql .= " WHERE id = ".GETPOST("pid", 'int'); + $sql .= " AND entity = ".$conf->entity; + $db->query($sql); } if ($action == 'remove') { - $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0"; - $sql .= " WHERE id = ".GETPOST('pid', 'int'); - $sql .= " AND entity = ".$conf->entity; - $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0"; + $sql .= " WHERE id = ".GETPOST('pid', 'int'); + $sql .= " AND entity = ".$conf->entity; + $db->query($sql); } @@ -145,81 +145,81 @@ $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $oldmod = ''; + $num = $db->num_rows($result); + $i = 0; + $oldmod = ''; - while ($i < $num) - { - $obj = $db->fetch_object($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); - // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it - if (empty($modules[$obj->module])) - { - $i++; - continue; - } + // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it + if (empty($modules[$obj->module])) + { + $i++; + continue; + } - // Save field module_position in database if value is still zero - if (empty($obj->module_position)) - { - if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) - { - // TODO Define familyposition - $family = $modules[$obj->module]->family_position; - $familyposition = 0; - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; - $sqlupdate .= " family_position = ".$familyposition; - $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; - $db->query($sqlupdate); - } - } + // Save field module_position in database if value is still zero + if (empty($obj->module_position)) + { + if (is_object($modules[$obj->module]) && ($modules[$obj->module]->module_position > 0)) + { + // TODO Define familyposition + $family = $modules[$obj->module]->family_position; + $familyposition = 0; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."rights_def SET module_position = ".$modules[$obj->module]->module_position.","; + $sqlupdate .= " family_position = ".$familyposition; + $sqlupdate .= " WHERE module_position = 0 AND module = '".$db->escape($obj->module)."'"; + $db->query($sqlupdate); + } + } - // Check if permission we found is inside a module definition. If not, we discard it. - $found = false; - foreach ($modules[$obj->module]->rights as $key => $val) - { - if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) - { - $found = true; - break; - } - } + // Check if permission we found is inside a module definition. If not, we discard it. + $found = false; + foreach ($modules[$obj->module]->rights as $key => $val) + { + if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) + { + $found = true; + break; + } + } if (!$found) { $i++; continue; } - // Break found, it's a new module to catch + // Break found, it's a new module to catch if (isset($obj->module) && ($oldmod <> $obj->module)) - { - $oldmod = $obj->module; + { + $oldmod = $obj->module; - // Break detected, we get objMod - $objMod = $modules[$obj->module]; - $picto = ($objMod->picto ? $objMod->picto : 'generic'); + // Break detected, we get objMod + $objMod = $modules[$obj->module]; + $picto = ($objMod->picto ? $objMod->picto : 'generic'); - // Show break line - print ''; - print ''; - print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); - print ''; - print ''; - print ' '; - print ' '; - print ' '; - // Permission id - if ($user->admin) print ''; - print ''."\n"; - } + // Show break line + print ''; + print ''; + print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName(); + print ''; + print ''; + print ' '; + print ' '; + print ' '; + // Permission id + if ($user->admin) print ''; + print ''."\n"; + } - $perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->label)); + $perm_libelle = ($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id) != ("PermissionAdvanced".$obj->id)) ? $langs->trans("PermissionAdvanced".$obj->id) : (($langs->trans("Permission".$obj->id) != ("Permission".$obj->id)) ? $langs->trans("Permission".$obj->id) : $obj->label)); - print ''; + print ''; - // Picto and label of module - print ''; + // Picto and label of module + print ''; print ''; // Tick @@ -247,15 +247,15 @@ if ($result) } // Permission and tick - print ''.$perm_libelle.''; + print ''.$perm_libelle.''; - // Permission id - if ($user->admin) print ''.$obj->id.''; + // Permission id + if ($user->admin) print ''.$obj->id.''; - print ''."\n"; + print ''."\n"; - $i++; - } + $i++; + } } else dol_print_error($db); print ''; print '
'; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 5123cec7f08..e75a06a78ad 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -76,7 +76,7 @@ if ($action == 'updateMask') { $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); + $file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { $filefound = 1; @@ -154,25 +154,25 @@ if ($action == 'updateMask') { setEventMessages($langs->trans("Error"), null, 'errors'); } } elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'set') { // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity); + if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity); } } elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { + if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { $conf->global->PROPALE_ADDON_PDF = $value; } @@ -253,13 +253,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->PROPALE_ADDON == "$file") @@ -280,16 +280,16 @@ foreach ($dirmodels as $reldir) $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $propal->type = 0; $nextval = $module->getNextValue($mysoc, $propal); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -348,83 +348,83 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/propale".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/propale".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - $var = !$var; - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + $var = !$var; + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ""; - if ($conf->global->PROPALE_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ""; + if ($conf->global->PROPALE_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + 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")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $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("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $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); @@ -434,28 +434,28 @@ foreach ($dirmodels as $reldir) $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -623,11 +623,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->tra $variablename = 'PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index d7287b53019..219643e8303 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -83,9 +83,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -98,9 +98,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -110,10 +110,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index db91aae87a1..d9eae8f064e 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -53,51 +53,51 @@ 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); + 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 = "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 - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - $i = 0; - while ($i < $numrows) - { - $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; - //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + $i = 0; + while ($i < $numrows) + { + $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; + //print $sql; - $resql2 = $db->query($sql); - if (!$resql2) - { - dol_print_error($db); - $error++; - break; - } + $resql2 = $db->query($sql); + if (!$resql2) + { + dol_print_error($db); + $error++; + break; + } - $i++; - } - } - } else dol_print_error($db); + $i++; + } + } + } else dol_print_error($db); //print $error." ".$sql; - //exit; - if (!$error) + //exit; + if (!$error) { $db->commit(); header("Location: security.php"); - exit; + exit; } else { $db->rollback(); dol_print_error($db, ''); @@ -109,9 +109,9 @@ if ($action == 'activate_encrypt') if ($allow_disable_encryption) { dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity); - } + } header("Location: security.php"); - exit; + exit; } if ($action == 'activate_encryptdbpassconf') @@ -119,9 +119,9 @@ 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 + // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); header("Location: security.php"); exit; @@ -133,7 +133,7 @@ if ($action == 'activate_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); @@ -158,24 +158,24 @@ if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') if ($action == 'updatepattern') { - $pattern = GETPOST("pattern", "alpha"); - $explodePattern = explode(';', $pattern); + $pattern = GETPOST("pattern", "alpha"); + $explodePattern = explode(';', $pattern); - $patternInError = false; - if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { - $patternInError = true; - } + $patternInError = false; + if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { + $patternInError = true; + } - if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { - $patternInError = true; - } + if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { + $patternInError = true; + } - if (!$patternInError) { - dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - header("Location: security.php"); - exit; - } + if (!$patternInError) { + dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + header("Location: security.php"); + exit; + } } @@ -214,20 +214,20 @@ $handle = opendir($dir); $i = 1; if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) - { - // Charging the numbering class - $classname = $reg[1]; - require_once $dir.'/'.$file; + while (($file = readdir($handle)) !== false) + { + if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) + { + // Charging the numbering class + $classname = $reg[1]; + require_once $dir.'/'.$file; - $obj = new $classname($db, $conf, $langs, $user); - $arrayhandler[$obj->id] = $obj; - $i++; - } - } - closedir($handle); + $obj = new $classname($db, $conf, $langs, $user); + $arrayhandler[$obj->id] = $obj; + $i++; + } + } + closedir($handle); } asort($arrayhandler); @@ -241,33 +241,33 @@ 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 == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) { - print ''; - print ucfirst($key); - print "\n"; - print $module->getDescription().'
'; - print $langs->trans("MinLength").': '.$module->length; - print ''; + print ''; + print ucfirst($key); + print "\n"; + print $module->getDescription().'
'; + print $langs->trans("MinLength").': '.$module->length; + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - if ($conf->global->USER_PASSWORD_GENERATED == $key) - { - print img_picto('', 'tick'); - } else { - print ''.$langs->trans("Activate").''; - } - print "\n"; + print ''; + if ($conf->global->USER_PASSWORD_GENERATED == $key) + { + print img_picto('', 'tick'); + } else { + print ''.$langs->trans("Activate").''; + } + print "\n"; } } print ''; @@ -493,14 +493,14 @@ print '
'; if (GETPOST('info', 'int') > 0) { - if (function_exists('password_hash')) - { - print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; - } else { - print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; - } - print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; - print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; + if (function_exists('password_hash')) + { + print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; + } else { + print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; + } + print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; + print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; } print '
'; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index 2e4f1f05229..5f063dbe2a2 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -121,8 +121,8 @@ if (function_exists("imagecreatefrompng")) } } } else { - $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); - print $desc; + $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); + print $desc; } print ''; diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index e09304a4921..e34d2ab9b7a 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -86,32 +86,32 @@ if ($action == 'send' && !$_POST['cancel']) if (!empty($formsms->error)) { setEventMessages($formsms->error, $formsms->errors, 'errors'); - $action = 'test'; - $error++; + $action = 'test'; + $error++; + } + if (empty($body)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); + $action = 'test'; + $error++; } - if (empty($body)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); - $action = 'test'; - $error++; - } 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)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors'); - $action = 'test'; + $action = 'test'; $error++; } if (!$error) { // Make substitutions into message - complete_substitutions_array($substitutionarrayfortest, $langs); - $body = make_substitutions($body, $substitutionarrayfortest); + complete_substitutions_array($substitutionarrayfortest, $langs); + $body = make_substitutions($body, $substitutionarrayfortest); require_once DOL_DOCUMENT_ROOT.'/core/class/CSMSFile.class.php'; @@ -180,7 +180,7 @@ if ($action == 'edit') print ''.$langs->trans("MAIN_SMS_SENDMODE").''; if (count($listofmethods)) print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1); else print ''.$langs->trans("None").''; - print ''; + print ''; // From print ''.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).''; @@ -259,9 +259,9 @@ if ($action == 'edit') if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) { - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; } else { - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; } print '
'; @@ -298,9 +298,9 @@ if ($action == 'edit') // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php'; $formsms = new FormSms($db); - $formsms->fromtype = 'user'; - $formsms->fromid = $user->id; - $formsms->fromsms = (GETPOSTISSET('fromsms') ? $_POST['fromsms'] : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile)); + $formsms->fromtype = 'user'; + $formsms->fromid = $user->id; + $formsms->fromsms = (GETPOSTISSET('fromsms') ? $_POST['fromsms'] : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile)); $formsms->withfromreadonly = 0; $formsms->withsubstit = 0; $formsms->withfrom = 1; diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index faf8897126f..0ab3a91432b 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -43,26 +43,26 @@ $action = GETPOST('action', 'aZ09'); */ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } @@ -96,15 +96,15 @@ print '
'; $arrayofsocialnetworks = array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn'); foreach ($arrayofsocialnetworks as $snkey => $snlabel) { - $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); - if ($conf->use_javascript_ajax) { - $link = ajax_constantonoff($consttocheck); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); - } + $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); + if ($conf->use_javascript_ajax) { + $link = ajax_constantonoff($consttocheck); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); + } - print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; + print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; } diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php index fe98d4bfe9e..2fa111578a9 100644 --- a/htdocs/admin/spip.php +++ b/htdocs/admin/spip.php @@ -55,48 +55,48 @@ if ($action == 'update' || $action == 'add') $consttypearray = GETPOST("consttype", 'array'); $constnotearray = GETPOST("constnote", 'array'); - // Action mise a jour ou ajout d'une constante - if ($action == 'update' || $action == 'add') - { - foreach ($constnamearray as $key => $val) - { - $constname = dol_escape_htmltag($constnamearray[$key]); - $constvalue = dol_escape_htmltag($constvaluearray[$key]); - $consttype = dol_escape_htmltag($consttypearray[$key]); - $constnote = dol_escape_htmltag($constnotearray[$key]); + // Action mise a jour ou ajout d'une constante + if ($action == 'update' || $action == 'add') + { + foreach ($constnamearray as $key => $val) + { + $constname = dol_escape_htmltag($constnamearray[$key]); + $constvalue = dol_escape_htmltag($constvaluearray[$key]); + $consttype = dol_escape_htmltag($consttypearray[$key]); + $constnote = dol_escape_htmltag($constnotearray[$key]); - $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); + $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); - if (!$res > 0) $error++; - } + if (!$res > 0) $error++; + } - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } } // Action activation d'un sous module du module adherent if ($action == 'set') { - $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } } // Action desactivation d'un sous module du module adherent if ($action == 'unset') { - $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); + if ($result < 0) + { + dol_print_error($db); + } } @@ -128,39 +128,39 @@ if (!empty($conf->global->ADHERENT_USE_SPIP)) print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user'); - //$link=img_picto($langs->trans("Active"),'tick').' '; - $link = ''; - //$link.=$langs->trans("Disable"); - $link .= img_picto($langs->trans("Activated"), 'switch_on'); - $link .= ''; - // Edition des varibales globales - $constantes = array( - 'ADHERENT_SPIP_SERVEUR', - 'ADHERENT_SPIP_DB', - 'ADHERENT_SPIP_USER', - 'ADHERENT_SPIP_PASS' + //$link=img_picto($langs->trans("Active"),'tick').' '; + $link = ''; + //$link.=$langs->trans("Disable"); + $link .= img_picto($langs->trans("Activated"), 'switch_on'); + $link .= ''; + // Edition des varibales globales + $constantes = array( + 'ADHERENT_SPIP_SERVEUR', + 'ADHERENT_SPIP_DB', + 'ADHERENT_SPIP_USER', + 'ADHERENT_SPIP_PASS' ); - print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); + print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); print '
'; form_constantes($constantes, 2); - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; + print '
'; - print ''; + print ''; } else { - print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user'); + print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user'); - $link = ''; - //$link.=$langs->trans("Activate"); - $link .= img_picto($langs->trans("Disabled"), 'switch_off'); - $link .= ''; - print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); + $link = ''; + //$link.=$langs->trans("Activate"); + $link .= img_picto($langs->trans("Disabled"), 'switch_off'); + $link .= ''; + print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); - print dol_get_fiche_end(); + print dol_get_fiche_end(); } // End of page diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index e833bd543ed..c5a6bc79421 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -93,7 +93,7 @@ if ($action == 'warehouse') { $value = GETPOST('default_warehouse', 'alpha'); $res = dolibarr_set_const($db, "MAIN_DEFAULT_WAREHOUSE", $value, 'chaine', 0, '', $conf->entity); - if ($value == -1 || empty($value) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)){ + if ($value == -1 || empty($value) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) { $res = dolibarr_del_const($db, "MAIN_DEFAULT_WAREHOUSE", $conf->entity); } if (!$res > 0) $error++; @@ -684,7 +684,7 @@ print ''; print ''.$langs->trans("UserDefaultWarehouse").''; print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1); + print ajax_constantonoff('MAIN_DEFAULT_WAREHOUSE_USER', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("MAIN_DEFAULT_WAREHOUSE_USER", $arrval, $conf->global->MAIN_DEFAULT_WAREHOUSE_USER); @@ -692,7 +692,7 @@ if ($conf->use_javascript_ajax) { print "\n"; print "\n"; -if (! empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { +if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { print ''; print ''.$langs->trans("UserWarehouseAutoCreate").''; print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index c248a45f9f9..779f7ab472a 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -57,15 +57,15 @@ $specimenthirdparty->initAsSpecimen(); if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskinvoice = GETPOST('maskinvoice', 'alpha'); + $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); - if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); + if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -77,44 +77,44 @@ if ($action == 'updateMask') if ($action == 'specimen') // For invoices { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $facture = new FactureFournisseur($db); - $facture->initAsSpecimen(); - $facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier) + $facture = new FactureFournisseur($db); + $facture->initAsSpecimen(); + $facture->thirdparty = $specimenthirdparty; // Define who should has build the invoice (so the supplier) - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/supplier_invoice/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/supplier_invoice/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $facture); + $module = new $classname($db, $facture); - if ($module->write_file($facture, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($facture, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -126,52 +126,52 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'INVOICE_SUPPLIER_ADDON_PDF', $conf->entity); + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'INVOICE_SUPPLIER_ADDON_PDF', $conf->entity); } } // Set default model elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; - } + if (dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value; + } - // On active le modele - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - $ret = addDocumentModel($value, $type, $label, $scandir); - } + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } } elseif ($action == 'unsetdoc') { - dolibarr_del_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $conf->entity); + dolibarr_del_const($db, "INVOICE_SUPPLIER_ADDON_PDF", $conf->entity); } if ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } if ($action == 'addcat') { - $fourn = new Fournisseur($db); - $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); + $fourn = new Fournisseur($db); + $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); } if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT') { - $freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string - $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -221,79 +221,79 @@ foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/supplier_invoice"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 24) == 'mod_facture_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file) - 4); - require_once $dir.'/'.$file.'.php'; + require_once $dir.'/'.$file.'.php'; - $module = new $file; + $module = new $file; - if ($module->isEnabled()) - { - // Show modules according to features level - 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()) + { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - print ''.$module->nom."\n"; - print $module->info(); - print ''; + print ''.$module->nom."\n"; + print $module->info(); + print ''; - // Show example of numbering model - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering model + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER == "$file") - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER == "$file") + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $invoice = new FactureFournisseur($db); - $invoice->initAsSpecimen(); + $invoice = new FactureFournisseur($db); + $invoice->initAsSpecimen(); - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $invoice); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $invoice); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - print ''; - } - } - } - closedir($handle); - } - } + print ''; + } + } + } + closedir($handle); + } + } } print '
'; @@ -318,16 +318,16 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } print ''."\n"; @@ -347,94 +347,94 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_invoice/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); + if (is_dir($dir)) + { + $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db, new FactureFournisseur($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new FactureFournisseur($db)); - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + print ""; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $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); - print ''; - print ''; + $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); + print ''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print '
"; - print (empty($module->name) ? $name : $module->name); - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; - print "'."\n"; - //if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") - //{ - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - /*} + // Active + if (in_array($name, $def)) + { + print ''."\n"; + //if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name") + //{ + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + /*} else { print img_picto($langs->trans("Enabled"),'switch_on'); }*/ - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") - { - //print img_picto($langs->trans("Default"),'on'); - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name") + { + //print img_picto($langs->trans("Default"),'on'); + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=invoice_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; @@ -466,11 +466,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->tra $variablename = 'SUPPLIER_INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 1999326c07e..60c2c4da56e 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -58,12 +58,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); - $maskvalue = GETPOST('maskorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskvalue = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); + if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; if (!$error) { @@ -73,44 +73,44 @@ if ($action == 'updateMask') } } elseif ($action == 'specimen') // For orders { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); - $commande->thirdparty = $specimenthirdparty; + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); + $commande->thirdparty = $specimenthirdparty; - // Search template files - $file = ''; $classname = ''; $filefound = 0; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { - $file = dol_buildpath($reldir."core/modules/supplier_order/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + // Search template files + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) + { + $file = dol_buildpath($reldir."core/modules/supplier_order/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db, $commande); + $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($commande, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } // Activate a model @@ -122,7 +122,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF', $conf->entity); + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF', $conf->entity); } } @@ -144,64 +144,64 @@ elseif ($action == 'setdoc') } } elseif ($action == 'setmod') { - // TODO Verifier si module numerotation choisi peut etre active - // par appel methode canBeActivated + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated - dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'addcat') { - $fourn = new Fournisseur($db); - $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); + $fourn = new Fournisseur($db); + $fourn->CreateCategory($user, GETPOST('cat', 'alphanohtml')); } elseif ($action == 'set_SUPPLIER_ORDER_OTHER') { - $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string + $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $doubleapproval = GETPOST('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED', 'alpha'); $doubleapproval = price2num($doubleapproval); - $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval, 'chaine', 0, '', $conf->entity); + $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); + $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval, 'chaine', 0, '', $conf->entity); - // TODO We add/delete permission here until permission can have a condition on a global var - include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; - $newmodule = new modFournisseur($db); + // TODO We add/delete permission here until permission can have a condition on a global var + include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; + $newmodule = new modFournisseur($db); - if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) - { - // clear default rights array - $newmodule->rights = array(); - // add new right - $r = 0; - $newmodule->rights[$r][0] = 1190; - $newmodule->rights[$r][1] = $langs->trans("Permission1190"); - $newmodule->rights[$r][2] = 'w'; - $newmodule->rights[$r][3] = 0; - $newmodule->rights[$r][4] = 'commande'; - $newmodule->rights[$r][5] = 'approve2'; + if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) + { + // clear default rights array + $newmodule->rights = array(); + // add new right + $r = 0; + $newmodule->rights[$r][0] = 1190; + $newmodule->rights[$r][1] = $langs->trans("Permission1190"); + $newmodule->rights[$r][2] = 'w'; + $newmodule->rights[$r][3] = 0; + $newmodule->rights[$r][4] = 'commande'; + $newmodule->rights[$r][5] = 'approve2'; - // Insert - $newmodule->insert_permissions(1); - } else { - // Remove all rights with Permission1190 - $newmodule->delete_permissions(); + // Insert + $newmodule->insert_permissions(1); + } else { + // Remove all rights with Permission1190 + $newmodule->delete_permissions(); - // Add all right without Permission1190 - $newmodule->insert_permissions(1); - } + // Add all right without Permission1190 + $newmodule->insert_permissions(1); + } } // Activate ask for payment bank elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } @@ -244,79 +244,79 @@ foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/supplier_order/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { - $file = substr($file, 0, dol_strlen($file) - 4); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file) - 3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file) - 4); - require_once $dir.$file.'.php'; + require_once $dir.$file.'.php'; - $module = new $file; + $module = new $file; - if ($module->isEnabled()) - { - // Show modules according to features level - 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()) + { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - print ''.$module->nom."\n"; - print $module->info(); - print ''; + print ''.$module->nom."\n"; + print $module->info(); + print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - print ''; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file") - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "$file") + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - $commande = new CommandeFournisseur($db); - $commande->initAsSpecimen(); + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); - // Info - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $commande); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Info + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $commande); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - print ''; - } - } - } - closedir($handle); - } - } + print ''; + } + } + } + closedir($handle); + } + } } print '
'; @@ -339,16 +339,16 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } print ''."\n"; @@ -368,86 +368,86 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_order/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db, new CommandeFournisseur($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new CommandeFournisseur($db)); - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print '"; - } else { - print '"; - } + // Active + if (in_array($name, $def)) + { + print '"; + } else { + print '"; + } - // Default - print ''; + // Default + print ''; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $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); - print ''; - print ''; + $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); + print ''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print '
"; - print (empty($module->name) ? $name : $module->name); - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print "
"; + print (empty($module->name) ? $name : $module->name); + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print "'."\n"; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - } else { - print img_picto($langs->trans("Enabled"), 'switch_on'); - } - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print "'."\n"; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + } else { + print img_picto($langs->trans("Enabled"), 'switch_on'); + } + print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; - if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print '

'; @@ -521,11 +521,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans $variablename = 'SUPPLIER_ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index c0c04eb9430..217b7d7c44a 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -48,21 +48,21 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); - $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); - if ($maskconstsupplierpayment) $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); + $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); + $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); + if ($maskconstsupplierpayment) $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } elseif ($action == 'setmod') { - dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON", $value, 'chaine', 0, '', $conf->entity); } // Activate a model @@ -74,7 +74,7 @@ elseif ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PAYMENT_ADDON_PDF', $conf->entity); + if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PAYMENT_ADDON_PDF', $conf->entity); } } @@ -96,54 +96,54 @@ elseif ($action == 'setdoc') } } elseif ($action == 'specimen') { - $modele = GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); - $paiementFourn = new PaiementFourn($db); - $paiementFourn->initAsSpecimen(); + $paiementFourn = new PaiementFourn($db); + $paiementFourn->initAsSpecimen(); // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { - $filefound = 1; - $classname = "pdf_".$modele; - break; - } - } + $file = dol_buildpath($reldir."core/modules/supplier_payment/doc/pdf_".$modele.".modules.php", 0); + if (file_exists($file)) + { + $filefound = 1; + $classname = "pdf_".$modele; + break; + } + } - if ($filefound) - { - require_once $file; + if ($filefound) + { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($paiementFourn, $langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, $module->errors, 'errors'); - dol_syslog($module->error, LOG_ERR); - } - } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); - } + if ($module->write_file($paiementFourn, $langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf"); + return; + } else { + setEventMessages($module->error, $module->errors, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } } elseif ($action == 'setparams') { - $res = dolibarr_set_const($db, "PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + $res = dolibarr_set_const($db, "PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", GETPOST('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD', 'int'), 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; if ($error) - { + { setEventMessages($langs->trans("Error"), null, 'errors'); } if (!$error) - { + { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } } @@ -184,16 +184,16 @@ $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { - $i = 0; - $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { - $array = $db->fetch_array($resql); - array_push($def, $array[0]); - $i++; - } + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } } else { - dol_print_error($db); + dol_print_error($db); } print ''; @@ -209,104 +209,104 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { - $filebis = $file; - $classname = preg_replace('/\.php$/', '', $file); - // For compatibility - if (!is_file($dir.$filebis)) - { - $filebis = $file."/".$file.".modules.php"; - $classname = "mod_supplier_payment_".$file; - } - // Check if there is a filter on country - preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/', '', $file); + // For compatibility + if (!is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_supplier_payment_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/', $classname, $reg); + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; - $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { - // Charging the numbering class - require_once $dir.$filebis; + $classname = preg_replace('/\-.*$/', '', $classname); + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; - $module = new $classname($db); + $module = new $classname($db); - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - if ($module->isEnabled()) - { - print ''; + print ''; - // Show example of numbering module - print ''."\n"; + // Show example of numbering module + print ''."\n"; - print ''; + print ''; - $payment = new PaiementFourn($db); - $payment->initAsSpecimen(); + $payment = new PaiementFourn($db); + $payment->initAsSpecimen(); - // Example - $htmltooltip = ''; - $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval = $module->getNextValue($mysoc, $payment); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= $langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + // Example + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $payment); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= $langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } - print ''; + print ''; - print "\n"; - } - } - } - } - closedir($handle); - } - } + print "\n"; + } + } + } + } + closedir($handle); + } + } } print '
'; - echo preg_replace('/\-.*$/', '', preg_replace('/mod_supplier_payment_/', '', preg_replace('/\.php$/', '', $file))); - print "\n"; + if ($module->isEnabled()) + { + print '
'; + echo preg_replace('/\-.*$/', '', preg_replace('/mod_supplier_payment_/', '', preg_replace('/\.php$/', '', $file))); + print "\n"; - print $module->info(); + print $module->info(); - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print '
'; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; - //print "> ".$conf->global->SUPPLIER_PAYMENT_ADDON." - ".$file; - if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) - { - print img_picto($langs->trans("Activated"), 'switch_on'); - } else { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } - print ''; + //print "> ".$conf->global->SUPPLIER_PAYMENT_ADDON." - ".$file; + if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); - } + if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + } - print '
'; @@ -335,91 +335,91 @@ foreach ($dirmodels as $reldir) $realpath = $reldir."core/modules/supplier_payment/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); + if (is_dir($dir)) + { + $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db, new PaiementFourn($db)); + require_once $dir.'/'.$file; + $module = new $classname($db, new PaiementFourn($db)); - print "\n"; - print ""; - print (empty($module->name) ? $name : $module->name); - print "\n"; - print "\n"; - require_once $dir.'/'.$file; - $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + print "\n"; + print ""; + print (empty($module->name) ? $name : $module->name); + print "\n"; + print "\n"; + require_once $dir.'/'.$file; + $module = new $classname($db, $specimenthirdparty); + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; - print "\n"; + print "\n"; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - //if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF != "$name") - //{ - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - /*} + // Active + if (in_array($name, $def)) + { + print ''."\n"; + //if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF != "$name") + //{ + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + /*} else { print img_picto($langs->trans("Enabled"),'switch_on'); }*/ - print ""; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + print ""; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Default - print ''; - if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF == "$name") - { - //print img_picto($langs->trans("Default"),'on'); - // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; - } else { - print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Default + print ''; + if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF == "$name") + { + //print img_picto($langs->trans("Default"),'on'); + // Even if choice is the default value, we allow to disable it: For supplier invoice, we accept to have no doc generation at all + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print 'scandir.'&label='.urlencode($module->name).'&type=SUPPLIER_PAYMENT"" 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("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; - print ''; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + print ''; + print ''.img_object($langs->trans("Preview"), 'order').''; + print ''; - print "\n"; - } - } + print "\n"; + } + } - closedir($handle); - } - } + closedir($handle); + } + } } print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 3e0708660d3..38a6d9e3ff5 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -77,7 +77,7 @@ if ($action == 'specimen') $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php"); + $file = dol_buildpath($reldir."core/modules/supplier_proposal/doc/pdf_".$modele.".modules.php"); if (file_exists($file)) { $filefound = 1; @@ -139,16 +139,16 @@ if ($action == 'set_SUPPLIER_PROPOSAL_FREE_TEXT') if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL') { - $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; + if (!$res > 0) $error++; - if (!$error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (!$error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } // Activate a model @@ -160,11 +160,11 @@ if ($action == 'set') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PROPOSAL_ADDON_PDF', $conf->entity); + if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$value") dolibarr_del_const($db, 'SUPPLIER_PROPOSAL_ADDON_PDF', $conf->entity); } } elseif ($action == 'setdoc') { - if (dolibarr_set_const($db, "SUPPLIER_PROPOSAL_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + if (dolibarr_set_const($db, "SUPPLIER_PROPOSAL_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF = $value; } @@ -248,13 +248,13 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module - print ''; - $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + // Show example of numbering module + print ''; + $tmp = $module->getExample(); + if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; print ''; if ($conf->global->SUPPLIER_PROPOSAL_ADDON == "$file") @@ -274,16 +274,16 @@ foreach ($dirmodels as $reldir) $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $nextval = $module->getNextValue($mysoc, $supplier_proposal); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip .= ''.$langs->trans("NextValue").': '; - if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') - $nextval = $langs->trans($nextval); - $htmltooltip .= $nextval.'
'; - } else { - $htmltooltip .= $langs->trans($module->error).'
'; - } - } + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip .= ''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip .= $nextval.'
'; + } else { + $htmltooltip .= $langs->trans($module->error).'
'; + } + } print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -342,82 +342,82 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $realpath = $reldir."core/modules/supplier_proposal".$valdir; - $dir = dol_buildpath($realpath); + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/supplier_proposal".$valdir; + $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ""; - if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ""; + if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"), 'on'); + } else { + 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")); - if ($module->type == 'pdf') - { - $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - } - $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + // Info + $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("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; - $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $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); @@ -427,28 +427,28 @@ foreach ($dirmodels as $reldir) $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'bill').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'bill').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -482,11 +482,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnSupplierProposal"), $la $variablename = 'SUPPLIER_PROPOSAL_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { - print ''; + print ''; } else { - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); - print $doleditor->Create(); + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + print $doleditor->Create(); } print ''; print ''; @@ -508,23 +508,23 @@ print ''; if ($conf->banque->enabled) { - print ''; - print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; - if (!empty($conf->use_javascript_ajax)) - { - print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL'); - } else { - if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL)) - { - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } else { - print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; - } - } - print ''; + print ''; + print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; + if (!empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL'); + } else { + if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL)) + { + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + } else { + print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; + } + } + print ''; } else { - print ''; - print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').''; + print ''; + print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '.$langs->trans('NotAvailable').''; } print ''; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index d84779c7477..ca12e4dfaa4 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -84,9 +84,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 7017bebf61f..97cf92883f9 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -85,9 +85,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -100,9 +100,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -112,10 +112,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 60de87d2d2e..6d84b4a0e2d 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -109,8 +109,8 @@ if ($action == 'set') $activeModules = $newActiveModules; - dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity - dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); + dolibarr_del_const($db, 'SYSLOG_HANDLERS', -1); // To be sure ther is not a setup into another entity + dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine', 0, '', 0); // Check configuration foreach ($activeModules as $modulename) { @@ -213,7 +213,7 @@ foreach ($syslogModules as $moduleName) print ' '; print $module->getName(); if ($moduleName == 'mod_syslog_syslog') { - if (! $module->isActive()) { + if (!$module->isActive()) { $langs->load("errors"); print $form->textwithpicto('', $langs->trans("ErrorPHPNeedModule", 'SysLog')); } @@ -226,22 +226,22 @@ foreach ($syslogModules as $moduleName) { foreach ($setuparray as $option) { - $tmpoption = $option['constant']; - if (!empty($tmpoption)) - { - if (isset($_POST[$tmpoption])) $value = $_POST[$tmpoption]; - elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; - } else $value = (isset($option['default']) ? $option['default'] : ''); + $tmpoption = $option['constant']; + if (!empty($tmpoption)) + { + if (isset($_POST[$tmpoption])) $value = $_POST[$tmpoption]; + elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; + } else $value = (isset($option['default']) ? $option['default'] : ''); print $option['name'].': '; if (!empty($option['example'])) print '
'.$langs->trans("Example").': '.$option['example']; if ($option['constant'] == 'SYSLOG_FILE' && preg_match('/^DOL_DATA_ROOT\/[^\/]*$/', $value)) { - $filelogparam = ' ('; - $filelogparam .= $langs->trans('Download'); - $filelogparam .= $filelog.')'; - print $filelogparam; + $filelogparam = ' ('; + $filelogparam .= $langs->trans('Download'); + $filelogparam .= $filelog.')'; + print $filelogparam; } } } diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index bbac6bdfe0c..460e568501b 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -188,25 +188,25 @@ print '
'; $showpromotemessage = 1; if ($showpromotemessage) { - $tmp = versiondolibarrarray(); - if (is_numeric($tmp[2])) // Not alpha, beta or rc - { - print '
'; - print '
'; + $tmp = versiondolibarrarray(); + if (is_numeric($tmp[2])) // Not alpha, beta or rc + { + print '
'; + print '
'; - if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0)) - { - print $langs->trans("TitleExampleForMajorRelease").':
'; - print ''; - } else { - print $langs->trans("TitleExampleForMaintenanceRelease").':
'; - print ''; - } - } + if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0)) + { + print $langs->trans("TitleExampleForMajorRelease").':
'; + print ''; + } else { + print $langs->trans("TitleExampleForMaintenanceRelease").':
'; + print ''; + } + } } // End of page diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 683fc3c4f3a..00020845bde 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -119,7 +119,7 @@ if (!$base) print ''.$obj->Name.''; print ''.$obj->Engine.''; if (isset($obj->Engine) && $obj->Engine == "MyISAM") { - print ''.$langs->trans("Convert").' InnoDb'; + print ''.$langs->trans("Convert").' InnoDb'; } else { print ' '; } diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 6b08fc4fe8f..8681efa08ef 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -77,7 +77,7 @@ if (!count($listofvars) && !count($listofstatus)) foreach ($arraylist as $listname) { print '
'; - print '
'; + print '
'; print ''; print ''; print ''; diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 41c8dcbd198..24a3f2ca55f 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -48,9 +48,9 @@ $version = '0.0'; if ($action == 'getlastversion') { - $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); - //var_dump($result['content']); - $sfurl = simplexml_load_string($result['content']); + $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); + //var_dump($result['content']); + $sfurl = simplexml_load_string($result['content']); } @@ -74,43 +74,43 @@ print ''; + } + $out .= '
'.$langs->trans("Parameters").'
'.$langs->trans("CurrentVersion").' ('.$langs->tr // If current version differs from last upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) { - // Compare version with last install database version (upgrades never occured) - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); + // Compare version with last install database version (upgrades never occured) + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); } else { - // Compare version with last upgrade database version - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); + // Compare version with last upgrade database version + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); } if (function_exists('curl_init')) { - $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; - print '     -     '; - if ($action == 'getlastversion') - { - if ($sfurl) - { - while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) - { - $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); - //var_dump($newversionarray);var_dump($versionarray); - if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; - } - $i++; - } + $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; + print '     -     '; + if ($action == 'getlastversion') + { + if ($sfurl) + { + while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) + { + $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); + //var_dump($newversionarray);var_dump($versionarray); + if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; + } + $i++; + } - // Show version - print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; - } else { - print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; - } - } else { - print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; - } + // Show version + print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; + } else { + print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; + } + } else { + print $langs->trans("LastStableVersion").' : '.$langs->trans("Check").''; + } } // Now show link to the changelog @@ -168,7 +168,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S { $shmoparray = dol_listshmop(); - print '
'; + print '
'; print ''; print ''; print ''; @@ -280,8 +280,8 @@ $configfileparameters = array( 'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"), '?dolibarr_main_document_root_alt' => $langs->trans("DocumentRootServer").' (alt)', 'dolibarr_main_data_root' => $langs->trans("DataRootServer"), - 'dolibarr_main_instance_unique_id' => $langs->trans("InstanceUniqueID"), - 'separator1' => '', + 'dolibarr_main_instance_unique_id' => $langs->trans("InstanceUniqueID"), + 'separator1' => '', 'dolibarr_main_db_host' => $langs->trans("DatabaseServer"), 'dolibarr_main_db_port' => $langs->trans("DatabasePort"), 'dolibarr_main_db_name' => $langs->trans("DatabaseName"), @@ -293,7 +293,7 @@ $configfileparameters = array( '?dolibarr_main_db_prefix' => $langs->trans("Prefix"), 'separator2' => '', 'dolibarr_main_authentication' => $langs->trans("AuthenticationMode"), - '?multicompany_transverse_mode'=> $langs->trans("MultiCompanyMode"), + '?multicompany_transverse_mode'=> $langs->trans("MultiCompanyMode"), 'separator'=> '', '?dolibarr_main_auth_ldap_login_attribute' => 'dolibarr_main_auth_ldap_login_attribute', '?dolibarr_main_auth_ldap_host' => 'dolibarr_main_auth_ldap_host', @@ -349,8 +349,8 @@ 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 ? + if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) + continue; // We discard parameters starting with ? } if (strpos($newkey, 'separator') !== false && $lastkeyshown == 'separator') continue; @@ -387,14 +387,14 @@ foreach ($configfileparameters as $key => $value) ++$i; } } elseif ($newkey == 'dolibarr_main_instance_unique_id') { - //print $conf->file->instance_unique_id; - global $dolibarr_main_cookie_cryptkey; - $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey - print $valuetoshow; - if (empty($valuetoshow)) { - print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); - } - print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; + //print $conf->file->instance_unique_id; + global $dolibarr_main_cookie_cryptkey; + $valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey; // Use $dolibarr_main_instance_unique_id first then $dolibarr_main_cookie_cryptkey + print $valuetoshow; + if (empty($valuetoshow)) { + print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id'); + } + print '   ('.$langs->trans("HashForPing").'='.md5('dolibarr'.$valuetoshow).')'; } elseif ($newkey == 'dolibarr_main_prod') { print ${$newkey}; @@ -410,7 +410,7 @@ foreach ($configfileparameters as $key => $value) print img_warning($langs->trans('SwitchThisForABetterSecurity', 0)); } } else { - print ${$newkey}; + print ${$newkey}; } if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')'; print ""; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index c8878b6b69f..a94a78a9794 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; $langs->load("admin"); if (!$user->admin) - accessforbidden(); + accessforbidden(); $error = 0; @@ -57,13 +57,13 @@ print ''."\n"; print '
'.$langs->trans("LanguageFilesCachedIntoShmopSharedMemory").'
'.$langs->trans("VersionLastUpgrade") print '
'.$langs->trans("VersionProgram").''.DOL_VERSION; // If current version differs from last upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) { - // Compare version with last install database version (upgrades never occured) - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) - print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); + // Compare version with last install database version (upgrades never occured) + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_INSTALL) + print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_INSTALL)); } else { - // Compare version with last upgrade database version - if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) - print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); + // Compare version with last upgrade database version + if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) + print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); } print '
'; @@ -96,24 +96,24 @@ print $langs->trans("MakeIntegrityAnalysisFrom").':
'; print ''."\n"; if (dol_is_file($xmlfile)) { - print ' '.$langs->trans("LocalSignature").' = '; - print ''; - print '
'; + print ' '.$langs->trans("LocalSignature").' = '; + print ''; + print '
'; } else { - print ' '.$langs->trans("LocalSignature").' = '; - print ''; - print ' ('.$langs->trans("AvailableOnlyOnPackagedVersions").')'; - print '
'; + print ' '.$langs->trans("LocalSignature").' = '; + print ''; + print ' ('.$langs->trans("AvailableOnlyOnPackagedVersions").')'; + print '
'; } print ''."\n"; if ($enableremotecheck) { - print ' '.$langs->trans("RemoteSignature").' = '; - print '
'; + print ' '.$langs->trans("RemoteSignature").' = '; + print '
'; } else { - print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote; - if (!GETPOST('xmlremote')) print ' ('.$langs->trans("FeatureAvailableOnlyOnStable").')'; - print '
'; + print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote; + if (!GETPOST('xmlremote')) print ' ('.$langs->trans("FeatureAvailableOnlyOnStable").')'; + print '
'; } print '
'; print ''; @@ -122,275 +122,275 @@ print '
'; if (GETPOST('target') == 'local') { - if (dol_is_file($xmlfile)) - { - // If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before - if (preg_match('/\.zip$/i', $xmlfile)) { - dol_mkdir($conf->admin->dir_temp); - $xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile); - $result = dol_uncompress($xmlfile, $conf->admin->dir_temp); - if (empty($result['error'])) { - $xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew); - } else { - print $langs->trans('FailedToUncompressFile').': '.$xmlfile; - $error++; - } - } - $xml = simplexml_load_file($xmlfile); - } else { - print $langs->trans('XmlNotFound').': '.$xmlfile; - $error++; - } + if (dol_is_file($xmlfile)) + { + // If file is a zip file (.../filelist-x.y.z.xml.zip), we uncompress it before + if (preg_match('/\.zip$/i', $xmlfile)) { + dol_mkdir($conf->admin->dir_temp); + $xmlfilenew = preg_replace('/\.zip$/i', '', $xmlfile); + $result = dol_uncompress($xmlfile, $conf->admin->dir_temp); + if (empty($result['error'])) { + $xmlfile = $conf->admin->dir_temp.'/'.basename($xmlfilenew); + } else { + print $langs->trans('FailedToUncompressFile').': '.$xmlfile; + $error++; + } + } + $xml = simplexml_load_file($xmlfile); + } else { + print $langs->trans('XmlNotFound').': '.$xmlfile; + $error++; + } } if (GETPOST('target') == 'remote') { - $xmlarray = getURLContent($xmlremote); + $xmlarray = getURLContent($xmlremote); - // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) - if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') - { - $xmlfile = $xmlarray['content']; - //print "xmlfilestart".$xmlfile."xmlfileend"; - $xml = simplexml_load_string($xmlfile); - } else { - $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; - setEventMessages($errormsg, null, 'errors'); - $error++; - } + // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) + if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') + { + $xmlfile = $xmlarray['content']; + //print "xmlfilestart".$xmlfile."xmlfileend"; + $xml = simplexml_load_string($xmlfile); + } else { + $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; + setEventMessages($errormsg, null, 'errors'); + $error++; + } } if (!$error && $xml) { - $checksumconcat = array(); - $file_list = array(); - $out = ''; + $checksumconcat = array(); + $file_list = array(); + $out = ''; - // Forced constants - if (is_object($xml->dolibarr_constants[0])) - { - $out .= load_fiche_titre($langs->trans("ForcedConstants")); + // Forced constants + if (is_object($xml->dolibarr_constants[0])) + { + $out .= load_fiche_titre($langs->trans("ForcedConstants")); $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; + $out .= '
#'.$langs->trans("Constant").''.$langs->trans("ExpectedValue").''.$langs->trans("Value").'
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; - $i = 0; - foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement - { - $constname = $constant['name']; - $constvalue = (string) $constant; - $constvalue = (empty($constvalue) ? '0' : $constvalue); - // Value found - $value = ''; - if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; - $valueforchecksum = (empty($value) ? '0' : $value); + $i = 0; + foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement + { + $constname = $constant['name']; + $constvalue = (string) $constant; + $constvalue = (empty($constvalue) ? '0' : $constvalue); + // Value found + $value = ''; + if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; + $valueforchecksum = (empty($value) ? '0' : $value); - $checksumconcat[] = $valueforchecksum; + $checksumconcat[] = $valueforchecksum; - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } - if ($i == 0) - { - $out .= ''; - } - $out .= '
#'.$langs->trans("Constant").''.$langs->trans("ExpectedValue").''.$langs->trans("Value").'
'.$i.''.dol_escape_htmltag($constname).''.dol_escape_htmltag($constvalue).''.dol_escape_htmltag($valueforchecksum).'
'.$i.''.dol_escape_htmltag($constname).''.dol_escape_htmltag($constvalue).''.dol_escape_htmltag($valueforchecksum).'
'.$langs->trans("None").'
'; - $out .= '
'; + if ($i == 0) + { + $out .= '
'.$langs->trans("None").'
'; + $out .= '
'; - $out .= '
'; - } + $out .= '
'; + } - // Scan htdocs - if (is_object($xml->dolibarr_htdocs_dir[0])) - { - //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; - $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); + // Scan htdocs + if (is_object($xml->dolibarr_htdocs_dir[0])) + { + //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; + $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); - // Defined qualified files (must be same than into generate_filelist_xml.php) - $regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; - $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs - $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); + // Defined qualified files (must be same than into generate_filelist_xml.php) + $regextoinclude = '\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; + $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs + $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); - // Fill file_list with files in signature, new files, modified files - $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list - // Complete with list of new files - foreach ($scanfiles as $keyfile => $valfile) - { - $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); - if (!in_array($tmprelativefilename, $file_list['insignature'])) - { - $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file - $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); - } - } + // Fill file_list with files in signature, new files, modified files + $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list + // Complete with list of new files + foreach ($scanfiles as $keyfile => $valfile) + { + $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); + if (!in_array($tmprelativefilename, $file_list['insignature'])) + { + $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file + $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); + } + } - // Files missings - $out .= load_fiche_titre($langs->trans("FilesMissing")); + // Files missings + $out .= load_fiche_titre($langs->trans("FilesMissing")); $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); - if (is_array($tmpfilelist) && count($tmpfilelist)) - { - $i = 0; - foreach ($tmpfilelist as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - } else { - $out .= ''; - } - $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedSize").''.$langs->trans("ExpectedChecksum").'
'.$i.''.dol_escape_htmltag($file['filename']).''; - if (!empty($file['expectedsize'])) $out .= dol_print_size($file['expectedsize']); - $out .= ''.dol_escape_htmltag($file['expectedmd5']).'
'.$langs->trans("None").'
'; - $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); + if (is_array($tmpfilelist) && count($tmpfilelist)) + { + $i = 0; + foreach ($tmpfilelist as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + } else { + $out .= ''; + } + $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedSize").''.$langs->trans("ExpectedChecksum").'
'.$i.''.dol_escape_htmltag($file['filename']).''; + if (!empty($file['expectedsize'])) $out .= dol_print_size($file['expectedsize']); + $out .= ''.dol_escape_htmltag($file['expectedmd5']).'
'.$langs->trans("None").'
'; + $out .= '
'; - $out .= '
'; + $out .= '
'; - // Files modified - $out .= load_fiche_titre($langs->trans("FilesModified")); + // Files modified + $out .= load_fiche_titre($langs->trans("FilesModified")); - $totalsize = 0; + $totalsize = 0; $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); - if (is_array($tmpfilelist2) && count($tmpfilelist2)) - { - $i = 0; - foreach ($tmpfilelist2 as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); - $totalsize += $size; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } else { - $out .= ''; - } - $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("ExpectedSize").''.$langs->trans("CurrentSize").''.$langs->trans("DateModification").'
'.$i.''.dol_escape_htmltag($file['filename']).''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''; - if ($file['expectedsize']) $out .= dol_print_size($file['expectedsize']); - $out .= ''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'; - $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); + if (is_array($tmpfilelist2) && count($tmpfilelist2)) + { + $i = 0; + foreach ($tmpfilelist2 as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); + $totalsize += $size; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } else { + $out .= ''; + } + $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("ExpectedSize").''.$langs->trans("CurrentSize").''.$langs->trans("DateModification").'
'.$i.''.dol_escape_htmltag($file['filename']).''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''; + if ($file['expectedsize']) $out .= dol_print_size($file['expectedsize']); + $out .= ''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'; + $out .= '
'; - $out .= '
'; + $out .= '
'; - // Files added - $out .= load_fiche_titre($langs->trans("FilesAdded")); + // Files added + $out .= load_fiche_titre($langs->trans("FilesAdded")); - $totalsize = 0; + $totalsize = 0; $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''."\n"; - $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); - if (is_array($tmpfilelist3) && count($tmpfilelist3)) - { - $i = 0; - foreach ($tmpfilelist3 as $file) - { - $i++; - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); - $totalsize += $size; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } - $out .= ''; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= "\n"; - } else { - $out .= ''; - } - $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("Size").''.$langs->trans("DateModification").'
'.$i.''.dol_escape_htmltag($file['filename']); - if (!preg_match('/^win/i', PHP_OS)) { - $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] - $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); - } - $out .= ''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'; - $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; + $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); + if (is_array($tmpfilelist3) && count($tmpfilelist3)) + { + $i = 0; + foreach ($tmpfilelist3 as $file) + { + $i++; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); + $totalsize += $size; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; + } else { + $out .= ''; + } + $out .= '
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("Size").''.$langs->trans("DateModification").'
'.$i.''.dol_escape_htmltag($file['filename']); + if (!preg_match('/^win/i', PHP_OS)) { + $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] + $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); + } + $out .= ''.dol_escape_htmltag($file['expectedmd5']).''.dol_escape_htmltag($file['md5']).''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'; + $out .= '
'; - // Show warning - if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) - { - setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); - } - } else { - print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile; - $error++; - } + // Show warning + if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) + { + setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); + } + } else { + print 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile; + $error++; + } - // Scan scripts - /* + // Scan scripts + /* if (is_object($xml->dolibarr_script_dir[0])) { $file_list = array(); @@ -398,44 +398,44 @@ if (!$error && $xml) }*/ - asort($checksumconcat); // Sort list of checksum - //var_dump($checksumconcat); - $checksumget = md5(join(',', $checksumconcat)); - $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); + asort($checksumconcat); // Sort list of checksum + //var_dump($checksumconcat); + $checksumget = md5(join(',', $checksumconcat)); + $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); - /*var_dump(count($file_list['added'])); + /*var_dump(count($file_list['added'])); var_dump($checksumget); var_dump($checksumtoget); var_dump($checksumget == $checksumtoget);*/ - $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); - if ($checksumget == $checksumtoget) - { - if (count($file_list['added'])) - { - $resultcode = 'warning'; - $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; - $outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; - } else { - $resultcode = 'ok'; - $resultcomment = 'Success'; - $outcurrentchecksum = ''.$checksumget.''; - } - } else { - $resultcode = 'error'; - $resultcomment = 'Error'; - $outcurrentchecksum = ''.$checksumget.''; - } + $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); + if ($checksumget == $checksumtoget) + { + if (count($file_list['added'])) + { + $resultcode = 'warning'; + $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; + $outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; + } else { + $resultcode = 'ok'; + $resultcomment = 'Success'; + $outcurrentchecksum = ''.$checksumget.''; + } + } else { + $resultcode = 'error'; + $resultcomment = 'Error'; + $outcurrentchecksum = ''.$checksumget.''; + } - print load_fiche_titre($langs->trans("GlobalChecksum")).'
'; - print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'
'; - print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; + print load_fiche_titre($langs->trans("GlobalChecksum")).'
'; + print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'
'; + print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; - print '
'; - print '
'; + print '
'; + print '
'; - // Output detail - print $out; + // Output detail + print $out; } // End of page diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 06003068bb2..2bbe919c72e 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -94,10 +94,10 @@ if ($db->type == 'pgsql') { // Check option standard_conforming_strings is on $paramarray = $db->getServerParametersValues('standard_conforming_strings'); - // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) - // { - // $langs->load("errors"); - // } + // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) + // { + // $langs->load("errors"); + // } } print '
'; diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 28dcb6641ef..8347a9a6e4c 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -270,13 +270,13 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print ''; // sort list -if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc"); if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc"); diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index d9901818c92..80c4556c35a 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -87,7 +87,7 @@ $test = empty($conf->debugbar->enabled); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); else { print img_picto('', 'warning').' '.$langs->trans("ModuleActivated", $langs->transnoentities("DebugBar")); - //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; + //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } print '
'; diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 9f1766a5d22..11d0dbc49cf 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -275,7 +275,7 @@ function getActivatedExtensions() // For compatibility with LF (Line Feed) if (empty($configLines) || count($configLines) < 2) { - $configLines = explode("\n", $content); + $configLines = explode("\n", $content); } $extensions = array(); @@ -428,5 +428,5 @@ function getResultColumn($name, array $activated, array $loaded, array $function $html .= $result ? $langs->trans("PHPSupport".$name) : $langs->trans("ErrorPHPDoesNotSupport".$name); $html .= ""; - return $html; + return $html; } diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 05cf9dd1b8e..cb708090386 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -116,7 +116,7 @@ $test = empty($conf->debugbar->enabled); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); else { print img_picto('', 'error').' '.$langs->trans("ModuleActivatedDoNotUseInProduction", $langs->transnoentities("DebugBar")); - //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; + //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } print '
'; print '
'; diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 50ff514c6a7..121ded4f578 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -32,7 +32,7 @@ $langs->loadLangs(array("admin", "ticket")); // Access control if (!$user->admin) { - accessforbidden(); + accessforbidden(); } // Parameters @@ -50,62 +50,62 @@ $error = 0; if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { - if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); - else dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); + if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); + else dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); } 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)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); + if (!empty($topic_interface)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); - if (!empty($text_home)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); + if (!empty($text_home)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); - if (!empty($text_help)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); + if (!empty($text_help)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); - if (!empty($mail_new_ticket)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); + if (!empty($mail_new_ticket)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } - $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); - if (!empty($url_interface)) { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } + $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); + if (!empty($url_interface)) { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } $param_public_notification_new_message_default_email = GETPOST('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', $param_public_notification_new_message_default_email, 'chaine', 0, '', $conf->entity); @@ -115,38 +115,38 @@ if ($action == 'setvar') { } if ($action == 'setvarother') { - $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } - $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } + $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } $param_show_module_logo = GETPOST('TICKET_SHOW_COMPANY_LOGO', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); if (!$res > 0) { - $error++; + $error++; } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - } + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } } @@ -181,15 +181,15 @@ print dol_get_fiche_end(); $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 .= ''; + // Button off, click to enable + $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 .= ''; + // Button on, click to disable + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml .= ''; } print $enabledisablehtml; print ''; @@ -198,37 +198,37 @@ print '

'; if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - if (empty($conf->use_javascript_ajax)) { - print '
'; - print ''; - print ''; - } + if (empty($conf->use_javascript_ajax)) { + print ''; + print ''; + print ''; + } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + print '
'.$langs->trans("Parameters").''; - print ''; - print '
'; + print ''; + print ''; + print ''; + print ''; - // Check if email exists - print ''; - print ''; - print ''; - print ''; + // Check if email exists + print ''; + print ''; + print ''; + print ''; - /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // Show logo for module print ''; @@ -246,145 +246,145 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print ''; }*/ - // Show logo for company - print ''; - print ''; - print ''; - print ''; + // Show logo for company + print ''; + print ''; + print ''; + print ''; - // Also send to main email address - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - print ''; - print ''; - print ''; - print ''; - } + // Also send to main email address + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + print ''; + print ''; + print ''; + print ''; + } - if (!$conf->use_javascript_ajax) { - print ''; - print ''; - } + if (!$conf->use_javascript_ajax) { + print ''; + print ''; + } - print '
'.$langs->trans("Parameters").''; + print ''; + print '
'.$langs->trans("TicketsEmailMustExist").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); - print '
'.$langs->trans("TicketsEmailMustExist").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowModuleLogo") . '
'.$langs->trans("TicketsShowCompanyLogo").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); - print '
'.$langs->trans("TicketsShowCompanyLogo").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); + print '
'.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); - print '
'.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print '
'; - print '
'; - print '
'; + print ''; + print '
'; + print '
'; - if (!$conf->use_javascript_ajax) { - print ''; - } + if (!$conf->use_javascript_ajax) { + print ''; + } - // Admin var of module - print load_fiche_titre($langs->trans("TicketParamMail")); + // Admin var of module + print load_fiche_titre($langs->trans("TicketParamMail")); - print '
'; - print ''; + print '
'; + print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { - print ''; - print ''; - print "\n"; - } + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { + print ''; + print ''; + print "\n"; + } - // Interface topic - $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; - print ''; - print ''; - print ''; + // Interface topic + $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; + print ''; + print ''; + print ''; - // Texte d'accueil homepage - $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); - print ''; - print ''; + // Texte d'accueil homepage + $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); + print ''; + print ''; - // 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 ''; - print ''; + // 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 ''; + print ''; - // Activate email creation to user - print ''; - print ''; - print ''; - print ''; + // Activate email creation to user + print ''; + print ''; + print ''; + print ''; - // 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 ''; - print ''; + // 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 ''; + print ''; - // Url public interface - $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; - print ''; - print ''; - print ''; + // Url public interface + $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + print ''; + print ''; + print ''; // Activate email notification when a new message is added - print ''; + print ''; print ''; // Send notification when a new message is added to a email if a user is not assigned to the ticket - print ''; + print ''; print ''; print '
'.$langs->trans("Parameter").'
'.$langs->trans("Parameter").'
'.$langs->trans("TicketCkEditorEmailNotActivated").'
'.$langs->trans("TicketCkEditorEmailNotActivated").'
'.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; - print ''; - print ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); - print '
'.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); + print '
'.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; - print ''; - 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 ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); - print '
'.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").''; + print ''; + 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 ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); + print '
'.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; - print ''; - 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 ''; - print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); - print '
'.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").''; + print ''; + 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 ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); + print '
'.$langs->trans("TicketsDisableCustomerEmail").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); - print '
'.$langs->trans("TicketsDisableCustomerEmail").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); + print '
'.$langs->trans("TicketNewEmailBodyLabel").''; - print ''; - 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 ''; - print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); - print '
'.$langs->trans("TicketNewEmailBodyLabel").''; + print ''; + 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 ''; + print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); + print '
'.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; - print ''; - print ''; - print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); - print '
'.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketsPublicNotificationNewMessage") . '
'.$langs->trans("TicketsPublicNotificationNewMessage").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED'); @@ -399,9 +399,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
' . $langs->trans("TicketPublicNotificationNewMessageDefaultEmail") . ''; + print '
'.$langs->trans("TicketPublicNotificationNewMessageDefaultEmail").''; print ''; - print ''; print $form->textwithpicto('', $langs->trans("TicketPublicNotificationNewMessageDefaultEmailHelp"), 1, 'help'); @@ -410,9 +410,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '
'; print '
'; - print '
'; + print '
'; - print ''; + print ''; } // End of page diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 5e990709d19..4128c0d7075 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -243,7 +243,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print ''; print ''; - print ''; + print ''; print ''; print '
'; print ''; @@ -304,7 +304,7 @@ if (in_array($type, array('mysql', 'mysqli'))) { print '
'; print '
'.$langs->trans('ExportStructure').''; - print ''; + print ''; print ''; print '
'; print '
'; diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 224bbc14b56..91fbb81b90e 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -58,8 +58,8 @@ jQuery(document).ready(function() { jQuery("#postgresql_options").show(); }); }); @@ -97,26 +97,26 @@ print $langs->trans("RestoreDesc3", $dolibarr_main_db_name).'

';
trans("ImportMethod"); ?> + if (in_array($type, array('mysql', 'mysqli'))) + { + ?>
/>
+ } elseif (in_array($type, array('pgsql'))) + { + ?>
/>
+ } else { + print 'No method available with database '.$label; + } + ?>
@@ -128,8 +128,8 @@ print $langs->trans("RestoreDesc3", $dolibarr_main_db_name).'

'; '; - print ''.$langs->trans('RestoreMySQL').''; + print '
'; + print ''.$langs->trans('RestoreMySQL').''; print '
'; // Parameteres execution $command = $db->getPathOfRestore(); @@ -152,46 +152,46 @@ if (in_array($type, array('mysql', 'mysqli'))) print '
'; print ajax_autoselect('restorecommand'); - if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { - print '
'.$langs->trans("UnHidePassword").''; - } - //else print '
'.$langs->trans("HidePassword").''; - print '
'; - print '
'; + if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) { + print '
'.$langs->trans("UnHidePassword").''; + } + //else print '
'.$langs->trans("HidePassword").''; + print '
'; + print ''; } elseif (in_array($type, array('pgsql'))) { - print '
'; - print 'Restore PostgreSQL'; - print '
'; - // Parameteres execution - $command = $db->getPathOfRestore(); - if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command + print '
'; + print 'Restore PostgreSQL'; + print '
'; + // Parameteres execution + $command = $db->getPathOfRestore(); + if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command - $param = " -d ".$dolibarr_main_db_name; - $param .= " -h ".$dolibarr_main_db_host; - if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port; - $param .= " -U ".$dolibarr_main_db_user; - $paramcrypted = $param; - $paramclear = $param; - /*if (! empty($dolibarr_main_db_pass)) + $param = " -d ".$dolibarr_main_db_name; + $param .= " -h ".$dolibarr_main_db_host; + if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port; + $param .= " -U ".$dolibarr_main_db_user; + $paramcrypted = $param; + $paramclear = $param; + /*if (! empty($dolibarr_main_db_pass)) { $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass); $paramclear.=" -p".$dolibarr_main_db_pass; }*/ - $paramcrypted .= " -W"; - $paramclear .= " -W"; - // With psql: - $paramcrypted .= " -f"; - $paramclear .= " -f"; + $paramcrypted .= " -W"; + $paramclear .= " -W"; + // With psql: + $paramcrypted .= " -f"; + $paramclear .= " -f"; - echo $langs->trans("ImportPostgreSqlDesc"); - print '
'; - print '
'; - print ajax_autoselect('restorecommand'); - //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
'.$langs->trans("UnHidePassword").''; - //else print '
'.$langs->trans("HidePassword").''; - print '
'; - print '
'; + echo $langs->trans("ImportPostgreSqlDesc"); + print '
'; + print '
'; + print ajax_autoselect('restorecommand'); + //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
'.$langs->trans("UnHidePassword").''; + //else print '
'.$langs->trans("HidePassword").''; + print '
'; + print '
'; } print '
'; diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 7ab26f6f6e0..0c3679c62fa 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -49,9 +49,9 @@ if (!$user->admin) accessforbidden(); if ($file && !$what) { - //print DOL_URL_ROOT.'/dolibarr_export.php'; + //print DOL_URL_ROOT.'/dolibarr_export.php'; header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : '')); - exit; + exit; } $errormsg = ''; @@ -83,16 +83,16 @@ $_SESSION["commandbackupresult"] = ''; $ExecTimeLimit = 600; if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); } $MemoryLimit = 0; if (!empty($MemoryLimit)) { - @ini_set('memory_limit', $MemoryLimit); + @ini_set('memory_limit', $MemoryLimit); } $form = new Form($db); @@ -122,51 +122,51 @@ $utils = new Utils($db); // MYSQL if ($what == 'mysql') { - $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg - $cmddump = dol_sanitizePathName($cmddump); + $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg + $cmddump = dol_sanitizePathName($cmddump); - if (!empty($dolibarr_main_restrict_os_commands)) - { - $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); - dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - $basenamecmddump = basename($cmddump); - if (!in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command - { - $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); - } - } + if (!empty($dolibarr_main_restrict_os_commands)) + { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump = basename($cmddump); + if (!in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); + } + } - if (!$errormsg && $cmddump) - { - dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); - } + if (!$errormsg && $cmddump) + { + dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); + } - if (!$errormsg) - { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; - } + if (!$errormsg) + { + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + } } // MYSQL NO BIN if ($what == 'mysqlnobin') { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; } // POSTGRESQL if ($what == 'postgresql') { - $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg - $cmddump = dol_sanitizePathName($cmddump); + $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg + $cmddump = dol_sanitizePathName($cmddump); - /* Not required, the command is output on screen but not ran for pgsql + /* Not required, the command is output on screen but not ran for pgsql if (! empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); @@ -178,20 +178,20 @@ if ($what == 'postgresql') } } */ - if (!$errormsg && $cmddump) - { - dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); - } + if (!$errormsg && $cmddump) + { + dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); + } - if (!$errormsg) - { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); - $errormsg = $utils->error; - $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; - $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; - } + if (!$errormsg) + { + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $errormsg = $utils->error; + $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; + $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; + } - $what = ''; // Clear to show message to run command + $what = ''; // Clear to show message to run command } @@ -200,20 +200,20 @@ if ($errormsg) setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); $resultstring = ''; - $resultstring .= '
'.$langs->trans("Error")." : ".$errormsg.'
'; + $resultstring .= '
'.$langs->trans("Error")." : ".$errormsg.'
'; - $_SESSION["commandbackupresult"] = $resultstring; + $_SESSION["commandbackupresult"] = $resultstring; } else { if ($what) { - setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); + setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); - $resultstring = '
'; - $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
'; - $resultstring .= $langs->trans("YouCanDownloadBackupFile"); - $resultstring .= '
'; + $resultstring = '
'; + $resultstring .= $langs->trans("BackupFileSuccessfullyCreated").'.
'; + $resultstring .= $langs->trans("YouCanDownloadBackupFile"); + $resultstring .= '
'; - $_SESSION["commandbackupresult"] = $resultstring; + $_SESSION["commandbackupresult"] = $resultstring; } /*else { diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index 28eaa2d9d54..590ff276831 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -59,8 +59,8 @@ $errormsg = ''; if ($action == 'delete') { - $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); - $filepath = $conf->admin->dir_output.'/'.$filerelative; + $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); + $filepath = $conf->admin->dir_output.'/'.$filerelative; $ret = dol_delete_file($filepath, 1); if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filerelative), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filerelative), null, 'errors'); @@ -76,16 +76,16 @@ if ($action == 'delete') $ExecTimeLimit = 1800; // 30mn if (!empty($ExecTimeLimit)) { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); } $MemoryLimit = 0; if (!empty($MemoryLimit)) { - @ini_set('memory_limit', $MemoryLimit); + @ini_set('memory_limit', $MemoryLimit); } $form = new Form($db); @@ -113,54 +113,54 @@ $utils = new Utils($db); if ($compression == 'zip') { $file .= '.zip'; - $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i'); - if ($ret < 0) - { - if ($ret == -2) { - $langs->load("errors"); - $errormsg = $langs->trans("ErrNoZipEngine"); - } else { - $langs->load("errors"); - $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); - } - } + $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i'); + if ($ret < 0) + { + if ($ret == -2) { + $langs->load("errors"); + $errormsg = $langs->trans("ErrNoZipEngine"); + } else { + $langs->load("errors"); + $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); + } + } } elseif (in_array($compression, array('gz', 'bz'))) { $userlogin = ($user->login ? $user->login : 'unknown'); $outputfile = $conf->admin->dir_temp.'/export_files.'.$userlogin.'.out'; // File used with popen method - $file .= '.tar'; - // We also exclude '/temp/' dir and 'documents/admin/documents' - $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); + $file .= '.tar'; + // We also exclude '/temp/' dir and 'documents/admin/documents' + $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); - $result = $utils->executeCLI($cmd, $outputfile); + $result = $utils->executeCLI($cmd, $outputfile); - $retval = $result['error']; - if ($result['result'] || !empty($retval)) - { - $langs->load("errors"); - dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); - $errormsg = 'Error tar generation return '.$retval; - } else { - if ($compression == 'gz') - { - $cmd = "gzip -f ".$outputdir."/".$file; - } - if ($compression == 'bz') - { - $cmd = "bzip2 -f ".$outputdir."/".$file; - } + $retval = $result['error']; + if ($result['result'] || !empty($retval)) + { + $langs->load("errors"); + dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); + $errormsg = 'Error tar generation return '.$retval; + } else { + if ($compression == 'gz') + { + $cmd = "gzip -f ".$outputdir."/".$file; + } + if ($compression == 'bz') + { + $cmd = "bzip2 -f ".$outputdir."/".$file; + } - $result = $utils->executeCLI($cmd, $outputfile); + $result = $utils->executeCLI($cmd, $outputfile); - $retval = $result['error']; - if ($result['result'] || !empty($retval)) - { - $errormsg = 'Error '.$compression.' generation return '.$retval; - unlink($outputdir."/".$file); - } - } + $retval = $result['error']; + if ($result['result'] || !empty($retval)) + { + $errormsg = 'Error '.$compression.' generation return '.$retval; + unlink($outputdir."/".$file); + } + } } if ($errormsg) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 82111e0716d..00c4bdc36dd 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -76,11 +76,11 @@ $nowarray = dol_getdate($now); if (empty($date_start)) // We define date_start and date_end { - $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); + $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); } if (empty($date_end)) { - $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); + $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); } // Set $date_startmonth... $tmp = dol_getdate($date_start); @@ -104,14 +104,14 @@ $now = dol_now(); // 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 { - $date_start = -1; - $date_end = -1; - $search_code = ''; - $search_ip = ''; - $search_user = ''; - $search_desc = ''; - $search_ua = ''; - $search_prefix_session = ''; + $date_start = -1; + $date_end = -1; + $search_code = ''; + $search_ip = ''; + $search_user = ''; + $search_desc = ''; + $search_ua = ''; + $search_prefix_session = ''; } // Purge audit events @@ -144,7 +144,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) $result = $securityevent->create($user); if ($result > 0) { - $db->commit(); + $db->commit(); dol_syslog($text, LOG_WARNING); } else { $error++; @@ -219,16 +219,16 @@ if ($result) if ($date_endday) $param .= "&date_endday=".urlencode($date_endday); if ($date_endyear) $param .= "&date_endyear=".urlencode($date_endyear); - $langs->load('withdrawals'); - if ($num) - { - $center = ''.$langs->trans("Purge").''; - } + $langs->load('withdrawals'); + if ($num) + { + $center = ''.$langs->trans("Purge").''; + } print '
'; print ''; - print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); + print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); if ($action == 'purge') { diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index aedc41e0b23..d8e0a0383a2 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -37,8 +37,8 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -192,7 +192,7 @@ if ($savehandler == 'files') { if (count($listofsessions)) { - print ''.$langs->trans("PurgeSessions").''; + print ''.$langs->trans("PurgeSessions").''; } } diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index c41b43b3b48..d450b5aa888 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -48,16 +48,16 @@ if (!empty($conf->syslog->enabled)) */ if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes')) { - // Increase limit of time. Works only if we are not in safe mode - $ExecTimeLimit = 600; - if (!empty($ExecTimeLimit)) - { - $err = error_reporting(); - error_reporting(0); // Disable all errors - //error_reporting(E_ALL); - @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 - error_reporting($err); - } + // Increase limit of time. Works only if we are not in safe mode + $ExecTimeLimit = 600; + if (!empty($ExecTimeLimit)) + { + $err = error_reporting(); + error_reporting(0); // Disable all errors + //error_reporting(E_ALL); + @set_time_limit($ExecTimeLimit); // Need more than 240 on Windows 7/64 + error_reporting($err); + } require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; $utils = new Utils($db); @@ -97,9 +97,9 @@ if (!empty($conf->syslog->enabled)) $filelogparam = $filelog; if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) { - $filelogparam = ''.$filelog.''; + $filelogparam = ''.$filelog.''; } print '> '.$langs->trans("PurgeDeleteLogFile", $filelogparam); print '

'; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index a22e585f972..a96ea4e16aa 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -60,7 +60,7 @@ if ($action == 'set_default') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); + if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); } $res = true; } @@ -84,24 +84,24 @@ elseif ($action == 'setdoc') $res = true; } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } //Set hide closed customer into combox or select elseif ($action == 'sethideinactiveuser') @@ -225,104 +225,104 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $dir = dol_buildpath($reldir."core/modules/user".$valdir); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + foreach (array('', '/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/user".$valdir); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->USER_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ''; + if ($conf->global->USER_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + 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")); - if ($module->type == 'pdf') - { - $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("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + // Info + $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("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index e73e01ccbdf..dd12584b276 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -57,7 +57,7 @@ if ($action == 'set_default') $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); + if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); } $res = true; } @@ -81,24 +81,24 @@ elseif ($action == 'setdoc') $res = true; } elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + dol_print_error($db); + } } /* * View @@ -157,104 +157,104 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('', '/doc') as $valdir) - { - $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir); - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $filelist[] = $file; - } - closedir($handle); - arsort($filelist); + foreach (array('', '/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); - require_once $dir.'/'.$file; - $module = new $classname($db); + require_once $dir.'/'.$file; + $module = new $classname($db); - $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; - if ($modulequalified) - { - print ''; - print (empty($module->name) ? $name : $module->name); - print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; - print ''; + if ($modulequalified) + { + print ''; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''; - // Active - if (in_array($name, $def)) - { - print ''."\n"; - print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); - print ''; - print ''; - } else { - print ''."\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; - print ""; - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''; + } else { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ""; + } - // Defaut - print ''; - if ($conf->global->USERGROUP_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"), 'on'); - } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; - } - print ''; + // Defaut + print ''; + if ($conf->global->USERGROUP_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + 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")); - if ($module->type == 'pdf') - { - $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("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + // Info + $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("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); - print ''; + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; - // Preview - print ''; - if ($module->type == 'pdf') - { - print ''.img_object($langs->trans("Preview"), 'contract').''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); - } - print ''; + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'contract').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ''; - print "\n"; - } - } - } - } - } - } - } + print "\n"; + } + } + } + } + } + } + } } print ''; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index a8bcbcf8172..5ee707a8002 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -139,7 +139,7 @@ if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['w } // remove not available workflows (based on activated modules and global defined keys) -$workflowcodes = array_filter($workflowcodes, function ($var) { +$workflowcodes = array_filter($workflowcodes, function($var) { return $var['enabled']; }); /* diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index 22263b8b9ba..835a5485544 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -43,10 +43,10 @@ $langs->load("admin"); // Enable and test if module Api is enabled if (empty($conf->global->MAIN_MODULE_API)) { - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningModuleNotActive", 'Api').'.

'; - print $langs->trans("ToActivateModule"); - exit; + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningModuleNotActive", 'Api').'.

'; + print $langs->trans("ToActivateModule"); + exit; } @@ -61,45 +61,45 @@ $listofapis = array(); $modulesdir = dolGetModulesDirs(); foreach ($modulesdir as $dir) { - /* + /* * Search available module */ - //dol_syslog("Scan directory ".$dir." for API modules"); + //dol_syslog("Scan directory ".$dir." for API modules"); - $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) - { - $modulename = $reg[1]; + $handle = @opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg)) + { + $modulename = $reg[1]; - // Defined if module is enabled - $enabled = true; - $module = $part = $obj = strtolower(preg_replace('/^mod/i', '', $modulename)); - //if ($part == 'propale') $part='propal'; - if ($module == 'societe') { + // Defined if module is enabled + $enabled = true; + $module = $part = $obj = strtolower(preg_replace('/^mod/i', '', $modulename)); + //if ($part == 'propale') $part='propal'; + if ($module == 'societe') { $obj = 'thirdparty'; } - if ($module == 'categorie') { - $part = 'categories'; + if ($module == 'categorie') { + $part = 'categories'; $obj = 'category'; } - if ($module == 'facture') { - $part = 'compta/facture'; + if ($module == 'facture') { + $part = 'compta/facture'; $obj = 'facture'; } - if ($module == 'ficheinter') { - $obj = 'fichinter'; - $part = 'fichinter'; - $module = 'fichinter'; - } + if ($module == 'ficheinter') { + $obj = 'fichinter'; + $part = 'fichinter'; + $module = 'fichinter'; + } - if (empty($conf->$module->enabled)) $enabled = false; + if (empty($conf->$module->enabled)) $enabled = false; - if ($enabled) { - /* + if ($enabled) { + /* * If exists, load the API class for enable module * * Search files named api_.class.php into /htdocs//class directory @@ -107,25 +107,25 @@ foreach ($modulesdir as $dir) * @todo : take care of externals module! * @todo : use getElementProperties() function ? */ - $dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/'; + $dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/'; - $handle_part = @opendir(dol_osencode($dir_part)); - if (is_resource($handle_part)) - { - while (($file_searched = readdir($handle_part)) !== false) - { - if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $reg)) - { - $classname = ucwords($reg[1]); - require_once $dir_part.$file_searched; - if (class_exists($classname)) - { - dol_syslog("Found API classname=".$classname." into ".$dir); - $listofapis[] = $classname; - } - } + $handle_part = @opendir(dol_osencode($dir_part)); + if (is_resource($handle_part)) + { + while (($file_searched = readdir($handle_part)) !== false) + { + if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $reg)) + { + $classname = ucwords($reg[1]); + require_once $dir_part.$file_searched; + if (class_exists($classname)) + { + dol_syslog("Found API classname=".$classname." into ".$dir); + $listofapis[] = $classname; + } + } - /* + /* if (is_readable($dir_part.$file_searched) && preg_match("/^(api_.*)\.class\.php$/i",$file_searched,$reg)) { $classname=$reg[1]; @@ -150,12 +150,12 @@ foreach ($modulesdir as $dir) // //$listofapis[]=array('classname'=>$classname, 'fullpath'=>$file_searched); // } }*/ - } - } - } - } - } - } + } + } + } + } + } + } } //var_dump($listofapis); @@ -188,28 +188,28 @@ $oldclass = ''; print $langs->trans("ListOfAvailableAPIs").':
'; foreach ($listofapis['v1'] as $key => $val) { - if ($key == 'login') continue; - if ($key == 'index') continue; + if ($key == 'login') continue; + if ($key == 'index') continue; - if ($key) - { - foreach ($val as $method => $val2) - { - $newclass = $val2['className']; + if ($key) + { + foreach ($val as $method => $val2) + { + $newclass = $val2['className']; - if (preg_match('/restler/i', $newclass)) continue; + if (preg_match('/restler/i', $newclass)) continue; - if ($oldclass != $newclass) - { - print "\n
\n".$langs->trans("Class").': '.$newclass.'
'."\n"; - $oldclass = $newclass; - } - //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
\n"; - $url = $urlwithroot.'/api/index.php/'.$key; - $url .= '?api_key=token'; - print img_picto('', 'globe').' '.$method.' '.$url."
\n"; - } - } + if ($oldclass != $newclass) + { + print "\n
\n".$langs->trans("Class").': '.$newclass.'
'."\n"; + $oldclass = $newclass; + } + //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
\n"; + $url = $urlwithroot.'/api/index.php/'.$key; + $url .= '?api_key=token'; + print img_picto('', 'globe').' '.$method.' '.$url."
\n"; + } + } } print '
'; diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index a7eab61211d..18cbff2ca61 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -64,11 +64,11 @@ if ($action == 'setproductionmode') } } - if (!$error) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } + if (!$error) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } } else { dol_print_error($db); } @@ -112,13 +112,13 @@ print ''.$langs->trans("ApiProductionMode").''; $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ?false:true); if ($production_mode) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } print ' '; print ''; @@ -157,10 +157,10 @@ print '
'; print ''.$langs->trans("ApiExporerIs").':
'; if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer')) { - $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; - print img_picto('', 'globe').' '.$url."
\n"; + $url = DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; + print img_picto('', 'globe').' '.$url."
\n"; } else { - print $langs->trans("NotAvailableWithThisDistribution"); + print $langs->trans("NotAvailableWithThisDistribution"); } llxFooter(); diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 895a0e2dc60..5834324fa2b 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -30,54 +30,54 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; class DolibarrApi { - /** - * @var DoliDb $db Database object - */ - protected $db; + /** + * @var DoliDb $db Database object + */ + protected $db; - /** - * @var Restler $r Restler object - */ - public $r; + /** + * @var Restler $r Restler object + */ + public $r; - /** - * Constructor - * - * @param DoliDb $db Database handler - * @param string $cachedir Cache dir - * @param boolean $refreshCache Update cache - */ - public function __construct($db, $cachedir = '', $refreshCache = false) - { - global $conf, $dolibarr_main_url_root; + /** + * Constructor + * + * @param DoliDb $db Database handler + * @param string $cachedir Cache dir + * @param boolean $refreshCache Update cache + */ + public function __construct($db, $cachedir = '', $refreshCache = false) + { + global $conf, $dolibarr_main_url_root; - if (empty($cachedir)) $cachedir = $conf->api->dir_temp; - Defaults::$cacheDirectory = $cachedir; + if (empty($cachedir)) $cachedir = $conf->api->dir_temp; + Defaults::$cacheDirectory = $cachedir; - $this->db = $db; - $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ? false : true); - $this->r = new Restler($production_mode, $refreshCache); + $this->db = $db; + $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ? false : true); + $this->r = new Restler($production_mode, $refreshCache); - $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 - $urlwithouturlrootautodetect = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim(DOL_MAIN_URL_ROOT)); - $urlwithrootautodetect = $urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url + $urlwithouturlrootautodetect = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim(DOL_MAIN_URL_ROOT)); + $urlwithrootautodetect = $urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url - $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect); - $this->r->setAPIVersion(1); - //$this->r->setSupportedFormats('json'); - //$this->r->setSupportedFormats('jsonFormat'); - } + $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect); + $this->r->setAPIVersion(1); + //$this->r->setSupportedFormats('json'); + //$this->r->setSupportedFormats('jsonFormat'); + } - /** - * Executed method when API is called without parameter - * - * Display a short message an return a http code 200 - * - * @return array - */ - /* Disabled, most APIs does not share same signature for method index + /** + * Executed method when API is called without parameter + * + * Display a short message an return a http code 200 + * + * @return array + */ + /* Disabled, most APIs does not share same signature for method index function index() { return array( @@ -88,148 +88,148 @@ class DolibarrApi ); }*/ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param Object $object Object to clean - * @return Object Object with cleaned properties - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - // Remove $db object property for object - unset($object->db); - unset($object->isextrafieldmanaged); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + // Remove $db object property for object + unset($object->db); + unset($object->isextrafieldmanaged); unset($object->ismultientitymanaged); unset($object->restrictiononfksoc); unset($object->table_rowid); - // Remove linkedObjects. We should already have linkedObjectsIds that avoid huge responses - unset($object->linkedObjects); + // Remove linkedObjects. We should already have linkedObjectsIds that avoid huge responses + unset($object->linkedObjects); - unset($object->fields); - unset($object->oldline); + unset($object->fields); + unset($object->oldline); - unset($object->error); - unset($object->errors); + unset($object->error); + unset($object->errors); - unset($object->ref_previous); - unset($object->ref_next); - unset($object->ref_int); + unset($object->ref_previous); + unset($object->ref_next); + unset($object->ref_int); - unset($object->projet); // Should be fk_project - unset($object->project); // Should be fk_project - unset($object->author); // Should be fk_user_author - unset($object->timespent_old_duration); - unset($object->timespent_id); - unset($object->timespent_duration); - unset($object->timespent_date); - unset($object->timespent_datehour); - unset($object->timespent_withhour); - unset($object->timespent_fk_user); - unset($object->timespent_note); - unset($object->fk_delivery_address); + unset($object->projet); // Should be fk_project + unset($object->project); // Should be fk_project + unset($object->author); // Should be fk_user_author + unset($object->timespent_old_duration); + unset($object->timespent_id); + unset($object->timespent_duration); + unset($object->timespent_date); + unset($object->timespent_datehour); + unset($object->timespent_withhour); + unset($object->timespent_fk_user); + unset($object->timespent_note); + unset($object->fk_delivery_address); - unset($object->statuts); - unset($object->statuts_short); - unset($object->statuts_logo); - unset($object->statuts_long); - unset($object->labelStatus); - unset($object->labelStatusShort); + unset($object->statuts); + unset($object->statuts_short); + unset($object->statuts_logo); + unset($object->statuts_long); + unset($object->labelStatus); + unset($object->labelStatusShort); - unset($object->stats_propale); - unset($object->stats_commande); - unset($object->stats_contrat); - unset($object->stats_facture); - unset($object->stats_commande_fournisseur); - unset($object->stats_reception); - unset($object->stats_mrptoconsume); - unset($object->stats_mrptoproduce); + unset($object->stats_propale); + unset($object->stats_commande); + unset($object->stats_contrat); + unset($object->stats_facture); + unset($object->stats_commande_fournisseur); + unset($object->stats_reception); + unset($object->stats_mrptoconsume); + unset($object->stats_mrptoproduce); - unset($object->element); - unset($object->fk_element); - unset($object->table_element); - unset($object->table_element_line); - unset($object->class_element_line); - unset($object->picto); + unset($object->element); + unset($object->fk_element); + unset($object->table_element); + unset($object->table_element_line); + unset($object->class_element_line); + unset($object->picto); - unset($object->fieldsforcombobox); + unset($object->fieldsforcombobox); - unset($object->skip_update_total); - unset($object->context); - unset($object->next_prev_filter); + unset($object->skip_update_total); + unset($object->context); + unset($object->next_prev_filter); - unset($object->region); - unset($object->region_code); + unset($object->region); + unset($object->region_code); - unset($object->libelle_statut); - unset($object->libelle_paiement); + unset($object->libelle_statut); + unset($object->libelle_paiement); - if ($object->table_element != 'ticket') { - unset($object->comments); - } + if ($object->table_element != 'ticket') { + unset($object->comments); + } - // Remove the $oldcopy property because it is not supported by the JSON - // encoder. The following error is generated when trying to serialize - // it: "Error encoding/decoding JSON: Type is not supported" - // Note: Event if this property was correctly handled by the JSON - // encoder, it should be ignored because keeping it would let the API - // have a very strange behavior: calling PUT and then GET on the same - // resource would give different results: - // PUT /objects/{id} -> returns object with oldcopy = previous version of the object - // GET /objects/{id} -> returns object with oldcopy empty - unset($object->oldcopy); + // Remove the $oldcopy property because it is not supported by the JSON + // encoder. The following error is generated when trying to serialize + // it: "Error encoding/decoding JSON: Type is not supported" + // Note: Event if this property was correctly handled by the JSON + // encoder, it should be ignored because keeping it would let the API + // have a very strange behavior: calling PUT and then GET on the same + // resource would give different results: + // PUT /objects/{id} -> returns object with oldcopy = previous version of the object + // GET /objects/{id} -> returns object with oldcopy empty + unset($object->oldcopy); - // If object has lines, remove $db property - if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { - $nboflines = count($object->lines); - for ($i = 0; $i < $nboflines; $i++) - { - $this->_cleanObjectDatas($object->lines[$i]); + // If object has lines, remove $db property + if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i = 0; $i < $nboflines; $i++) + { + $this->_cleanObjectDatas($object->lines[$i]); - unset($object->lines[$i]->contact); - unset($object->lines[$i]->contact_id); - unset($object->lines[$i]->country); - unset($object->lines[$i]->country_id); - unset($object->lines[$i]->country_code); - unset($object->lines[$i]->mode_reglement_id); - unset($object->lines[$i]->mode_reglement_code); - unset($object->lines[$i]->mode_reglement); - unset($object->lines[$i]->cond_reglement_id); - unset($object->lines[$i]->cond_reglement_code); - unset($object->lines[$i]->cond_reglement); - unset($object->lines[$i]->fk_delivery_address); - unset($object->lines[$i]->fk_projet); - unset($object->lines[$i]->fk_project); - unset($object->lines[$i]->thirdparty); - unset($object->lines[$i]->user); - unset($object->lines[$i]->model_pdf); - unset($object->lines[$i]->modelpdf); - unset($object->lines[$i]->note_public); - unset($object->lines[$i]->note_private); - unset($object->lines[$i]->fk_incoterms); - unset($object->lines[$i]->label_incoterms); - unset($object->lines[$i]->location_incoterms); - unset($object->lines[$i]->name); - unset($object->lines[$i]->lastname); - unset($object->lines[$i]->firstname); - unset($object->lines[$i]->civility_id); - unset($object->lines[$i]->fk_multicurrency); - unset($object->lines[$i]->multicurrency_code); - unset($object->lines[$i]->shipping_method_id); - } - } + unset($object->lines[$i]->contact); + unset($object->lines[$i]->contact_id); + unset($object->lines[$i]->country); + unset($object->lines[$i]->country_id); + unset($object->lines[$i]->country_code); + unset($object->lines[$i]->mode_reglement_id); + unset($object->lines[$i]->mode_reglement_code); + unset($object->lines[$i]->mode_reglement); + unset($object->lines[$i]->cond_reglement_id); + unset($object->lines[$i]->cond_reglement_code); + unset($object->lines[$i]->cond_reglement); + unset($object->lines[$i]->fk_delivery_address); + unset($object->lines[$i]->fk_projet); + unset($object->lines[$i]->fk_project); + unset($object->lines[$i]->thirdparty); + unset($object->lines[$i]->user); + unset($object->lines[$i]->model_pdf); + unset($object->lines[$i]->modelpdf); + unset($object->lines[$i]->note_public); + unset($object->lines[$i]->note_private); + unset($object->lines[$i]->fk_incoterms); + unset($object->lines[$i]->label_incoterms); + unset($object->lines[$i]->location_incoterms); + unset($object->lines[$i]->name); + unset($object->lines[$i]->lastname); + unset($object->lines[$i]->firstname); + unset($object->lines[$i]->civility_id); + unset($object->lines[$i]->fk_multicurrency); + unset($object->lines[$i]->multicurrency_code); + unset($object->lines[$i]->shipping_method_id); + } + } - if (!empty($object->thirdparty) && is_object($object->thirdparty)) - { - $this->_cleanObjectDatas($object->thirdparty); - } + if (!empty($object->thirdparty) && is_object($object->thirdparty)) + { + $this->_cleanObjectDatas($object->thirdparty); + } return $object; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Check user access to a resource * @@ -241,12 +241,12 @@ class DolibarrApi * @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) - * @return bool + * @return bool * @throws RestException */ - protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') - { - // phpcs:enable + protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') + { + // phpcs:enable // Features/modules to check $featuresarray = array($resource); if (preg_match('/&/', $resource)) { @@ -261,9 +261,9 @@ class DolibarrApi } return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Return if a $sqlfilters parameter is valid * @@ -272,30 +272,30 @@ class DolibarrApi */ protected function _checkFilters($sqlfilters) { - // phpcs:enable - //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); - $tmp = $sqlfilters; - $ok = 0; - $i = 0; $nb = strlen($tmp); - $counter = 0; - while ($i < $nb) - { - if ($tmp[$i] == '(') $counter++; - if ($tmp[$i] == ')') $counter--; - if ($counter < 0) - { - $error = "Bad sqlfilters=".$sqlfilters; - dol_syslog($error, LOG_WARNING); - return false; - } - $i++; - } - return true; + // phpcs:enable + //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); + $tmp = $sqlfilters; + $ok = 0; + $i = 0; $nb = strlen($tmp); + $counter = 0; + while ($i < $nb) + { + if ($tmp[$i] == '(') $counter++; + if ($tmp[$i] == ')') $counter--; + if ($counter < 0) + { + $error = "Bad sqlfilters=".$sqlfilters; + dol_syslog($error, LOG_WARNING); + return false; + } + $i++; + } + return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Function to forge a SQL criteria * @@ -304,22 +304,22 @@ class DolibarrApi */ protected static function _forge_criteria_callback($matches) { - // phpcs:enable - global $db; + // phpcs:enable + global $db; - //dol_syslog("Convert matches ".$matches[1]); - if (empty($matches[1])) return ''; - $tmp = explode(':', $matches[1]); - if (count($tmp) < 3) return ''; + //dol_syslog("Convert matches ".$matches[1]); + if (empty($matches[1])) return ''; + $tmp = explode(':', $matches[1]); + if (count($tmp) < 3) return ''; - $tmpescaped = $tmp[2]; - $regbis = array(); - if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) - { - $tmpescaped = "'".$db->escape($regbis[1])."'"; - } else { - $tmpescaped = $db->escape($tmpescaped); - } - return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; + $tmpescaped = $tmp[2]; + $regbis = array(); + if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) + { + $tmpescaped = "'".$db->escape($regbis[1])."'"; + } else { + $tmpescaped = $db->escape($tmpescaped); + } + return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; } } diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 84f7bf303e7..6f6e1a2fb6c 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -18,7 +18,7 @@ // Create the autoloader for Luracast require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; -call_user_func(function () { +call_user_func(function() { $loader = Luracast\Restler\AutoLoader::instance(); spl_autoload_register($loader); return $loader; @@ -52,7 +52,7 @@ class DolibarrApiAccess implements iAuthenticate /** * @var string $role user role */ - public static $role = 'user'; + public static $role = 'user'; /** * @var User $user Loggued user @@ -69,7 +69,7 @@ class DolibarrApiAccess implements iAuthenticate $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Check access * @@ -80,7 +80,7 @@ class DolibarrApiAccess implements iAuthenticate */ public function __isAllowed() { - // phpcs:enable + // phpcs:enable global $conf, $db; $login = ''; @@ -97,17 +97,17 @@ class DolibarrApiAccess implements iAuthenticate $api_key = ''; if (isset($_GET['api_key'])) // For backward compatibility { - // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['api_key']; + // TODO Add option to disable use of api key on url. Return errors if used. + $api_key = $_GET['api_key']; } if (isset($_GET['DOLAPIKEY'])) { - // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['DOLAPIKEY']; // With GET method + // TODO Add option to disable use of api key on url. Return errors if used. + $api_key = $_GET['DOLAPIKEY']; // With GET method } if (isset($_SERVER['HTTP_DOLAPIKEY'])) // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY { - $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) + $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) } if ($api_key) @@ -149,7 +149,7 @@ class DolibarrApiAccess implements iAuthenticate if (!$login) { - throw new RestException(503, 'Error when searching login user from api key'); + throw new RestException(503, 'Error when searching login user from api key'); } $fuser = new User($this->db); $result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity)); // If user is not entity 0, we search in working entity $conf->entity (that may have been forced to a different value than user entity) @@ -161,49 +161,49 @@ class DolibarrApiAccess implements iAuthenticate if ($fuser->socid) { static::$role = 'external'; - } + } if ($fuser->admin) { static::$role = 'admin'; - } - } else { - throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."); + } + } else { + throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL)."); } - $userClass::setCacheIdentifier(static::$role); - Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; - $requirefortest = static::$requires; - if (!is_array($requirefortest)) $requirefortest = explode(',', $requirefortest); - return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin'; + $userClass::setCacheIdentifier(static::$role); + Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess'; + $requirefortest = static::$requires; + if (!is_array($requirefortest)) $requirefortest = explode(',', $requirefortest); + return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * @return string string to be used with WWW-Authenticate header */ - public function __getWWWAuthenticateString() - { - // phpcs:enable - return ''; - } + public function __getWWWAuthenticateString() + { + // phpcs:enable + return ''; + } - /** - * Verify access - * - * @param array $m Properties of method - * - * @access private - * @return bool - */ - public static function verifyAccess(array $m) - { - $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) - ? $m['class']['DolibarrApiAccess']['properties']['requires'] - : false; + /** + * Verify access + * + * @param array $m Properties of method + * + * @access private + * @return bool + */ + public static function verifyAccess(array $m) + { + $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) + ? $m['class']['DolibarrApiAccess']['properties']['requires'] + : false; - return $requires - ? static::$role == 'admin' || in_array(static::$role, (array) $requires) - : true; - } + return $requires + ? static::$role == 'admin' || in_array(static::$role, (array) $requires) + : true; + } } diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index fa570caed77..5fff08b80ab 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -409,7 +409,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->fournisseur->dir_output."/facture/".get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').dol_sanitizeFileName($object->ref); } - elseif ($modulepart == 'produit' || $modulepart == 'product') + elseif ($modulepart == 'produit' || $modulepart == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -419,9 +419,9 @@ class Documents extends DolibarrApi $object = new Product($this->db); $result = $object->fetch($id, $ref); - if ($result==0) { + if ($result == 0) { throw new RestException(404, 'Product not found'); - } elseif ($result<0) { + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object: '.$object->error); } @@ -515,7 +515,7 @@ class Documents extends DolibarrApi * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) * @param int $overwriteifexists Overwrite file if exists (1 by default) - * @return string + * @return string * * @throws RestException 400 * @throws RestException 401 @@ -633,7 +633,7 @@ class Documents extends DolibarrApi if ($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); - } + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object: '.$object->error); @@ -682,7 +682,7 @@ class Documents extends DolibarrApi if (dol_mkdir($upload_dir) < 0) // needed by products { - throw new RestException(500, 'Error while trying to create directory.'); + throw new RestException(500, 'Error while trying to create directory.'); } $destfile = $upload_dir.'/'.$original_file; @@ -735,63 +735,63 @@ class Documents extends DolibarrApi */ public function delete($modulepart, $original_file) { - global $conf, $langs; + global $conf, $langs; - if (empty($modulepart)) { - throw new RestException(400, 'bad value for parameter modulepart'); - } - if (empty($original_file)) { - throw new RestException(400, 'bad value for parameter original_file'); - } + if (empty($modulepart)) { + throw new RestException(400, 'bad value for parameter modulepart'); + } + if (empty($original_file)) { + throw new RestException(400, 'bad value for parameter original_file'); + } - //--- Finds and returns the document - $entity = $conf->entity; + //--- Finds and returns the document + $entity = $conf->entity; - // Special cases that need to use get_exdir to get real dir of object - // If future, all object should use this to define path of documents. - /* + // Special cases that need to use get_exdir to get real dir of object + // If future, all object should use this to define path of documents. + /* $tmpreldir = ''; if ($modulepart == 'supplier_invoice') { $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); } $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */ - $relativefile = $original_file; + $relativefile = $original_file; - $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'read'); - $accessallowed = $check_access['accessallowed']; - $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; - $original_file = $check_access['original_file']; + $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'read'); + $accessallowed = $check_access['accessallowed']; + $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; + $original_file = $check_access['original_file']; - if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { - throw new RestException(401); - } - if (!$accessallowed) { - throw new RestException(401); - } + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { + throw new RestException(401); + } + if (!$accessallowed) { + throw new RestException(401); + } - $filename = basename($original_file); - $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset + $filename = basename($original_file); + $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset - if (!file_exists($original_file_osencoded)) - { - dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); - throw new RestException(404, 'File not found'); - } + if (!file_exists($original_file_osencoded)) + { + dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); + throw new RestException(404, 'File not found'); + } - if (@unlink($original_file_osencoded)) { - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Document deleted' - ) - ); - } + if (@unlink($original_file_osencoded)) { + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Document deleted' + ) + ); + } - throw new RestException(401); + throw new RestException(401); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Validate fields before create or update object * @@ -799,9 +799,9 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - private function _validate_file($data) - { - // phpcs:enable + private function _validate_file($data) + { + // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { if (!isset($data[$field])) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 8627808a679..cb2fdd54d66 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -26,14 +26,14 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; class Login { - /** - * Constructor of the class - */ - public function __construct() - { - global $db; - $this->db = $db; - } + /** + * Constructor of the class + */ + public function __construct() + { + global $db; + $this->db = $db; + } /** * Login @@ -46,21 +46,21 @@ class Login * @param string $password User password * @param string $entity Entity (when multicompany module is used). '' means 1=first company. * @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access) - * @return array Response status and user token - * + * @return array Response status and user token + * * @throws RestException 403 * @throws RestException 500 * * @url GET / * @url POST / */ - public function index($login, $password, $entity = '', $reset = 0) - { - global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; + public function index($login, $password, $entity = '', $reset = 0) + { + global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; - // TODO Remove the API login. The token must be generated from backoffice only. + // TODO Remove the API login. The token must be generated from backoffice only. - // Authentication mode + // Authentication mode if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'dolibarr'; // Authentication mode: forceuser @@ -108,22 +108,22 @@ class Login throw new RestException(403, 'User need write permission on itself to reset its API token'); } - // Generate token for user - $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1); + // Generate token for user + $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1); - // We store API token into database - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET api_key = '".$this->db->escape($token)."'"; - $sql .= " WHERE login = '".$this->db->escape($login)."'"; + // We store API token into database + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET api_key = '".$this->db->escape($token)."'"; + $sql .= " WHERE login = '".$this->db->escape($login)."'"; - dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log - $result = $this->db->query($sql); - if (!$result) - { - throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror()); - } + dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log + $result = $this->db->query($sql); + if (!$result) + { + throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror()); + } } else { - $token = $tmpuser->api_key; + $token = $tmpuser->api_key; } //return token @@ -131,9 +131,9 @@ class Login 'success' => array( 'code' => 200, 'token' => $token, - 'entity' => $tmpuser->entity, - 'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') + 'entity' => $tmpuser->entity, + 'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); - } + } } diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php index 45c69e318e0..6c80e838f0a 100644 --- a/htdocs/api/class/api_status.class.php +++ b/htdocs/api/class/api_status.class.php @@ -26,21 +26,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; */ class Status { - /** - * Get status (Dolibarr version) - * - * @return array - */ - public function index() - { - global $conf; + /** + * Get status (Dolibarr version) + * + * @return array + */ + public function index() + { + global $conf; - return array( - 'success' => array( - 'code' => 200, - 'dolibarr_version' => DOL_VERSION, - 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED) ? '0' : $conf->global->MAIN_ONLY_LOGIN_ALLOWED), - ), - ); - } + return array( + 'success' => array( + 'code' => 200, + 'dolibarr_version' => DOL_VERSION, + 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED) ? '0' : $conf->global->MAIN_ONLY_LOGIN_ALLOWED), + ), + ); + } } diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 1ae504f523a..f605ff11d85 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -45,7 +45,7 @@ if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; -call_user_func(function () { +call_user_func(function() { $loader = Luracast\Restler\AutoLoader::instance(); spl_autoload_register($loader); return $loader; @@ -69,22 +69,22 @@ if (!empty($conf->global->MAIN_NGINX_FIX)) // Enable and test if module Api is enabled if (empty($conf->global->MAIN_MODULE_API)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningModuleNotActive", 'Api').'.

'; - print $langs->trans("ToActivateModule"); - //session_destroy(); - exit(0); + $langs->load("admin"); + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningModuleNotActive", 'Api').'.

'; + print $langs->trans("ToActivateModule"); + //session_destroy(); + exit(0); } // Test if explorer is not disabled if (preg_match('/api\/index\.php\/explorer/', $url) && !empty($conf->global->API_EXPLORER_DISABLED)) { - $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); - print $langs->trans("WarningAPIExplorerDisabled").'.

'; - //session_destroy(); - exit(0); + $langs->load("admin"); + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningAPIExplorerDisabled").'.

'; + //session_destroy(); + exit(0); } @@ -114,7 +114,7 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg); $refreshcache = (empty($conf->global->API_PRODUCTION_DO_NOT_ALWAYS_REFRESH_CACHE) ? true : false); if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { - $refreshcache = true; + $refreshcache = true; } $api = new DolibarrApi($db, '', $refreshcache); @@ -150,104 +150,104 @@ if (!empty($conf->global->API_RESTRICT_ON_IP)) // Call Explorer file for all APIs definitions (this part is slow) if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { - // Scan all API files to load them + // Scan all API files to load them - $listofapis = array(); + $listofapis = array(); - $modulesdir = dolGetModulesDirs(); - foreach ($modulesdir as $dir) - { - // Search available module - dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files"); + $modulesdir = dolGetModulesDirs(); + foreach ($modulesdir as $dir) + { + // Search available module + dol_syslog("Scan directory ".$dir." for module descriptor files, then search for API files"); - $handle = @opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - $regmod = array(); - if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) - { - $module = strtolower($regmod[1]); - $moduledirforclass = getModuleDirForApiClass($module); - $modulenameforenabled = $module; - if ($module == 'propale') { $modulenameforenabled = 'propal'; } - if ($module == 'supplierproposal') { $modulenameforenabled = 'supplier_proposal'; } - if ($module == 'ficheinter') { $modulenameforenabled = 'ficheinter'; } + $handle = @opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $regmod = array(); + if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) + { + $module = strtolower($regmod[1]); + $moduledirforclass = getModuleDirForApiClass($module); + $modulenameforenabled = $module; + if ($module == 'propale') { $modulenameforenabled = 'propal'; } + if ($module == 'supplierproposal') { $modulenameforenabled = 'supplier_proposal'; } + if ($module == 'ficheinter') { $modulenameforenabled = 'ficheinter'; } - dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass); + dol_syslog("Found module file ".$file." - module=".$module." - modulenameforenabled=".$modulenameforenabled." - moduledirforclass=".$moduledirforclass); - // Defined if module is enabled - $enabled = true; - if (empty($conf->$modulenameforenabled->enabled)) $enabled = false; + // Defined if module is enabled + $enabled = true; + if (empty($conf->$modulenameforenabled->enabled)) $enabled = false; - if ($enabled) - { - // If exists, load the API class for enable module - // Search files named api_.class.php into /htdocs//class directory - // @todo : use getElementProperties() function ? - $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); + if ($enabled) + { + // If exists, load the API class for enable module + // Search files named api_.class.php into /htdocs//class directory + // @todo : use getElementProperties() function ? + $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); - $handle_part = @opendir(dol_osencode($dir_part)); - if (is_resource($handle_part)) - { - while (($file_searched = readdir($handle_part)) !== false) - { - if ($file_searched == 'api_access.class.php') continue; + $handle_part = @opendir(dol_osencode($dir_part)); + if (is_resource($handle_part)) + { + while (($file_searched = readdir($handle_part)) !== false) + { + if ($file_searched == 'api_access.class.php') continue; - $regapi = array(); - if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) - { - $classname = ucwords($regapi[1]); - $classname = str_replace('_', '', $classname); - require_once $dir_part.$file_searched; - if (class_exists($classname.'Api')) - { - //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched); - $listofapis[strtolower($classname.'Api')] = $classname.'Api'; - } elseif (class_exists($classname)) - { - //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); - $listofapis[strtolower($classname)] = $classname; - } else { - dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); - } - } - } - } - } - } - } - } - } + $regapi = array(); + if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) + { + $classname = ucwords($regapi[1]); + $classname = str_replace('_', '', $classname); + require_once $dir_part.$file_searched; + if (class_exists($classname.'Api')) + { + //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched); + $listofapis[strtolower($classname.'Api')] = $classname.'Api'; + } elseif (class_exists($classname)) + { + //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); + $listofapis[strtolower($classname)] = $classname; + } else { + dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); + } + } + } + } + } + } + } + } + } - // Sort the classes before adding them to Restler. - // The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted. - asort($listofapis); - foreach ($listofapis as $apiname => $classname) - { - $api->r->addAPIClass($classname, $apiname); - } - //var_dump($api->r); + // Sort the classes before adding them to Restler. + // The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted. + asort($listofapis); + foreach ($listofapis as $apiname => $classname) + { + $api->r->addAPIClass($classname, $apiname); + } + //var_dump($api->r); } // Call one APIs or one definition of an API $regbis = array(); if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) { - $moduleobject = $reg[1]; - if ($moduleobject == 'explorer') // If we call page to explore details of a service - { - $moduleobject = $regbis[2]; - } + $moduleobject = $reg[1]; + if ($moduleobject == 'explorer') // If we call page to explore details of a service + { + $moduleobject = $regbis[2]; + } - $moduleobject = strtolower($moduleobject); - $moduledirforclass = getModuleDirForApiClass($moduleobject); + $moduleobject = strtolower($moduleobject); + $moduledirforclass = getModuleDirForApiClass($moduleobject); - // Load a dedicated API file - dol_syslog("Load a dedicated API file moduleobject=".$moduleobject." moduledirforclass=".$moduledirforclass); + // Load a dedicated API file + dol_syslog("Load a dedicated API file moduleobject=".$moduleobject." moduledirforclass=".$moduledirforclass); - $tmpmodule = $moduleobject; + $tmpmodule = $moduleobject; if ($tmpmodule != 'api') $tmpmodule = preg_replace('/api$/i', '', $tmpmodule); $classfile = str_replace('_', '', $tmpmodule); @@ -274,7 +274,7 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && if ($dir_part_file) $res = include_once $dir_part_file; if (!$res) { - dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING); + dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING); print 'API not found (failed to include API file)'; header('HTTP/1.1 501 API not found (failed to include API file)'); //session_destroy(); diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php index 25d7df8e1a7..e17d421437d 100644 --- a/htdocs/asset/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -91,7 +91,7 @@ if ($action == 'create') print "
"; print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -104,7 +104,7 @@ if ($action == 'edit' && !empty($attrname)) print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index db2407a9376..5af5f3d7591 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -87,7 +87,7 @@ class AssetType extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -100,8 +100,8 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - public function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error = 0; @@ -164,7 +164,7 @@ class AssetType extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Met a jour en base donnees du type @@ -173,7 +173,7 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - public function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -299,7 +299,7 @@ class AssetType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of asset's type * @@ -307,7 +307,7 @@ class AssetType extends CommonObject */ public function liste_array() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $assettypes = array(); @@ -424,8 +424,8 @@ class AssetType extends CommonObject * * @return void */ - public function initAsSpecimen() - { + public function initAsSpecimen() + { global $conf, $user, $langs; // Initialize parameters @@ -440,15 +440,15 @@ class AssetType extends CommonObject $this->asset = array( $user->id => $user ); - } + } - /** - * getLibStatut - * - * @return string Return status of a type of asset - */ - public function getLibStatut() - { - return ''; - } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + public function getLibStatut() + { + return ''; + } } diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php index 87aaeb6d46f..7a3660e350e 100644 --- a/htdocs/asterisk/cidlookup.php +++ b/htdocs/asterisk/cidlookup.php @@ -35,8 +35,8 @@ $notfound = $langs->trans("Unknown"); // Security check if (empty($conf->clicktodial->enabled)) { - print "Error: Module Click to dial is not enabled.\n"; - exit; + print "Error: Module Click to dial is not enabled.\n"; + exit; } // Check parameters diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index ecc7c4fee6c..0a9ac82ce23 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -44,10 +44,10 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); */ function llxHeader() { - print ''."\n"; - print ''."\n"; - print 'Asterisk redirection from Dolibarr...'."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print 'Asterisk redirection from Dolibarr...'."\n"; + print ''."\n"; } /** @@ -58,7 +58,7 @@ function llxHeader() */ function llxFooter() { - print "\n".''."\n"; + print "\n".''."\n"; } require_once '../main.inc.php'; @@ -69,8 +69,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Security check if (empty($conf->clicktodial->enabled)) { - accessforbidden(); - exit; + accessforbidden(); + exit; } @@ -146,46 +146,46 @@ $number = strtolower($called); $pos = strpos($number, "local"); if (!empty($number)) { - if ($pos === false) - { - $errno = 0; - $errstr = 0; - $strCallerId = "Dolibarr call $found <".strtolower($number).">"; - $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10); - if (!$oSocket) - { - print ''."\n"; - $txt = "Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
\n"; - print $txt; - dol_syslog($txt, LOG_ERR); - $txt = $errstr." (".$errno.")
\n"; - print $txt; - dol_syslog($txt, LOG_ERR); - print ''."\n"; - } else { - $txt = "Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login; - dol_syslog($txt); - print ''."\n"; - print ''; - fputs($oSocket, "Action: login\r\n"); - fputs($oSocket, "Events: off\r\n"); - fputs($oSocket, "Username: $login\r\n"); - fputs($oSocket, "Secret: $password\r\n\r\n"); - fputs($oSocket, "Action: originate\r\n"); - fputs($oSocket, "Channel: ".$channel.$caller."\r\n"); - fputs($oSocket, "WaitTime: $strWaitTime\r\n"); - fputs($oSocket, "CallerId: $strCallerId\r\n"); - fputs($oSocket, "Exten: ".$prefix.$number."\r\n"); - fputs($oSocket, "Context: $strContext\r\n"); - fputs($oSocket, "Priority: $strPriority\r\n\r\n"); - fputs($oSocket, "Action: Logoff\r\n\r\n"); - sleep(2); - fclose($oSocket); - print ''."\n"; - } - } + if ($pos === false) + { + $errno = 0; + $errstr = 0; + $strCallerId = "Dolibarr call $found <".strtolower($number).">"; + $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10); + if (!$oSocket) + { + print ''."\n"; + $txt = "Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
\n"; + print $txt; + dol_syslog($txt, LOG_ERR); + $txt = $errstr." (".$errno.")
\n"; + print $txt; + dol_syslog($txt, LOG_ERR); + print ''."\n"; + } else { + $txt = "Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login; + dol_syslog($txt); + print ''."\n"; + print ''; + fputs($oSocket, "Action: login\r\n"); + fputs($oSocket, "Events: off\r\n"); + fputs($oSocket, "Username: $login\r\n"); + fputs($oSocket, "Secret: $password\r\n\r\n"); + fputs($oSocket, "Action: originate\r\n"); + fputs($oSocket, "Channel: ".$channel.$caller."\r\n"); + fputs($oSocket, "WaitTime: $strWaitTime\r\n"); + fputs($oSocket, "CallerId: $strCallerId\r\n"); + fputs($oSocket, "Exten: ".$prefix.$number."\r\n"); + fputs($oSocket, "Context: $strContext\r\n"); + fputs($oSocket, "Priority: $strPriority\r\n\r\n"); + fputs($oSocket, "Action: Logoff\r\n\r\n"); + sleep(2); + fclose($oSocket); + print ''."\n"; + } + } } else { - print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx'; + print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx'; } // End of page diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index dabd05bf745..8a513034a4a 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -148,7 +148,7 @@ if ($action == 'builddoc') $module = new $classname($db); if ($generator != 'tcpdfbarcode') { - // May be phpbarcode + // May be phpbarcode $template = 'standardlabel'; $is2d = false; if ($module->encodingIsSupported($encoding)) @@ -178,19 +178,19 @@ if ($action == 'builddoc') { // List of values to scan for a replacement $substitutionarray = array( - '%LOGIN%' => $user->login, - '%COMPANY%' => $mysoc->name, - '%ADDRESS%' => $mysoc->address, - '%ZIP%' => $mysoc->zip, - '%TOWN%' => $mysoc->town, - '%COUNTRY%' => $mysoc->country, - '%COUNTRY_CODE%' => $mysoc->country_code, - '%EMAIL%' => $mysoc->email, - '%YEAR%' => $year, - '%MONTH%' => $month, - '%DAY%' => $day, - '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, - '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", + '%LOGIN%' => $user->login, + '%COMPANY%' => $mysoc->name, + '%ADDRESS%' => $mysoc->address, + '%ZIP%' => $mysoc->zip, + '%TOWN%' => $mysoc->town, + '%COUNTRY%' => $mysoc->country, + '%COUNTRY_CODE%' => $mysoc->country_code, + '%EMAIL%' => $mysoc->email, + '%YEAR%' => $year, + '%MONTH%' => $month, + '%DAY%' => $day, + '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, + '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/", ); complete_substitutions_array($substitutionarray, $langs); @@ -291,8 +291,8 @@ print '
'.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; - print '
'; - print '
'; - $form->select_produits(GETPOST('productid', 'int'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); - print '   '; - print '
'; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; + print '
'; + print '
'; + $form->select_produits(GETPOST('productid', 'int'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); + print '   '; + print '
'; } if (!empty($user->rights->societe->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; - print '
'; - print '
'; - print $form->select_company(GETPOST('socid', 'int'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); - print '   '; - print '
'; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; + print '
'; + print '
'; + print $form->select_company(GETPOST('socid', 'int'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); + print '   '; + print '
'; } print '
'; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 0a77c6ddf3b..67c6c394815 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -559,7 +559,7 @@ jQuery(document).ready(function () { if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { - ?> + ?> '; - } else { - $html = ' + } else { + $html = ' '; - $html .= ' + $html .= ' '; - $html .= ' + $html .= ' '; - $html .= ' + $html .= ' '; - } + } - return $html; + return $html; } diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 30ccc6cdd75..b8d0949a1f0 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -32,7 +32,7 @@ $langs->loadLangs(array('bookmarks', 'other')); // Security check if (!$user->rights->bookmark->lire) { - restrictedArea($user, 'bookmarks'); + restrictedArea($user, 'bookmarks'); } $id = GETPOST("id", 'int'); @@ -219,11 +219,11 @@ if ($id > 0 && !preg_match('/^add/i', $action)) $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', '', 0); - print '
'; + print '
'; - print '
'; + print '
'; print ''; print ''; // Force warehouse (this is not a default value) print ''; @@ -174,11 +174,11 @@ if (!empty($conf->stock->enabled)) // Use Dolibarr Receipt Printer if (!empty($conf->receiptprinter->enabled)) { - print '\n"; + print '\n"; } print '
'; diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 5fab4496f6e..7f19b1bd21e 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -28,217 +28,217 @@ */ class Bookmark extends CommonObject { - /** + /** * @var string ID to identify managed object */ public $element = 'bookmark'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'bookmark'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'bookmark'; - /** + /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int */ - public $ismultientitymanaged = 1; + public $ismultientitymanaged = 1; - /** + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'bookmark'; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var int ID - */ - public $id; + /** + * @var int ID + */ + public $id; - /** + /** * @var int User ID */ public $fk_user; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - public $url; + public $url; - public $target; // 0=replace, 1=new window + public $target; // 0=replace, 1=new window - public $title; + public $title; - public $position; + public $position; - public $favicon; + public $favicon; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Directs the bookmark - * - * @param int $id Bookmark Id Loader - * @return int <0 if KO, >0 if OK - */ - public function fetch($id) - { - global $conf; + /** + * Directs the bookmark + * + * @param int $id Bookmark Id Loader + * @return int <0 if KO, >0 if OK + */ + public function fetch($id) + { + global $conf; - $sql = "SELECT rowid, fk_user, dateb as datec, url, target,"; - $sql .= " title, position, favicon"; - $sql .= " FROM ".MAIN_DB_PREFIX."bookmark"; - $sql .= " WHERE rowid = ".$id; - $sql .= " AND entity = ".$conf->entity; + $sql = "SELECT rowid, fk_user, dateb as datec, url, target,"; + $sql .= " title, position, favicon"; + $sql .= " FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE rowid = ".$id; + $sql .= " AND entity = ".$conf->entity; dol_syslog("Bookmark::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->fk_user = $obj->fk_user; - $this->datec = $this->db->jdate($obj->datec); - $this->url = $obj->url; - $this->target = $obj->target; - $this->title = $obj->title; - $this->position = $obj->position; - $this->favicon = $obj->favicon; + $this->fk_user = $obj->fk_user; + $this->datec = $this->db->jdate($obj->datec); + $this->url = $obj->url; + $this->target = $obj->target; + $this->title = $obj->title; + $this->position = $obj->position; + $this->favicon = $obj->favicon; - $this->db->free($resql); - return $this->id; - } else { - dol_print_error($this->db); - return -1; - } - } + $this->db->free($resql); + return $this->id; + } else { + dol_print_error($this->db); + return -1; + } + } - /** - * Insert bookmark into database - * - * @return int <0 si ko, rowid du bookmark cree si ok - */ - public function create() - { - global $conf; + /** + * Insert bookmark into database + * + * @return int <0 si ko, rowid du bookmark cree si ok + */ + public function create() + { + global $conf; - // Clean parameters - $this->url = trim($this->url); - $this->title = trim($this->title); + // Clean parameters + $this->url = trim($this->url); + $this->title = trim($this->title); if (empty($this->position)) $this->position = 0; $now = dol_now(); - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target"; - $sql .= ",title,favicon,position"; - $sql .= ",entity"; - $sql .= ") VALUES ("; - $sql .= ($this->fk_user > 0 ? $this->fk_user : "0").","; - $sql .= " '".$this->db->idate($now)."',"; - $sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',"; - $sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', '".$this->db->escape($this->position)."'"; - $sql .= ", ".$this->db->escape($conf->entity); - $sql .= ")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_user,dateb,url,target"; + $sql .= ",title,favicon,position"; + $sql .= ",entity"; + $sql .= ") VALUES ("; + $sql .= ($this->fk_user > 0 ? $this->fk_user : "0").","; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->escape($this->url)."', '".$this->db->escape($this->target)."',"; + $sql .= " '".$this->db->escape($this->title)."', '".$this->db->escape($this->favicon)."', '".$this->db->escape($this->position)."'"; + $sql .= ", ".$this->db->escape($conf->entity); + $sql .= ")"; - dol_syslog("Bookmark::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark"); - if ($id > 0) - { - $this->id = $id; - $this->db->commit(); - return $id; - } else { - $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); - $this->db->rollback(); - return -1; - } - } + dol_syslog("Bookmark::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."bookmark"); + if ($id > 0) + { + $this->id = $id; + $this->db->commit(); + return $id; + } else { + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->lasterror(); + $this->errno = $this->db->lasterrno(); + $this->db->rollback(); + return -1; + } + } - /** - * Update bookmark record - * - * @return int <0 if KO, > if OK - */ - public function update() - { - // Clean parameters - $this->url = trim($this->url); - $this->title = trim($this->title); + /** + * Update bookmark record + * + * @return int <0 if KO, > if OK + */ + public function update() + { + // Clean parameters + $this->url = trim($this->url); + $this->title = trim($this->title); if (empty($this->position)) $this->position = 0; - $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark"; - $sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0"); - $sql .= " ,dateb = '".$this->db->idate($this->datec)."'"; - $sql .= " ,url = '".$this->db->escape($this->url)."'"; - $sql .= " ,target = '".$this->db->escape($this->target)."'"; - $sql .= " ,title = '".$this->db->escape($this->title)."'"; - $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; - $sql .= " ,position = '".$this->db->escape($this->position)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."bookmark"; + $sql .= " SET fk_user = ".($this->fk_user > 0 ? $this->fk_user : "0"); + $sql .= " ,dateb = '".$this->db->idate($this->datec)."'"; + $sql .= " ,url = '".$this->db->escape($this->url)."'"; + $sql .= " ,target = '".$this->db->escape($this->target)."'"; + $sql .= " ,title = '".$this->db->escape($this->title)."'"; + $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; + $sql .= " ,position = '".$this->db->escape($this->position)."'"; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog("Bookmark::update", LOG_DEBUG); - if ($this->db->query($sql)) - { - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog("Bookmark::update", LOG_DEBUG); + if ($this->db->query($sql)) + { + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } - /** - * Removes the bookmark - * - * @param int $id Id removed bookmark - * @return int <0 si ko, >0 si ok - */ - public function remove($id) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; - $sql .= " WHERE rowid = ".$id; + /** + * Removes the bookmark + * + * @param int $id Id removed bookmark + * @return int <0 si ko, >0 si ok + */ + public function remove($id) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; + $sql .= " WHERE rowid = ".$id; - dol_syslog("Bookmark::remove", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - return 1; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } + dol_syslog("Bookmark::remove", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + return 1; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } /** * Function used to replace a thirdparty id with another one. @@ -265,7 +265,7 @@ class Bookmark extends CommonObject */ public function getLibStatut($mode) { - return ''; + return ''; } /** diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index dfd6e99a9ea..93d287ac501 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -65,13 +65,13 @@ if (GETPOST('action', 'alpha') == 'set') if (!$res > 0) $error++; if (!$error) - { - $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); - } + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* @@ -146,13 +146,13 @@ if (!empty($conf->stock->enabled)) print '
'.$langs->trans("CashDeskDoNotDecreaseStock").''; if (empty($conf->productbatch->enabled)) { - print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); + print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1); } else { - if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) { - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); - } - print $langs->trans("Yes").'
'; - print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; + if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) { + $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity); + } + print $langs->trans("Yes").'
'; + print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; } print '
'; - print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; - print ''; - print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1); - print "
'; + print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')'; + print ''; + print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1); + print "
'; diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 7b513ada33c..72cb99123a4 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -34,8 +34,8 @@ if ($_GET['id'] == 'NOUV') // Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ... if (isset($_SESSION['serObjFacturation'])) { - $obj_facturation = unserialize($_SESSION['serObjFacturation']); - unset($_SESSION['serObjFacturation']); + $obj_facturation = unserialize($_SESSION['serObjFacturation']); + unset($_SESSION['serObjFacturation']); } else { // ... sinon, c'est une nouvelle vente $obj_facturation = new Facturation(); diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php index cc71d1c20d8..7dbe7ceae3e 100644 --- a/htdocs/cashdesk/class/Auth.class.php +++ b/htdocs/cashdesk/class/Auth.class.php @@ -94,45 +94,45 @@ class Auth $test = true; - // Authentication mode - if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; - // Authentication mode: forceuser - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto'; - // Set authmode - $authmode = explode(',', $dolibarr_main_authentication); + // Authentication mode + if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; + // Authentication mode: forceuser + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto'; + // Set authmode + $authmode = explode(',', $dolibarr_main_authentication); - // No authentication mode - if (!count($authmode)) - { - $langs->load('main'); - dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication')); - exit; - } + // No authentication mode + if (!count($authmode)) + { + $langs->load('main'); + dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication')); + exit; + } $usertotest = $aLogin; $passwordtotest = $aPasswd; $entitytotest = $conf->entity; - // Validation tests user / password - // If ok, the variable will be initialized login - // If error, we will put error message in session under the name dol_loginmesg - $goontestloop = false; - if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) $goontestloop = true; - if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) $goontestloop = true; + // Validation tests user / password + // If ok, the variable will be initialized login + // If error, we will put error message in session under the name dol_loginmesg + $goontestloop = false; + if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) $goontestloop = true; + if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) $goontestloop = true; - if ($test && $goontestloop) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + if ($test && $goontestloop) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode); - if ($login) - { - $this->login($aLogin); - $this->passwd($aPasswd); - $ret = 0; - } else { - $ret = -1; - } - } + if ($login) + { + $this->login($aLogin); + $this->passwd($aPasswd); + $ret = 0; + } else { + $ret = -1; + } + } return $ret; } diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index f2223b0b45d..23eafadc7b8 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -25,553 +25,553 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; */ class Facturation { - /** - * Attributs "volatiles" : reinitialises apres chaque traitement d'un article - *

Attributs "volatiles" : reinitialises apres chaque traitement d'un article

- * int $id => 'rowid' du produit dans llx_product - * string $ref => 'ref' du produit dans llx_product - * int $qte => Quantite pour le produit en cours de traitement - * int $stock => Stock theorique pour le produit en cours de traitement - * int $remise_percent => Remise en pourcent sur le produit en cours - * int $montant_remise => Remise en pourcent sur le produit en cours - * int $prix => Prix HT du produit en cours - * int $tva => 'rowid' du taux de tva dans llx_c_tva - */ + /** + * Attributs "volatiles" : reinitialises apres chaque traitement d'un article + *

Attributs "volatiles" : reinitialises apres chaque traitement d'un article

+ * int $id => 'rowid' du produit dans llx_product + * string $ref => 'ref' du produit dans llx_product + * int $qte => Quantite pour le produit en cours de traitement + * int $stock => Stock theorique pour le produit en cours de traitement + * int $remise_percent => Remise en pourcent sur le produit en cours + * int $montant_remise => Remise en pourcent sur le produit en cours + * int $prix => Prix HT du produit en cours + * int $tva => 'rowid' du taux de tva dans llx_c_tva + */ - /** + /** * @var int ID */ public $id; - protected $ref; - protected $qte; - protected $stock; - protected $remise_percent; - protected $montant_remise; - protected $prix; - protected $tva; + protected $ref; + protected $qte; + protected $stock; + protected $remise_percent; + protected $montant_remise; + protected $prix; + protected $tva; - /** - * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) - * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) - * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) - * int $montant_encaisse => Montant encaisse en cas de reglement en especes - * int $montant_rendu => Monnaie rendue en cas de reglement en especes - * int $paiement_le => Date de paiement en cas de paiement differe - * - * int $prix_total_ht => Prix total hors taxes - * int $montant_tva => Montant total de la TVA, tous taux confondus - * int $prix_total_ttc => Prix total TTC - */ - protected $num_facture; - protected $mode_reglement; - protected $montant_encaisse; - protected $montant_rendu; - protected $paiement_le; + /** + * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) + * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) + * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) + * int $montant_encaisse => Montant encaisse en cas de reglement en especes + * int $montant_rendu => Monnaie rendue en cas de reglement en especes + * int $paiement_le => Date de paiement en cas de paiement differe + * + * int $prix_total_ht => Prix total hors taxes + * int $montant_tva => Montant total de la TVA, tous taux confondus + * int $prix_total_ttc => Prix total TTC + */ + protected $num_facture; + protected $mode_reglement; + protected $montant_encaisse; + protected $montant_rendu; + protected $paiement_le; - protected $prix_total_ht; - protected $montant_tva; - protected $prix_total_ttc; + protected $prix_total_ht; + protected $montant_tva; + protected $prix_total_ttc; - /** - * Constructor - */ - public function __construct() - { - $this->raz(); - $this->razPers(); - } + /** + * Constructor + */ + public function __construct() + { + $this->raz(); + $this->razPers(); + } - // Data processing methods + // Data processing methods - /** - * Add a product into cart - * - * @return void - */ - public function ajoutArticle() - { - global $conf, $db, $mysoc; + /** + * Add a product into cart + * + * @return void + */ + public function ajoutArticle() + { + global $conf, $db, $mysoc; - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); - $societe->fetch($thirdpartyid); + $societe = new Societe($db); + $societe->fetch($thirdpartyid); - $product = new Product($db); - $product->fetch($this->id); + $product = new Product($db); + $product->fetch($this->id); - $vatrowid = $this->tva(); + $vatrowid = $this->tva(); - $tmp = getTaxesFromId($vatrowid); - $txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')'); - $vat_npr = $tmp['npr']; + $tmp = getTaxesFromId($vatrowid); + $txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')'); + $vat_npr = $tmp['npr']; - $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); + $localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1); - // Clean vat code - $reg = array(); - $vat_src_code = ''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // Clean vat code + $reg = array(); + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } - // Define part of HT, VAT, TTC - $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); + // Define part of HT, VAT, TTC + $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); - // Calculation of total HT without discount - $total_ht = $resultarray[0]; - $total_vat = $resultarray[1]; - $total_ttc = $resultarray[2]; - $total_localtax1 = $resultarray[9]; - $total_localtax2 = $resultarray[10]; + // Calculation of total HT without discount + $total_ht = $resultarray[0]; + $total_vat = $resultarray[1]; + $total_ttc = $resultarray[2]; + $total_localtax1 = $resultarray[9]; + $total_localtax2 = $resultarray[10]; - // Calculation of the discount amount - if ($this->remisePercent()) - { - $remise_percent = $this->remisePercent(); - } else { - $remise_percent = 0; - } - $montant_remise_ht = ($resultarray[6] - $resultarray[0]); - $this->amountDiscount($montant_remise_ht); + // Calculation of the discount amount + if ($this->remisePercent()) + { + $remise_percent = $this->remisePercent(); + } else { + $remise_percent = 0; + } + $montant_remise_ht = ($resultarray[6] - $resultarray[0]); + $this->amountDiscount($montant_remise_ht); - $newcartarray = $_SESSION['poscart']; + $newcartarray = $_SESSION['poscart']; - $i = 0; - if (!is_null($newcartarray) && !empty($newcartarray)) { - $i = count($newcartarray); - } + $i = 0; + if (!is_null($newcartarray) && !empty($newcartarray)) { + $i = count($newcartarray); + } - $newcartarray[$i]['id'] = $i; - $newcartarray[$i]['ref'] = $product->ref; - $newcartarray[$i]['label'] = $product->label; - $newcartarray[$i]['price'] = $product->price; - $newcartarray[$i]['price_ttc'] = $product->price_ttc; + $newcartarray[$i]['id'] = $i; + $newcartarray[$i]['ref'] = $product->ref; + $newcartarray[$i]['label'] = $product->label; + $newcartarray[$i]['price'] = $product->price; + $newcartarray[$i]['price_ttc'] = $product->price_ttc; - if (!empty($conf->global->PRODUIT_MULTIPRICES)) - { - if (isset($product->multiprices[$societe->price_level])) - { - $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; - $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; - } - } + if (!empty($conf->global->PRODUIT_MULTIPRICES)) + { + if (isset($product->multiprices[$societe->price_level])) + { + $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; + $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; + } + } - $newcartarray[$i]['fk_article'] = $this->id; - $newcartarray[$i]['qte'] = $this->qte(); - $newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid - $newcartarray[$i]['remise_percent'] = $remise_percent; - $newcartarray[$i]['remise'] = price2num($montant_remise_ht); - $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); - $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); - $newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT'); - $newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT'); - $newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT'); - $_SESSION['poscart'] = $newcartarray; + $newcartarray[$i]['fk_article'] = $this->id; + $newcartarray[$i]['qte'] = $this->qte(); + $newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid + $newcartarray[$i]['remise_percent'] = $remise_percent; + $newcartarray[$i]['remise'] = price2num($montant_remise_ht); + $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); + $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); + $newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT'); + $newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT'); + $newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT'); + $_SESSION['poscart'] = $newcartarray; - $this->raz(); - } + $this->raz(); + } - /** - * Remove a product from panel - * - * @param int $aArticle Id of line into cart to remove - * @return void - */ - public function supprArticle($aArticle) - { - $poscart = $_SESSION['poscart']; + /** + * Remove a product from panel + * + * @param int $aArticle Id of line into cart to remove + * @return void + */ + public function supprArticle($aArticle) + { + $poscart = $_SESSION['poscart']; - $j = 0; - $newposcart = array(); - foreach ($poscart as $key => $val) - { - if ($poscart[$key]['id'] != $aArticle) - { - $newposcart[$j] = $poscart[$key]; - $newposcart[$j]['id'] = $j; - $j++; - } - } - unset($poscart); - //var_dump($poscart);exit; - $_SESSION['poscart'] = $newposcart; - } + $j = 0; + $newposcart = array(); + foreach ($poscart as $key => $val) + { + if ($poscart[$key]['id'] != $aArticle) + { + $newposcart[$j] = $poscart[$key]; + $newposcart[$j]['id'] = $j; + $j++; + } + } + unset($poscart); + //var_dump($poscart);exit; + $_SESSION['poscart'] = $newposcart; + } - /** - * Calculation of total HT, total TTC and VAT amounts - * - * @return int Total - */ - public function calculTotaux() - { - global $db; + /** + * Calculation of total HT, total TTC and VAT amounts + * + * @return int Total + */ + public function calculTotaux() + { + global $db; - $total_ht = 0; - $total_ttc = 0; - $total_vat = 0; - $total_localtax1 = 0; - $total_localtax2 = 0; + $total_ht = 0; + $total_ttc = 0; + $total_vat = 0; + $total_localtax1 = 0; + $total_localtax2 = 0; - $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); + $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); - $tab_size = count($tab); - for ($i = 0; $i < $tab_size; $i++) - { - // Total HT - $remise = $tab[$i]['remise']; - $total_ht += ($tab[$i]['total_ht']); - $total_vat += ($tab[$i]['total_vat']); - $total_ttc += ($tab[$i]['total_ttc']); - $total_localtax1 += ($tab[$i]['total_localtax1']); - $total_localtax2 += ($tab[$i]['total_localtax2']); - } + $tab_size = count($tab); + for ($i = 0; $i < $tab_size; $i++) + { + // Total HT + $remise = $tab[$i]['remise']; + $total_ht += ($tab[$i]['total_ht']); + $total_vat += ($tab[$i]['total_vat']); + $total_ttc += ($tab[$i]['total_ttc']); + $total_localtax1 += ($tab[$i]['total_localtax1']); + $total_localtax2 += ($tab[$i]['total_localtax2']); + } - $this->prix_total_ttc = $total_ttc; - $this->prix_total_ht = $total_ht; - $this->prix_total_vat = $total_vat; - $this->prix_total_localtax1 = $total_localtax1; - $this->prix_total_localtax2 = $total_localtax2; + $this->prix_total_ttc = $total_ttc; + $this->prix_total_ht = $total_ht; + $this->prix_total_vat = $total_vat; + $this->prix_total_localtax1 = $total_localtax1; + $this->prix_total_localtax2 = $total_localtax2; - $this->montant_tva = $total_ttc - $total_ht; - //print 'total: '.$this->prix_total_ttc; exit; - } + $this->montant_tva = $total_ttc - $total_ht; + //print 'total: '.$this->prix_total_ttc; exit; + } - /** - * Reset attributes - * - * @return void - */ - public function raz() - { - $this->id('RESET'); - $this->ref('RESET'); - $this->qte('RESET'); - $this->stock('RESET'); - $this->remisePercent('RESET'); - $this->amountDiscount('RESET'); - $this->prix('RESET'); - $this->tva('RESET'); - } + /** + * Reset attributes + * + * @return void + */ + public function raz() + { + $this->id('RESET'); + $this->ref('RESET'); + $this->qte('RESET'); + $this->stock('RESET'); + $this->remisePercent('RESET'); + $this->amountDiscount('RESET'); + $this->prix('RESET'); + $this->tva('RESET'); + } - /** - * Resetting persistent attributes - * - * @return void - */ - private function razPers() - { - $this->numInvoice('RESET'); - $this->getSetPaymentMode('RESET'); - $this->amountCollected('RESET'); - $this->amountReturned('RESET'); - $this->paiementLe('RESET'); + /** + * Resetting persistent attributes + * + * @return void + */ + private function razPers() + { + $this->numInvoice('RESET'); + $this->getSetPaymentMode('RESET'); + $this->amountCollected('RESET'); + $this->amountReturned('RESET'); + $this->paiementLe('RESET'); - $this->amountWithoutTax('RESET'); - $this->amountVat('RESET'); - $this->amountWithTax('RESET'); - } + $this->amountWithoutTax('RESET'); + $this->amountVat('RESET'); + $this->amountWithTax('RESET'); + } - // Methods for modifying protected attributes + // Methods for modifying protected attributes - /** - * Getter for id - * - * @param int $aId Id - * @return int Id - */ - public function id($aId = null) - { + /** + * Getter for id + * + * @param int $aId Id + * @return int Id + */ + public function id($aId = null) + { - if (!$aId) - { - return $this->id; - } elseif ($aId == 'RESET') - { - $this->id = null; - } else { - $this->id = $aId; - } - } + if (!$aId) + { + return $this->id; + } elseif ($aId == 'RESET') + { + $this->id = null; + } else { + $this->id = $aId; + } + } - /** - * Getter for ref - * - * @param string $aRef Ref - * @return string Ref - */ - public function ref($aRef = null) - { + /** + * Getter for ref + * + * @param string $aRef Ref + * @return string Ref + */ + public function ref($aRef = null) + { - if (is_null($aRef)) - { - return $this->ref; - } elseif ($aRef == 'RESET') - { - $this->ref = null; - } else { - $this->ref = $aRef; - } - } + if (is_null($aRef)) + { + return $this->ref; + } elseif ($aRef == 'RESET') + { + $this->ref = null; + } else { + $this->ref = $aRef; + } + } - /** - * Getter for qte - * - * @param int $aQte Qty - * @return int Qty - */ - public function qte($aQte = null) - { - if (is_null($aQte)) - { - return $this->qte; - } elseif ($aQte == 'RESET') - { - $this->qte = null; - } else { - $this->qte = $aQte; - } - } + /** + * Getter for qte + * + * @param int $aQte Qty + * @return int Qty + */ + public function qte($aQte = null) + { + if (is_null($aQte)) + { + return $this->qte; + } elseif ($aQte == 'RESET') + { + $this->qte = null; + } else { + $this->qte = $aQte; + } + } - /** - * Getter for stock - * - * @param string $aStock Stock - * @return string Stock - */ - public function stock($aStock = null) - { + /** + * Getter for stock + * + * @param string $aStock Stock + * @return string Stock + */ + public function stock($aStock = null) + { - if (is_null($aStock)) - { - return $this->stock; - } elseif ($aStock == 'RESET') - { - $this->stock = null; - } else { - $this->stock = $aStock; - } - } + if (is_null($aStock)) + { + return $this->stock; + } elseif ($aStock == 'RESET') + { + $this->stock = null; + } else { + $this->stock = $aStock; + } + } - /** - * Getter for remise_percent - * - * @param string $aRemisePercent Discount - * @return string Discount - */ - public function remisePercent($aRemisePercent = null) - { + /** + * Getter for remise_percent + * + * @param string $aRemisePercent Discount + * @return string Discount + */ + public function remisePercent($aRemisePercent = null) + { - if (is_null($aRemisePercent)) - { - return $this->remise_percent; - } elseif ($aRemisePercent == 'RESET') - { - $this->remise_percent = null; - } else { - $this->remise_percent = $aRemisePercent; - } - } + if (is_null($aRemisePercent)) + { + return $this->remise_percent; + } elseif ($aRemisePercent == 'RESET') + { + $this->remise_percent = null; + } else { + $this->remise_percent = $aRemisePercent; + } + } - /** - * Getter for montant_remise - * - * @param int $aMontantRemise Amount - * @return string Amount - */ - public function amountDiscount($aMontantRemise = null) - { + /** + * Getter for montant_remise + * + * @param int $aMontantRemise Amount + * @return string Amount + */ + public function amountDiscount($aMontantRemise = null) + { - if (is_null($aMontantRemise)) { - return $this->montant_remise; - } elseif ($aMontantRemise == 'RESET') { - $this->montant_remise = null; - } else { - $this->montant_remise = $aMontantRemise; - } - } + if (is_null($aMontantRemise)) { + return $this->montant_remise; + } elseif ($aMontantRemise == 'RESET') { + $this->montant_remise = null; + } else { + $this->montant_remise = $aMontantRemise; + } + } - /** - * Getter for prix - * - * @param int $aPrix Price - * @return string Stock - */ - public function prix($aPrix = null) - { + /** + * Getter for prix + * + * @param int $aPrix Price + * @return string Stock + */ + public function prix($aPrix = null) + { - if (is_null($aPrix)) { - return $this->prix; - } elseif ($aPrix == 'RESET') { - $this->prix = null; - } else { - $this->prix = $aPrix; - } - } + if (is_null($aPrix)) { + return $this->prix; + } elseif ($aPrix == 'RESET') { + $this->prix = null; + } else { + $this->prix = $aPrix; + } + } - /** - * Getter for tva - * - * @param int $aTva Vat - * @return int Vat - */ - public function tva($aTva = null) - { - if (is_null($aTva)) { - return $this->tva; - } elseif ($aTva == 'RESET') { - $this->tva = null; - } else { - $this->tva = $aTva; - } - } + /** + * Getter for tva + * + * @param int $aTva Vat + * @return int Vat + */ + public function tva($aTva = null) + { + if (is_null($aTva)) { + return $this->tva; + } elseif ($aTva == 'RESET') { + $this->tva = null; + } else { + $this->tva = $aTva; + } + } - /** - * Get num invoice - * - * @param string $aNumFacture Invoice ref - * @return string Invoice ref - */ - public function numInvoice($aNumFacture = null) - { - if (is_null($aNumFacture)) { - return $this->num_facture; - } elseif ($aNumFacture == 'RESET') { - $this->num_facture = null; - } else { - $this->num_facture = $aNumFacture; - } - } + /** + * Get num invoice + * + * @param string $aNumFacture Invoice ref + * @return string Invoice ref + */ + public function numInvoice($aNumFacture = null) + { + if (is_null($aNumFacture)) { + return $this->num_facture; + } elseif ($aNumFacture == 'RESET') { + $this->num_facture = null; + } else { + $this->num_facture = $aNumFacture; + } + } - /** - * Get payment mode - * - * @param int $aModeReglement Payment mode - * @return int Payment mode - */ - public function getSetPaymentMode($aModeReglement = null) - { + /** + * Get payment mode + * + * @param int $aModeReglement Payment mode + * @return int Payment mode + */ + public function getSetPaymentMode($aModeReglement = null) + { - if (is_null($aModeReglement)) { - return $this->mode_reglement; - } elseif ($aModeReglement == 'RESET') { - $this->mode_reglement = null; - } else { - $this->mode_reglement = $aModeReglement; - } - } + if (is_null($aModeReglement)) { + return $this->mode_reglement; + } elseif ($aModeReglement == 'RESET') { + $this->mode_reglement = null; + } else { + $this->mode_reglement = $aModeReglement; + } + } - /** - * Get amount - * - * @param int $aMontantEncaisse Amount - * @return int Amount - */ - public function amountCollected($aMontantEncaisse = null) - { + /** + * Get amount + * + * @param int $aMontantEncaisse Amount + * @return int Amount + */ + public function amountCollected($aMontantEncaisse = null) + { - if (is_null($aMontantEncaisse)) { - return $this->montant_encaisse; - } elseif ($aMontantEncaisse == 'RESET') { - $this->montant_encaisse = null; - } else { - $this->montant_encaisse = $aMontantEncaisse; - } - } + if (is_null($aMontantEncaisse)) { + return $this->montant_encaisse; + } elseif ($aMontantEncaisse == 'RESET') { + $this->montant_encaisse = null; + } else { + $this->montant_encaisse = $aMontantEncaisse; + } + } - /** - * Get amount - * - * @param int $aMontantRendu Amount - * @return int Amount - */ - public function amountReturned($aMontantRendu = null) - { + /** + * Get amount + * + * @param int $aMontantRendu Amount + * @return int Amount + */ + public function amountReturned($aMontantRendu = null) + { - if (is_null($aMontantRendu)) { - return $this->montant_rendu; - } elseif ($aMontantRendu == 'RESET') { - $this->montant_rendu = null; - } else { - $this->montant_rendu = $aMontantRendu; - } - } + if (is_null($aMontantRendu)) { + return $this->montant_rendu; + } elseif ($aMontantRendu == 'RESET') { + $this->montant_rendu = null; + } else { + $this->montant_rendu = $aMontantRendu; + } + } - /** - * Get payment date - * - * @param integer $aPaiementLe Date - * @return integer Date - */ - public function paiementLe($aPaiementLe = null) - { - if (is_null($aPaiementLe)) { - return $this->paiement_le; - } elseif ($aPaiementLe == 'RESET') { - $this->paiement_le = null; - } else { - $this->paiement_le = $aPaiementLe; - } - } + /** + * Get payment date + * + * @param integer $aPaiementLe Date + * @return integer Date + */ + public function paiementLe($aPaiementLe = null) + { + if (is_null($aPaiementLe)) { + return $this->paiement_le; + } elseif ($aPaiementLe == 'RESET') { + $this->paiement_le = null; + } else { + $this->paiement_le = $aPaiementLe; + } + } - /** - * Get total HT - * - * @param int $aTotalHt Total amount - * @return int Total amount - */ - public function amountWithoutTax($aTotalHt = null) - { - if (is_null($aTotalHt)) { - return $this->prix_total_ht; - } elseif ($aTotalHt == 'RESET') { - $this->prix_total_ht = null; - } else { - $this->prix_total_ht = $aTotalHt; - } - } + /** + * Get total HT + * + * @param int $aTotalHt Total amount + * @return int Total amount + */ + public function amountWithoutTax($aTotalHt = null) + { + if (is_null($aTotalHt)) { + return $this->prix_total_ht; + } elseif ($aTotalHt == 'RESET') { + $this->prix_total_ht = null; + } else { + $this->prix_total_ht = $aTotalHt; + } + } - /** - * Get amount vat - * - * @param int $aMontantTva Amount vat - * @return int Amount vat - */ - public function amountVat($aMontantTva = null) - { - if (is_null($aMontantTva)) { - return $this->montant_tva; - } elseif ($aMontantTva == 'RESET') { - $this->montant_tva = null; - } else { - $this->montant_tva = $aMontantTva; - } - } + /** + * Get amount vat + * + * @param int $aMontantTva Amount vat + * @return int Amount vat + */ + public function amountVat($aMontantTva = null) + { + if (is_null($aMontantTva)) { + return $this->montant_tva; + } elseif ($aMontantTva == 'RESET') { + $this->montant_tva = null; + } else { + $this->montant_tva = $aMontantTva; + } + } - /** - * Get total TTC - * - * @param int $aTotalTtc Amount ttc - * @return int Amount ttc - */ - public function amountWithTax($aTotalTtc = null) - { - if (is_null($aTotalTtc)) - { - return $this->prix_total_ttc; - } elseif ($aTotalTtc == 'RESET') - { - $this->prix_total_ttc = null; - } else { - $this->prix_total_ttc = $aTotalTtc; - } - } + /** + * Get total TTC + * + * @param int $aTotalTtc Amount ttc + * @return int Amount ttc + */ + public function amountWithTax($aTotalTtc = null) + { + if (is_null($aTotalTtc)) + { + return $this->prix_total_ttc; + } elseif ($aTotalTtc == 'RESET') + { + $this->prix_total_ttc = null; + } else { + $this->prix_total_ttc = $aTotalTtc; + } + } } diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 16b4bfec017..76ad8571118 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -67,15 +67,15 @@ switch ($action) { $ret[$key] = $value; } - // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function + // Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function $productid = $ret['rowid']; $product = new Product($db); - $product->fetch($productid); - $prod = $product; + $product->fetch($productid); + $prod = $product; $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); + $societe = new Societe($db); $societe->fetch($thirdpartyid); // Update if prices fields are defined @@ -91,39 +91,39 @@ switch ($action) // multiprix if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($societe->price_level)) { - $pu_ht = $prod->multiprices[$societe->price_level]; - $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; - $price_min = $prod->multiprices_min[$societe->price_level]; - $price_base_type = $prod->multiprices_base_type[$societe->price_level]; - if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility - { - if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx = $prod->multiprices_tva_tx[$societe->price_level]; - if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level]; - } + $pu_ht = $prod->multiprices[$societe->price_level]; + $pu_ttc = $prod->multiprices_ttc[$societe->price_level]; + $price_min = $prod->multiprices_min[$societe->price_level]; + $price_base_type = $prod->multiprices_base_type[$societe->price_level]; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$societe->price_level])) $tva_tx = $prod->multiprices_tva_tx[$societe->price_level]; + if (isset($prod->multiprices_recuperableonly[$societe->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$societe->price_level]; + } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; - $prodcustprice = new Productcustomerprice($db); + $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id); + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id); - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) - { - if (count($prodcustprice->lines) > 0) - { - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; - $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr = 0; - } - } else { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); - } + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) + { + if (count($prodcustprice->lines) > 0) + { + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $tva_tx = $prodcustprice->lines[0]->tva_tx; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_npr = $prodcustprice->lines[0]->recuperableonly; + if (empty($tva_tx)) $tva_npr = 0; + } + } else { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); + } } $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); @@ -131,17 +131,17 @@ switch ($action) // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? if (!empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). elseif ($tmpvat != $tmpprodvat) { - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } + if ($price_base_type != 'HT') { + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + } else { + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } } $obj_facturation->id($ret['rowid']); @@ -187,17 +187,17 @@ switch ($action) $newthirdpartyid = GETPOST('CASHDESK_ID_THIRDPARTY', 'int'); if ($newthirdpartyid > 0) { - $_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid; + $_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid; } $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation'; - break; + break; case 'ajout_article': // We have clicked on button "Add product" if (!empty($obj_facturation->id)) // A product was previously selected and stored in session, so we can add it { - dol_syslog("facturation_verif save vat ".$_POST['selTva']); + dol_syslog("facturation_verif save vat ".$_POST['selTva']); $obj_facturation->qte($_POST['txtQte']); $obj_facturation->tva($_POST['selTva']); // id of vat. Saved so we can use it for next product $obj_facturation->remisePercent($_POST['txtRemise']); diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index e8366e981cc..45ce3857068 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -51,9 +51,9 @@ if (empty($username)) // Check third party id if (!($thirdpartyid > 0)) { - $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); - header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); - exit; + $retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell")); + header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb); + exit; } // If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished. @@ -107,12 +107,12 @@ if ($retour >= 0) $_SESSION['lastname'] = $tab['lastname']; $_SESSION['firstname'] = $tab['firstname']; $_SESSION['CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid : ''); - $_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : ''); + $_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : ''); - $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); - //var_dump($_SESSION);exit; + $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : ''); + $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : ''); + $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : ''); + //var_dump($_SESSION);exit; header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV'); exit; @@ -121,7 +121,7 @@ if ($retour >= 0) } } else { // Load translation files required by the page - $langs->loadLangs(array("other", "errors")); + $langs->loadLangs(array("other", "errors")); $retour = $langs->trans("ErrorBadLoginPassword"); header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid); exit; diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index d9d12c5d84e..d48fc544eb0 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -118,7 +118,7 @@ for ($i = 0; $i < $nbtoshow; $i++) $buyer = new Societe($db); if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1); - ?> + ?> diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index bd73954f6a0..e3c3c285966 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -50,22 +50,22 @@ $tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); $tab_size = count($tab); if ($tab_size <= 0) print '
'.$langs->trans("NoArticle").'

'; else { - for ($i = 0; $i < $tab_size; $i++) - { - echo ('
'."\n"); - echo ('

'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

'."\n"); + for ($i = 0; $i < $tab_size; $i++) + { + echo ('
'."\n"); + echo ('

'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

'."\n"); - if ($tab[$i]['remise_percent'] > 0) { - $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; - } else { - $remise_percent = ''; - } + if ($tab[$i]['remise_percent'] > 0) { + $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; + } else { + $remise_percent = ''; + } - $remise = $tab[$i]['remise']; + $remise = $tab[$i]['remise']; - echo ('

'.$tab[$i]['qte'].' x '.price2num($tab[$i]['price'], 'MT').$remise_percent.' = '.price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT").' ('.price(price2num($tab[$i]['total_ttc'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC").')

'."\n"); - echo ('
'."\n"); - } + echo ('

'.$tab[$i]['qte'].' x '.price2num($tab[$i]['price'], 'MT').$remise_percent.' = '.price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT").' ('.price(price2num($tab[$i]['total_ttc'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC").')

'."\n"); + echo ('
'."\n"); + } } echo ('

'.$langs->trans("Total").' : '.price(price2num($total_ttc, 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'

'."\n"); diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index b5994456252..101ea687e7b 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -55,11 +55,11 @@ $object->fetch($facid);

'; - print $object->ref; - ?>

+ // Recuperation et affichage de la date et de l'heure + $now = dol_now(); + print dol_print_date($now, 'dayhourtext').'
'; + print $object->ref; + ?>

@@ -78,14 +78,14 @@ $object->fetch($facid); + $tab_size = count($tab); + for ($i = 0; $i < $tab_size; $i++) + { + $remise = $tab[$i]['remise']; + ?> @@ -94,8 +94,8 @@ $object->fetch($facid); currency); ?> + } + ?> diff --git a/htdocs/cashdesk/validation_ticket.php b/htdocs/cashdesk/validation_ticket.php index 7e4e101c9b8..28ad91dc4e7 100644 --- a/htdocs/cashdesk/validation_ticket.php +++ b/htdocs/cashdesk/validation_ticket.php @@ -35,7 +35,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $obj_facturation); if (empty($reshook)) { - require 'tpl/ticket.tpl.php'; + require 'tpl/ticket.tpl.php'; } diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index d57aaa251ce..9468c395756 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -39,11 +39,11 @@ $bankaccountid = GETPOST('cashdeskbank'); switch ($action) { default: - $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; + $redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation'; break; case 'validate_sell': - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; $company = new Societe($db); $company->fetch($thirdpartyid); @@ -97,9 +97,9 @@ switch ($action) $obj_facturation->amountReturned($encaisse - $total); } else { - //$txtDatePaiement=$_POST['txtDatePaiement']; - $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']); - $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc'); + //$txtDatePaiement=$_POST['txtDatePaiement']; + $datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']); + $txtDatePaiement = dol_print_date($datePaiement, 'dayrfc'); $obj_facturation->paiementLe($txtDatePaiement); } @@ -252,12 +252,12 @@ switch ($action) } } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + $error++; } $id = $invoice->id; } else { - $resultcreate = $invoice->create($user, 0, 0); + $resultcreate = $invoice->create($user, 0, 0); if ($resultcreate > 0) { $warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0); @@ -282,8 +282,8 @@ switch ($action) if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); else $result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref)); if ($result < 0) { - setEventMessages($mouvP->error, $mouvP->errors, 'errors'); - $error++; + setEventMessages($mouvP->error, $mouvP->errors, 'errors'); + $error++; } } } @@ -303,33 +303,33 @@ switch ($action) $paiement_id = $payment->create($user); if ($paiement_id > 0) { - if (!$error) - { - $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); - if (!$result > 0) - { - $errmsg = $paiement->error; - $error++; - } - } + if (!$error) + { + $result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', ''); + if (!$result > 0) + { + $errmsg = $paiement->error; + $error++; + } + } - if (!$error) - { - if ($invoice->total_ttc == $obj_facturation->amountWithTax() - && $obj_facturation->getSetPaymentMode() != 'DIFF') - { - // We set status to payed - $result = $invoice->set_paid($user); - //print 'set paid';exit; - } - } + if (!$error) + { + if ($invoice->total_ttc == $obj_facturation->amountWithTax() + && $obj_facturation->getSetPaymentMode() != 'DIFF') + { + // We set status to payed + $result = $invoice->set_paid($user); + //print 'set paid';exit; + } + } } else { - setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + setEventMessages($invoice->error, $invoice->errors, 'errors'); + $error++; } } else { setEventMessages($invoice->error, $invoice->errors, 'errors'); - $error++; + $error++; } } diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php index f9127914059..693a3e53a2a 100644 --- a/htdocs/categories/admin/categorie.php +++ b/htdocs/categories/admin/categorie.php @@ -42,26 +42,26 @@ $action = GETPOST('action', 'aZ09'); $reg = array(); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - setEventMessages($db->lasterror(), null, 'errors'); - } + $code = $reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + setEventMessages($db->lasterror(), null, 'errors'); + } } if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - setEventMessages($db->lasterror(), null, 'errors'); - } + $code = $reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + setEventMessages($db->lasterror(), null, 'errors'); + } } diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 9bc1dd685ff..ff6a4ca7881 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -78,9 +78,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -93,9 +93,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -105,10 +105,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 6598387c36a..40542e70f6f 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -264,7 +264,7 @@ if ($user->rights->categorie->creer) $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index d37bdfed04d..3aca92708a7 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1551,7 +1551,7 @@ class Categorie extends CommonObject if (colorIsLight($this->color)) $forced_color = 'categtextblack'; } - $link = ''; + $link = ''; $linkend = ''; $picto = 'category'; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 4b4eaffeb57..7764341dfd7 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -56,7 +56,7 @@ $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); if ($id > 0) { - $result = $object->fetch($id); + $result = $object->fetch($id); } $extrafields = new ExtraFields($db); @@ -73,23 +73,23 @@ $error = 0; */ if ($cancel) { - header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); - exit; + header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); + exit; } // Action mise a jour d'une categorie if ($action == 'update' && $user->rights->categorie->creer) { - $object->oldcopy = dol_clone($object); + $object->oldcopy = dol_clone($object); $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; - $object->fk_parent = $parent != -1 ? $parent : 0; + $object->fk_parent = $parent != -1 ? $parent : 0; if (empty($object->label)) { - $error++; + $error++; $action = 'edit'; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index 5bd8f6c9d24..f64f3be8f9e 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -44,8 +44,8 @@ $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); if (!$object->fetch($id) > 0) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } $type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -72,7 +72,7 @@ $object->ref = $object->label; $morehtmlref = '
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); foreach ($ways as $way) { - $morehtmlref .= $way."
\n"; + $morehtmlref .= $way."
\n"; } $morehtmlref .= '
'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 280b278657c..4306bc728d6 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -126,19 +126,19 @@ if ($id > 0 && $removeelem > 0) $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; - } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) - { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $tmpobject = new Account($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'account'; - } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) - { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $tmpobject = new Project($db); - $result = $tmpobject->fetch($removeelem); - $elementtype = 'project'; - } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) + } elseif ($type == Categorie::TYPE_ACCOUNT && $user->rights->banque->configurer) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $tmpobject = new Account($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'account'; + } elseif ($type == Categorie::TYPE_PROJECT && $user->rights->projet->creer) + { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $tmpobject = new Project($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'project'; + } elseif ($type == Categorie::TYPE_USER && $user->rights->user->user->creer) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $tmpobject = new User($db); @@ -162,9 +162,9 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } if ($elemid && $action == 'addintocategory' && - (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || - ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || - ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) + (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || + ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || + ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) )) { if ($type == Categorie::TYPE_PRODUCT) @@ -227,7 +227,7 @@ $morehtmlref = '
'; @@ -801,61 +801,61 @@ if ($type == Categorie::TYPE_CONTACT) // List of bank accounts if ($type == Categorie::TYPE_ACCOUNT) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $permission = $user->rights->banque->creer; + $permission = $user->rights->banque->creer; - $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); - if ($accounts < 0) - { - dol_print_error($db, $object->error, $object->errors); - } else { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($accounts < 0) + { + dol_print_error($db, $object->error, $object->errors); + } else { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($accounts); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); - print "\n"; - print ''."\n"; + print "
'.$langs->trans("Ref").'
\n"; + print ''."\n"; - if (count($accounts) > 0) - { - $i = 0; - foreach ($accounts as $key => $account) - { - $i++; - if ($i > $limit) break; + if (count($accounts) > 0) + { + $i = 0; + foreach ($accounts as $key => $account) + { + $i++; + if ($i > $limit) break; - print "\t".''."\n"; - print '\n"; - print '\n"; - print '\n"; - // Link to delete from category - print '\n"; - } - } else { - print ''; - } - print "
'.$langs->trans("Ref").'
'; - print $account->getNomUrl(1, 0); - print "'.$account->bank."'.$account->number."'; - if ($permission) - { - print ""; - print $langs->trans("DeleteFromCat"); - print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); - print ""; - } - print "
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + print "\t".''."\n"; + print ''; + print $account->getNomUrl(1, 0); + print "\n"; + print ''.$account->bank."\n"; + print ''.$account->number."\n"; + // Link to delete from category + print ''; + if ($permission) + { + print "
"; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print "\n"; + } + } else { + print ''.$langs->trans("ThisCategoryHasNoItems").''; + } + print "\n"; - print ''."\n"; - } + print ''."\n"; + } } // List of Project diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index a46e302bd4b..99326bb6abf 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -96,14 +96,14 @@ $formactions = new FormActions($db); // Load object if ($id > 0 && $action != 'add') { - $ret = $object->fetch($id); - if ($ret > 0) { - $ret = $object->fetch_optionals(); - $ret1 = $object->fetch_userassigned(); - } - if ($ret < 0 || $ret1 < 0) { - dol_print_error('', $object->error); - } + $ret = $object->fetch($id); + if ($ret > 0) { + $ret = $object->fetch_optionals(); + $ret1 = $object->fetch_userassigned(); + } + if ($ret < 0 || $ret1 < 0) { + dol_print_error('', $object->error); + } } // fetch optionals attributes and labels @@ -172,10 +172,10 @@ if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedt // Link to a project if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allactions->create || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { - //$object->fetch($id); - $object->setProject(GETPOST('projectid', 'int')); + //$object->fetch($id); + $object->setProject(GETPOST('projectid', 'int')); } // Action clone object @@ -187,10 +187,10 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') } else { if ($id > 0) { //$object->fetch($id); - if (!empty($object->socpeopleassigned)) { - reset($object->socpeopleassigned); - $object->contact_id = key($object->socpeopleassigned); - } + if (!empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contact_id = key($object->socpeopleassigned); + } $result = $object->createFromClone($user, GETPOST('socid', 'int')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -208,13 +208,13 @@ if (empty($reshook) && $action == 'add') { $error = 0; - if (empty($backtopage)) - { - if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; - else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; - } + if (empty($backtopage)) + { + if ($socid > 0) $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid; + else $backtopage = DOL_URL_ROOT.'/comm/action/index.php'; + } - if (!empty($socpeopleassigned[0])) + if (!empty($socpeopleassigned[0])) { $result = $contact->fetch($socpeopleassigned[0]); } @@ -225,9 +225,9 @@ if (empty($reshook) && $action == 'add') exit; } - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status - // Clean parameters + // Clean parameters $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); @@ -284,13 +284,13 @@ if (empty($reshook) && $action == 'add') $taskid = GETPOST('taskid', 'int'); if (!empty($taskid)) { - $taskProject = new Task($db); - if ($taskProject->fetch($taskid) > 0) { - $object->fk_project = $taskProject->fk_project; - } + $taskProject = new Task($db); + if ($taskProject->fetch($taskid) > 0) { + $object->fk_project = $taskProject->fk_project; + } - $object->fk_element = $taskid; - $object->elementtype = 'task'; + $object->fk_element = $taskid; + $object->elementtype = 'task'; } $object->datep = $datep; @@ -390,7 +390,7 @@ if (empty($reshook) && $action == 'add') if ($user->id != $object->userownerid) $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. // Create reminders - if ($addreminder == 'on'){ + if ($addreminder == 'on') { $actionCommReminder = new ActionCommReminder($db); $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); @@ -409,7 +409,7 @@ if (empty($reshook) && $action == 'add') $actionCommReminder->fk_user = $userassigned['id']; $res = $actionCommReminder->create($user); - if ($res <= 0){ + if ($res <= 0) { // If error $db->rollback(); $langs->load("errors"); @@ -419,13 +419,13 @@ if (empty($reshook) && $action == 'add') break; } } - } + } - if ($error) { - $db->rollback(); - } else { + if ($error) { + $db->rollback(); + } else { $db->commit(); - } + } if (!empty($backtopage)) { @@ -461,14 +461,14 @@ if (empty($reshook) && $action == 'update') { if (empty($cancel)) { - $fulldayevent = GETPOST('fullday'); - $aphour = GETPOST('aphour'); - $apmin = GETPOST('apmin'); - $p2hour = GETPOST('p2hour'); - $p2min = GETPOST('p2min'); + $fulldayevent = GETPOST('fullday'); + $aphour = GETPOST('aphour'); + $apmin = GETPOST('apmin'); + $p2hour = GETPOST('p2hour'); + $p2min = GETPOST('p2min'); $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status - // Clean parameters + // Clean parameters if ($aphour == -1) $aphour = '0'; if ($apmin == -1) $apmin = '0'; if ($p2hour == -1) $p2hour = '0'; @@ -494,7 +494,7 @@ if (empty($reshook) && $action == 'update') $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); $object->socpeopleassigned = array(); foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); - $object->contact_id = GETPOST("contactid", 'int'); + $object->contact_id = GETPOST("contactid", 'int'); if (empty($object->contact_id) && !empty($object->socpeopleassigned)) { reset($object->socpeopleassigned); $object->contact_id = key($object->socpeopleassigned); @@ -564,64 +564,64 @@ if (empty($reshook) && $action == 'update') $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (!$error) { - // check if an event resource is already in use - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { - $eventDateStart = $object->datep; - $eventDateEnd = $object->datef; + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; - $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; - $sql .= " WHERE ac.id != ".$object->id; - $sql .= " AND er.resource_id IN ("; - $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE element_id = ".$object->id; - $sql .= " AND element_type = '".$db->escape($object->element)."'"; - $sql .= " AND busy = 1"; - $sql .= ")"; - $sql .= " AND er.busy = 1"; - $sql .= " AND ("; + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; + $sql .= " WHERE ac.id != ".$object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; + $sql .= " WHERE element_id = ".$object->id; + $sql .= " AND element_type = '".$db->escape($object->element)."'"; + $sql .= " AND busy = 1"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; - // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; - // event date end between ac.datep and ac.datep2 - if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; - } - // event date start before ac.datep and event date end after ac.datep2 - $sql .= " OR ("; - $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; - if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; - } - $sql .= ")"; + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; + } + $sql .= ")"; - $sql .= ")"; - $resql = $db->query($sql); - if (!$resql) { - $error++; - $object->error = $db->lasterror(); - $object->errors[] = $object->error; - } else { - if ($db->num_rows($resql) > 0) { - // already in use - $error++; - $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; - while ($obj = $db->fetch_object($resql)) { - $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); - } - $object->errors[] = $object->error; - } - $db->free($resql); - } + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } - if ($error) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } if (!$error) { @@ -646,7 +646,7 @@ if (empty($reshook) && $action == 'update') } //Create reminders - if ($addreminder == 'on' && $object->datep > dol_now()){ + if ($addreminder == 'on' && $object->datep > dol_now()) { $actionCommReminder = new ActionCommReminder($db); $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); @@ -665,7 +665,7 @@ if (empty($reshook) && $action == 'update') $actionCommReminder->fk_user = $userassigned['id']; $res = $actionCommReminder->create($user); - if ($res <= 0){ + if ($res <= 0) { // If error $langs->load("errors"); $error = $langs->trans('ErrorReminderActionCommCreation'); @@ -689,12 +689,12 @@ if (empty($reshook) && $action == 'update') if (!$error) { - if (!empty($backtopage)) - { - unset($_SESSION['assignedtouser']); - header("Location: ".$backtopage); - exit; - } + if (!empty($backtopage)) + { + unset($_SESSION['assignedtouser']); + header("Location: ".$backtopage); + exit; + } } } @@ -704,9 +704,9 @@ if (empty($reshook) && $action == 'update') if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') { $object->fetch($id); - $object->fetch_optionals(); - $object->fetch_userassigned(); - $object->oldcopy = clone $object; + $object->fetch_optionals(); + $object->fetch_userassigned(); + $object->oldcopy = clone $object; if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) @@ -729,112 +729,112 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes */ if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') { - $error = 0; + $error = 0; - $shour = dol_print_date($object->datep, "%H"); - $smin = dol_print_date($object->datep, "%M"); + $shour = dol_print_date($object->datep, "%H"); + $smin = dol_print_date($object->datep, "%M"); - $newdate = GETPOST('newdate', 'alpha'); - if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) - { - header("Location: ".$backtopage); - exit; - } + $newdate = GETPOST('newdate', 'alpha'); + if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) + { + header("Location: ".$backtopage); + exit; + } - $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4)); - if ($datep != $object->datep) - { - if (!empty($object->datef)) - { - $object->datef += $datep - $object->datep; - } - $object->datep = $datep; + $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4)); + if ($datep != $object->datep) + { + if (!empty($object->datef)) + { + $object->datef += $datep - $object->datep; + } + $object->datep = $datep; - if (!$error) { - // check if an event resource is already in use - if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { - $eventDateStart = $object->datep; - $eventDateEnd = $object->datef; + if (!$error) { + // check if an event resource is already in use + if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') { + $eventDateStart = $object->datep; + $eventDateEnd = $object->datef; - $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; - $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; - $sql .= " WHERE ac.id != ".$object->id; - $sql .= " AND er.resource_id IN ("; - $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE element_id = ".$object->id; - $sql .= " AND element_type = '".$db->escape($object->element)."'"; - $sql .= " AND busy = 1"; - $sql .= ")"; - $sql .= " AND er.busy = 1"; - $sql .= " AND ("; + $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'"; + $sql .= " WHERE ac.id != ".$object->id; + $sql .= " AND er.resource_id IN ("; + $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources"; + $sql .= " WHERE element_id = ".$object->id; + $sql .= " AND element_type = '".$db->escape($object->element)."'"; + $sql .= " AND busy = 1"; + $sql .= ")"; + $sql .= " AND er.busy = 1"; + $sql .= " AND ("; - // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) - $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; - // event date end between ac.datep and ac.datep2 - if (!empty($eventDateEnd)) { - $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; - } - // event date start before ac.datep and event date end after ac.datep2 - $sql .= " OR ("; - $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; - if (!empty($eventDateEnd)) { - $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; - } - $sql .= ")"; + // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end) + $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))"; + // event date end between ac.datep and ac.datep2 + if (!empty($eventDateEnd)) { + $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))"; + } + // event date start before ac.datep and event date end after ac.datep2 + $sql .= " OR ("; + $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'"; + if (!empty($eventDateEnd)) { + $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')"; + } + $sql .= ")"; - $sql .= ")"; - $resql = $db->query($sql); - if (!$resql) { - $error++; - $object->error = $db->lasterror(); - $object->errors[] = $object->error; - } else { - if ($db->num_rows($resql) > 0) { - // already in use - $error++; - $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; - while ($obj = $db->fetch_object($resql)) { - $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); - } - $object->errors[] = $object->error; - } - $db->free($resql); - } + $sql .= ")"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $object->error = $db->lasterror(); + $object->errors[] = $object->error; + } else { + if ($db->num_rows($resql) > 0) { + // already in use + $error++; + $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : '; + while ($obj = $db->fetch_object($resql)) { + $object->error .= '
- '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']'); + } + $object->errors[] = $object->error; + } + $db->free($resql); + } - if ($error) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } + if ($error) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } - if (!$error) { - $db->begin(); - $result = $object->update($user); - if ($result < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); - } else { - $db->commit(); - } - } - } - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } else { - $action = ''; - } + if (!$error) { + $db->begin(); + $result = $object->update($user); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } else { + $db->commit(); + } + } + } + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } else { + $action = ''; + } } // Actions to delete doc $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); $permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read)); if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -869,10 +869,10 @@ if ($action == 'create') dol_set_focus("#label"); - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - } + print ''."\n"; + } print '
'; print ''; @@ -972,7 +972,7 @@ if ($action == 'create') print ''.$langs->trans("DateActionEnd").''; print ''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // Empty value not allowed for start date and hours if "todo" + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // Empty value not allowed for start date and hours if "todo" } else { print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart'); } @@ -997,7 +997,7 @@ if ($action == 'create') } print '';*/ - // Dev in progress + // Dev in progress $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { @@ -1061,11 +1061,11 @@ if ($action == 'create') $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''.$langs->trans("Location").''; - } + } // Assigned to print ''.$langs->trans("ActionAffectedTo").''; @@ -1206,24 +1206,24 @@ if ($action == 'create') } // Priority - if (! empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { + if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { print ''.$langs->trans("Priority").''; print ''; print ''; } - // Description - print ''.$langs->trans("Description").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', (GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : $object->note_private), '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); - $doleditor->Create(); - print ''; + // Description + print ''.$langs->trans("Description").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('note', (GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : $object->note_private), '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); + $doleditor->Create(); + print ''; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) + // Other attributes + $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)) { print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -1231,46 +1231,46 @@ if ($action == 'create') print ''; - if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) - { - //checkbox create reminder - print '
'; - print '
'; - print '

'; + if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) + { + //checkbox create reminder + print '
'; + print '
'; + print '

'; - print ''; - print "\n".''."\n"; - } + print ''."\n"; + } - print dol_get_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; @@ -1327,7 +1327,7 @@ if ($id > 0) if ($listUserAssignedUpdated || $donotclearsession) { - $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status + $percentage = in_array(GETPOST('status'), array(-1, 100)) ?GETPOST('status') : (in_array(GETPOST('complete'), array(-1, 100)) ?GETPOST('complete') : GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -1338,7 +1338,7 @@ if ($id > 0) $object->datef = $datef; $object->percentage = $percentage; $object->priority = GETPOST("priority", "alphanohtml"); - $object->fulldayevent = GETPOST("fullday") ? 1 : 0; + $object->fulldayevent = GETPOST("fullday") ? 1 : 0; $object->location = GETPOST('location', "alpanohtml"); $object->socid = GETPOST("socid", "int"); $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); @@ -1376,10 +1376,10 @@ if ($id > 0) if ($action == 'edit') { - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - } + print ''."\n"; + } print ''; print ''; @@ -1420,42 +1420,42 @@ if ($id > 0) // Type of event if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''.$langs->trans("Type").''; - if ($object->type_code != 'AC_OTH_AUTO') - { - $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); - } else { - print ''.$langs->trans("Action".$object->type_code); - } + print ''.$langs->trans("Type").''; + if ($object->type_code != 'AC_OTH_AUTO') + { + $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); + } else { + print ''.$langs->trans("Action".$object->type_code); + } print ''; } // Title print ''.$langs->trans("Title").''; - // Full day event - print ''.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>'; + // Full day event + print ''.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>'; // Date start print ''.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); - } else { - print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); - } - print ' - '; + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + } else { + print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart'); + } + print ' - '; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } else { - print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } elseif (GETPOST("afaire") == 2) { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } else { + print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + } print ''; - // Dev in progress + // Dev in progress $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); if ($userepeatevent) { @@ -1512,50 +1512,50 @@ if ($id > 0) $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''.$langs->trans("Location").''; - } + } // Assigned to - $listofuserid = array(); // User assigned - if (empty($donotclearsession)) - { - if ($object->userownerid > 0) - { - $listofuserid[$object->userownerid] = array( - 'id'=>$object->userownerid, - 'type'=>'user', - //'transparency'=>$object->userassigned[$user->id]['transparency'], - 'transparency'=>$object->transparency, // Force transparency on ownerfrom event - 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], - 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] - ); - } - if (!empty($object->userassigned)) // Now concat assigned users - { - // Restore array with key with same value than param 'id' - $tmplist1 = $object->userassigned; - foreach ($tmplist1 as $key => $val) - { - if ($val['id'] && $val['id'] != $object->userownerid) - { - $listofuserid[$val['id']] = $val; - } - } - } - $_SESSION['assignedtouser'] = json_encode($listofuserid); - } else { - if (!empty($_SESSION['assignedtouser'])) - { - $listofuserid = json_decode($_SESSION['assignedtouser'], true); - } - } - $listofcontactid = $object->socpeopleassigned; // Contact assigned - $listofotherid = $object->otherassigned; // Other undefined email (not used yet) + $listofuserid = array(); // User assigned + if (empty($donotclearsession)) + { + if ($object->userownerid > 0) + { + $listofuserid[$object->userownerid] = array( + 'id'=>$object->userownerid, + 'type'=>'user', + //'transparency'=>$object->userassigned[$user->id]['transparency'], + 'transparency'=>$object->transparency, // Force transparency on ownerfrom event + 'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'], + 'mandatory'=>$object->userassigned[$object->userownerid]['mandatory'] + ); + } + if (!empty($object->userassigned)) // Now concat assigned users + { + // Restore array with key with same value than param 'id' + $tmplist1 = $object->userassigned; + foreach ($tmplist1 as $key => $val) + { + if ($val['id'] && $val['id'] != $object->userownerid) + { + $listofuserid[$val['id']] = $val; + } + } + } + $_SESSION['assignedtouser'] = json_encode($listofuserid); + } else { + if (!empty($_SESSION['assignedtouser'])) + { + $listofuserid = json_decode($_SESSION['assignedtouser'], true); + } + } + $listofcontactid = $object->socpeopleassigned; // Contact assigned + $listofotherid = $object->otherassigned; // Other undefined email (not used yet) - print ''.$langs->trans("ActionAssignedTo").''; + print ''.$langs->trans("ActionAssignedTo").''; print '
'; print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); print '
'; @@ -1575,7 +1575,7 @@ if ($id > 0) print ''; } // Tags-Categories - if ($conf->categorie->enabled) { + if ($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -1635,7 +1635,7 @@ if ($id > 0) } // Priority - if (! empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { + if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { print ''.$langs->trans("Priority").''; print ''; print ''; @@ -1645,19 +1645,19 @@ if ($id > 0) if (!empty($object->fk_element) && !empty($object->elementtype)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print ''; + print ''; print ''.$langs->trans("LinkedObject").''; if ($object->elementtype == 'task' && !empty($conf->projet->enabled)) { - print ''; + print ''; $urloption = '?action=create&donotclearsession=1'; // we use create not edit for more flexibility - $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; + $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption; - // update task list - print "\n".''."\n"; + print ''."\n"; - $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); - print ''; + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project); + print ''; - print ''; + print ''; } else { - print ''; - print dolGetElementUrl($object->fk_element, $object->elementtype, 1); - print ''; - print ''; - print ''; + print ''; + print dolGetElementUrl($object->fk_element, $object->elementtype, 1); + print ''; + print ''; + print ''; } print ''; } - // Description - print ''.$langs->trans("Description").''; - // Editeur wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', $object->note_private, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); - $doleditor->Create(); - print ''; + // Description + print ''.$langs->trans("Description").''; + // Editeur wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('note', $object->note_private, '', 200, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor->Create(); + print ''; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) + // Other attributes + $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)) { print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -1832,46 +1832,46 @@ if ($id > 0) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - //$morehtmlref.='
'.$langs->trans('Project') . ' '; - $morehtmlref .= $langs->trans('Project').' '; - if ($user->rights->agenda->allactions->create || - (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) - { - if ($action != 'classify') { + $langs->load("projects"); + //$morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').' '; + if ($user->rights->agenda->allactions->create || + (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) + { + if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - if ($proj->title) $morehtmlref .= ' - '.$proj->title; - } else { - $morehtmlref .= ''; - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; print '
'; @@ -1884,8 +1884,8 @@ if ($id > 0) print ''.$langs->trans("Type").''.$langs->trans($object->type).''; } - // Full day event - print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; + // Full day event + print ''.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).''; $rowspan = 4; if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++; @@ -1900,19 +1900,19 @@ if ($id > 0) // Date end print ''.$langs->trans("DateActionEnd").''; - if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); + if (!$object->fulldayevent) print dol_print_date($object->datef, 'dayhour'); else print dol_print_date($object->datef, 'day'); if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print img_warning($langs->trans("Late")); print ''; - // Location - if (empty($conf->global->AGENDA_DISABLE_LOCATION)) - { + // Location + if (empty($conf->global->AGENDA_DISABLE_LOCATION)) + { print ''.$langs->trans("Location").''.$object->location.''; - } + } // Assigned to - print ''.$langs->trans("ActionAssignedTo").''; + print ''.$langs->trans("ActionAssignedTo").''; $listofuserid = array(); if (empty($donotclearsession)) { @@ -1988,8 +1988,8 @@ if ($id > 0) if ($conf->societe->enabled) { - // Related company - print ''.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); + // Related company + print ''.$langs->trans("ActionOnCompany").''.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").'')); if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') { if ($object->thirdparty->fetch($object->thirdparty->id)) @@ -2051,43 +2051,43 @@ if ($id > 0) print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)); print ''; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - // Reminders - if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) - { - $filtreuserid = $user->id; - if ($user->rights->agenda->allactions->read) $filtreuserid = 0; - $object->loadReminders('', $filteruserid, false); + // Reminders + if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) + { + $filtreuserid = $user->id; + if ($user->rights->agenda->allactions->read) $filtreuserid = 0; + $object->loadReminders('', $filteruserid, false); - print ''.$langs->trans("Reminders").''; + print ''.$langs->trans("Reminders").''; - if (count($object->reminders) > 0) { - $tmpuserstatic = new User($db); + if (count($object->reminders) > 0) { + $tmpuserstatic = new User($db); - foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { - print $TRemindTypes[$actioncommreminder->typeremind]; - if ($actioncommreminder->fk_user > 0) { - $tmpuserstatic->fetch($actioncommreminder->fk_user); - print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; - } - print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; - if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { - print ' - '; - print $langs->trans("NotSent"); - print ' '; - } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) { - print ' - '; - print $langs->trans("Done"); - print ' '; - } - print '
'; - } - } + foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { + print $TRemindTypes[$actioncommreminder->typeremind]; + if ($actioncommreminder->fk_user > 0) { + $tmpuserstatic->fetch($actioncommreminder->fk_user); + print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; + } + print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit]; + if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) { + print ' - '; + print $langs->trans("NotSent"); + print ' '; + } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) { + print ' - '; + print $langs->trans("Done"); + print ' '; + } + print '
'; + } + } - print ''; - } + print ''; + } print ''; @@ -2144,26 +2144,26 @@ if ($id > 0) if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) { print '
'; - print ''; // ancre + print ''; // ancre - /* + /* * Documents generes */ - $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->agenda->myactions->read; - $delallowed = $user->rights->agenda->myactions->create; + $genallowed = $user->rights->agenda->myactions->read; + $delallowed = $user->rights->agenda->myactions->create; - print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); + print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); print '
'; print '
'; - } + } } } diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 16384edfcde..09c9a25ca1a 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -77,8 +77,8 @@ class ActionCommReminder extends CommonObject */ public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), - 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), + 'dateremind' => array('type'=>'datetime', 'label'=>'DateRemind', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>1, 'index'=>1,), 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), @@ -93,10 +93,10 @@ class ActionCommReminder extends CommonObject */ public $rowid; - /** - * @var int Entity - */ - public $entity; + /** + * @var int Entity + */ + public $entity; public $dateremind; public $typeremind; @@ -204,7 +204,7 @@ class ActionCommReminder extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -214,7 +214,7 @@ class ActionCommReminder extends CommonObject */ public static function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0 || $mode == 1) diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 6e86a556a1a..55a98dbb1dc 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -162,12 +162,12 @@ class CActionComm if ($qualified && $obj->module) { - if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified=0; - if ($obj->module == 'order' && !$conf->commande->enabled) $qualified=0; - if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified=0; - if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ! $conf->supplier_invoice->enabled)) $qualified=0; - if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ! $conf->supplier_order->enabled)) $qualified=0; - if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified=0; + if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified = 0; + if ($obj->module == 'order' && !$conf->commande->enabled) $qualified = 0; + if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified = 0; + if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_invoice->enabled)) $qualified = 0; + if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_order->enabled)) $qualified = 0; + if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified = 0; } if ($qualified) diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index b806dde94f9..4789e49f44a 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -32,144 +32,144 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php'; */ class ICal { - // Text in file - public $file_text; - public $cal; // Array to save iCalendar parse data - public $event_count; // Number of Events - public $todo_count; // Number of Todos - public $freebusy_count; // Number of Freebusy - public $last_key; //Help variable save last key (multiline string) + // Text in file + public $file_text; + public $cal; // Array to save iCalendar parse data + public $event_count; // Number of Events + public $todo_count; // Number of Todos + public $freebusy_count; // Number of Freebusy + public $last_key; //Help variable save last key (multiline string) - /** - * Constructor - */ - public function __construct() - { - } + /** + * Constructor + */ + public function __construct() + { + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Read text file, icalender text file - * - * @param string $file File - * @return string - */ - public function read_file($file) - { - // phpcs:enable - $this->file = $file; - $file_text = ''; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Read text file, icalender text file + * + * @param string $file File + * @return string + */ + public function read_file($file) + { + // phpcs:enable + $this->file = $file; + $file_text = ''; - $tmparray = file($file); - if (is_array($tmparray)) - { - $file_text = join("", $tmparray); //load file - $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); - } - return $file_text; // return all text - } + $tmparray = file($file); + if (is_array($tmparray)) + { + $file_text = join("", $tmparray); //load file + $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); + } + return $file_text; // return all text + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Returns the number of calendar events - * - * @return int - */ - public function get_event_count() - { - // phpcs:enable - return $this->event_count; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the number of calendar events + * + * @return int + */ + public function get_event_count() + { + // phpcs:enable + return $this->event_count; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Returns the number of to do - * - * @return int - */ - public function get_todo_count() - { - // phpcs:enable - return $this->todo_count; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the number of to do + * + * @return int + */ + public function get_todo_count() + { + // phpcs:enable + return $this->todo_count; + } - /** - * Translate Calendar - * - * @param string $uri Url - * @return array|string - */ - public function parse($uri) - { - $this->cal = array(); // new empty array + /** + * Translate Calendar + * + * @param string $uri Url + * @return array|string + */ + public function parse($uri) + { + $this->cal = array(); // new empty array - $this->event_count = -1; + $this->event_count = -1; - // read FILE text - $this->file_text = $this->read_file($uri); + // read FILE text + $this->file_text = $this->read_file($uri); - $this->file_text = preg_split("[\n]", $this->file_text); + $this->file_text = preg_split("[\n]", $this->file_text); - // is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR - if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; + // is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR + if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) return 'error not VCALENDAR'; - $insidealarm = 0; - $tmpkey = ''; $tmpvalue = ''; $type = ''; - foreach ($this->file_text as $text) - { - $text = trim($text); // trim one line - if (!empty($text)) - { - // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin - list($key, $value) = $this->retun_key_value($text); - //var_dump($text.' -> '.$key.' - '.$value); + $insidealarm = 0; + $tmpkey = ''; $tmpvalue = ''; $type = ''; + foreach ($this->file_text as $text) + { + $text = trim($text); // trim one line + if (!empty($text)) + { + // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin + list($key, $value) = $this->retun_key_value($text); + //var_dump($text.' -> '.$key.' - '.$value); - switch ($text) // search special string - { - case "BEGIN:VTODO": - $this->todo_count = $this->todo_count + 1; // new to do begin - $type = "VTODO"; - break; + switch ($text) // search special string + { + case "BEGIN:VTODO": + $this->todo_count = $this->todo_count + 1; // new to do begin + $type = "VTODO"; + break; - case "BEGIN:VEVENT": - $this->event_count = $this->event_count + 1; // new event begin - $type = "VEVENT"; - break; + case "BEGIN:VEVENT": + $this->event_count = $this->event_count + 1; // new event begin + $type = "VEVENT"; + break; - case "BEGIN:VFREEBUSY": - $this->freebusy_count = $this->freebusy_count + 1; // new event begin - $type = "VFREEBUSY"; - break; + case "BEGIN:VFREEBUSY": + $this->freebusy_count = $this->freebusy_count + 1; // new event begin + $type = "VFREEBUSY"; + break; - case "BEGIN:VCALENDAR": // all other special string - case "BEGIN:DAYLIGHT": - case "BEGIN:VTIMEZONE": - case "BEGIN:STANDARD": - $type = $value; // save array under value key - break; + case "BEGIN:VCALENDAR": // all other special string + case "BEGIN:DAYLIGHT": + case "BEGIN:VTIMEZONE": + case "BEGIN:STANDARD": + $type = $value; // save array under value key + break; - case "END:VTODO": // end special text - goto VCALENDAR key - case "END:VEVENT": - case "END:VFREEBUSY": + case "END:VTODO": // end special text - goto VCALENDAR key + case "END:VEVENT": + case "END:VFREEBUSY": - case "END:VCALENDAR": - case "END:DAYLIGHT": - case "END:VTIMEZONE": - case "END:STANDARD": - $type = "VCALENDAR"; - break; + case "END:VCALENDAR": + case "END:DAYLIGHT": + case "END:VTIMEZONE": + case "END:STANDARD": + $type = "VCALENDAR"; + break; - // Manage VALARM that are inside a VEVENT to avoid fields of VALARM to overwrites fields of VEVENT - case "BEGIN:VALARM": - $insidealarm = 1; - break; - case "END:VALARM": - $insidealarm = 0; - break; + // Manage VALARM that are inside a VEVENT to avoid fields of VALARM to overwrites fields of VEVENT + case "BEGIN:VALARM": + $insidealarm = 1; + break; + case "END:VALARM": + $insidealarm = 0; + break; - default: // no special string (SUMMARY, DESCRIPTION, ...) - if ($tmpvalue) + default: // no special string (SUMMARY, DESCRIPTION, ...) + if ($tmpvalue) { $tmpvalue .= $text; if (!preg_match('/=$/', $text)) // No more lines @@ -180,96 +180,96 @@ class ICal $tmpvalue = ''; } } elseif (preg_match('/^ENCODING=QUOTED-PRINTABLE:/i', $value)) - { - if (preg_match('/=$/', $value)) - { - $tmpkey = $key; - $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message - } else { - $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); - } - } //$value=quotedPrintDecode($tmpvalue.$value); - if (!$insidealarm && !$tmpkey) $this->add_to_array($type, $key, $value); // add to array - break; - } - } - } + { + if (preg_match('/=$/', $value)) + { + $tmpkey = $key; + $tmpvalue = $tmpvalue.preg_replace('/=$/', "", $value); // We must wait to have next line to have complete message + } else { + $value = quotedPrintDecode(preg_replace('/^ENCODING=QUOTED-PRINTABLE:/i', '', $tmpvalue.$value)); + } + } //$value=quotedPrintDecode($tmpvalue.$value); + if (!$insidealarm && !$tmpkey) $this->add_to_array($type, $key, $value); // add to array + break; + } + } + } - //var_dump($this->cal); - return $this->cal; - } + //var_dump($this->cal); + return $this->cal; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Add to $this->ical array one value and key. - * - * @param string $type Type ('VTODO', 'VEVENT', 'VFREEBUSY', 'VCALENDAR'...) - * @param string $key Key ('DTSTART', ...). Note: Field is never 'DTSTART;TZID=...' because ';...' was before removed and added as another property - * @param string $value Value - * @return void - */ - public function add_to_array($type, $key, $value) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Add to $this->ical array one value and key. + * + * @param string $type Type ('VTODO', 'VEVENT', 'VFREEBUSY', 'VCALENDAR'...) + * @param string $key Key ('DTSTART', ...). Note: Field is never 'DTSTART;TZID=...' because ';...' was before removed and added as another property + * @param string $value Value + * @return void + */ + public function add_to_array($type, $key, $value) + { + // phpcs:enable - //print 'type='.$type.' key='.$key.' value='.$value.'
'."\n"; + //print 'type='.$type.' key='.$key.' value='.$value.'
'."\n"; - if (empty($key)) - { - $key = $this->last_key; - switch ($type) - { - case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break; - case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; - case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value; break; - } - } + if (empty($key)) + { + $key = $this->last_key; + switch ($type) + { + case 'VEVENT': $value = $this->cal[$type][$this->event_count][$key].$value; break; + case 'VFREEBUSY': $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; + case 'VTODO': $value = $this->cal[$type][$this->todo_count][$key].$value; break; + } + } - if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value); - //if ($key == "RRULE" ) $value = $this->ical_rrule($value); + if (($key == "DTSTAMP") || ($key == "LAST-MODIFIED") || ($key == "CREATED")) $value = $this->ical_date_to_unix($value); + //if ($key == "RRULE" ) $value = $this->ical_rrule($value); - if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) - { - if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) - { - list($key, $value) = array($key, $value); - } else { - list($key, $value) = $this->ical_dt_date($key, $value); - } - } + if (stristr($key, "DTSTART") || stristr($key, "DTEND") || stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) + { + if (stristr($key, "DTSTART;VALUE=DATE") || stristr($key, "DTEND;VALUE=DATE")) + { + list($key, $value) = array($key, $value); + } else { + list($key, $value) = $this->ical_dt_date($key, $value); + } + } - switch ($type) - { - case "VTODO": - $this->cal[$type][$this->todo_count][$key] = $value; - break; + switch ($type) + { + case "VTODO": + $this->cal[$type][$this->todo_count][$key] = $value; + break; - case "VEVENT": - $this->cal[$type][$this->event_count][$key] = $value; - break; + case "VEVENT": + $this->cal[$type][$this->event_count][$key] = $value; + break; - case "VFREEBUSY": - $this->cal[$type][$this->freebusy_count][$key] = $value; - break; + case "VFREEBUSY": + $this->cal[$type][$this->freebusy_count][$key] = $value; + break; - default: - $this->cal[$type][$key] = $value; - break; - } - $this->last_key = $key; - } + default: + $this->cal[$type][$key] = $value; + break; + } + $this->last_key = $key; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); - * - * @param string $text Text - * @return array - */ - public function retun_key_value($text) - { - // phpcs:enable - /* + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); + * + * @param string $text Text + * @return array + */ + public function retun_key_value($text) + { + // phpcs:enable + /* preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches); if (empty($matches)) @@ -281,173 +281,173 @@ class ICal $matches = array_splice($matches, 1, 2); return $matches; }*/ - return explode(':', $text, 2); - } + return explode(':', $text, 2); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Parse RRULE return array - * - * @param string $value string - * @return array - */ - public function ical_rrule($value) - { - // phpcs:enable - $result = array(); - $rrule = explode(';', $value); - foreach ($rrule as $line) - { - $rcontent = explode('=', $line); - $result[$rcontent[0]] = $rcontent[1]; - } - return $result; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Parse RRULE return array + * + * @param string $value string + * @return array + */ + public function ical_rrule($value) + { + // phpcs:enable + $result = array(); + $rrule = explode(';', $value); + foreach ($rrule as $line) + { + $rcontent = explode('=', $line); + $result[$rcontent[0]] = $rcontent[1]; + } + return $result; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS) - * - * @param string $ical_date String date - * @return int - */ - public function ical_date_to_unix($ical_date) - { - // phpcs:enable - $ical_date = str_replace('T', '', $ical_date); - $ical_date = str_replace('Z', '', $ical_date); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS) + * + * @param string $ical_date String date + * @return int + */ + public function ical_date_to_unix($ical_date) + { + // phpcs:enable + $ical_date = str_replace('T', '', $ical_date); + $ical_date = str_replace('Z', '', $ical_date); - $ntime = 0; - // TIME LIMITED EVENT - if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) - $ntime = dol_mktime($date[4], $date[5], $date[6], $date[2], $date[3], $date[1], true); + $ntime = 0; + // TIME LIMITED EVENT + if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})/', $ical_date, $date)) + $ntime = dol_mktime($date[4], $date[5], $date[6], $date[2], $date[3], $date[1], true); - //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; - //print dol_print_date($ntime,'dayhour');exit; - return $ntime; // ntime is a GTM time - } + //if (empty($date[4])) print 'Error bad date: '.$ical_date.' - date1='.$date[1]; + //print dol_print_date($ntime,'dayhour');exit; + return $ntime; // ntime is a GTM time + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return unix date from iCal date format - * - * @param string $key Key - * @param string $value Value - * @return array - */ - public function ical_dt_date($key, $value) - { - // phpcs:enable - $return_value = array(); - $value = $this->ical_date_to_unix($value); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return unix date from iCal date format + * + * @param string $key Key + * @param string $value Value + * @return array + */ + public function ical_dt_date($key, $value) + { + // phpcs:enable + $return_value = array(); + $value = $this->ical_date_to_unix($value); - // Analyse TZID - $temp = explode(";", $key); + // Analyse TZID + $temp = explode(";", $key); - if (empty($temp[1])) // not TZID - { - $value = str_replace('T', '', $value); - return array($key, $value); - } + if (empty($temp[1])) // not TZID + { + $value = str_replace('T', '', $value); + return array($key, $value); + } - $key = $temp[0]; - $temp = explode("=", $temp[1]); - $return_value[$temp[0]] = $temp[1]; - $return_value['unixtime'] = $value; + $key = $temp[0]; + $temp = explode("=", $temp[1]); + $return_value[$temp[0]] = $temp[1]; + $return_value['unixtime'] = $value; - return array($key, $return_value); - } + return array($key, $return_value); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return sorted eventlist as array or false if calendar is empty - * - * @return array|false - */ - public function get_sort_event_list() - { - // phpcs:enable - $temp = $this->get_event_list(); - if (!empty($temp)) - { - usort($temp, array(&$this, "ical_dtstart_compare")); - return $temp; - } else { - return false; - } - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return sorted eventlist as array or false if calendar is empty + * + * @return array|false + */ + public function get_sort_event_list() + { + // phpcs:enable + $temp = $this->get_event_list(); + if (!empty($temp)) + { + usort($temp, array(&$this, "ical_dtstart_compare")); + return $temp; + } else { + return false; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Compare two unix timestamp - * - * @param array $a Operand a - * @param array $b Operand b - * @return integer - */ - public function ical_dtstart_compare($a, $b) - { - // phpcs:enable - return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Compare two unix timestamp + * + * @param array $a Operand a + * @param array $b Operand b + * @return integer + */ + public function ical_dtstart_compare($a, $b) + { + // phpcs:enable + return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return eventlist array (not sorted eventlist array) - * - * @return array - */ - public function get_event_list() - { - // phpcs:enable - return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : ''); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return eventlist array (not sorted eventlist array) + * + * @return array + */ + public function get_event_list() + { + // phpcs:enable + return (!empty($this->cal['VEVENT']) ? $this->cal['VEVENT'] : ''); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return eventlist array (not sort eventlist array) - * - * @return array - */ - public function get_freebusy_list() - { - // phpcs:enable - return $this->cal['VFREEBUSY']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return eventlist array (not sort eventlist array) + * + * @return array + */ + public function get_freebusy_list() + { + // phpcs:enable + return $this->cal['VFREEBUSY']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return to do array (not sorted todo array) - * - * @return array - */ - public function get_todo_list() - { - // phpcs:enable - return $this->cal['VTODO']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return to do array (not sorted todo array) + * + * @return array + */ + public function get_todo_list() + { + // phpcs:enable + return $this->cal['VTODO']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return base calendar data - * - * @return array - */ - public function get_calender_data() - { - // phpcs:enable - return $this->cal['VCALENDAR']; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return base calendar data + * + * @return array + */ + public function get_calender_data() + { + // phpcs:enable + return $this->cal['VCALENDAR']; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return array with all data - * - * @return array - */ - public function get_all_data() - { - // phpcs:enable - return $this->cal; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return array with all data + * + * @return array + */ + public function get_all_data() + { + // phpcs:enable + return $this->cal; + } } diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index 292c0ea94ce..40787abb8c3 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -29,8 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -41,8 +41,8 @@ $id = GETPOST('id', 'int'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); @@ -86,19 +86,19 @@ $morehtmlref = '
'; // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - //$morehtmlref.='
'.$langs->trans('Project') . ' '; - $morehtmlref .= $langs->trans('Project').': '; - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - if ($proj->title) $morehtmlref .= ' - '.$proj->title; - } else { - $morehtmlref .= ''; - } + $langs->load("projects"); + //$morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= $langs->trans('Project').': '; + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + if ($proj->title) $morehtmlref .= ' - '.$proj->title; + } else { + $morehtmlref .= ''; + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 582f1c538f0..a9e365534f3 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -57,10 +57,10 @@ $confirm = GETPOST('confirm', 'alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); $search_id = GETPOST('search_id', 'alpha'); @@ -166,13 +166,13 @@ if (GETPOST('cancel', 'alpha')) if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { $param = ''; - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - $param .= '&'.$key.'='.urlencode($val); - } - } + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + $param .= '&'.$key.'='.urlencode($val); + } + } //print $param; header("Location: ".DOL_URL_ROOT.'/comm/action/index.php?'.$param); exit; @@ -187,15 +187,15 @@ 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 { - //$actioncode=''; - $search_id = ''; + //$actioncode=''; + $search_id = ''; $search_title = ''; - $search_note = ''; - $datestart = ''; - $dateend = ''; - $search_status = ''; + $search_note = ''; + $datestart = ''; + $dateend = ''; + $search_status = ''; $toselect = ''; - $search_array_options = array(); + $search_array_options = array(); } if (empty($reshook) && !empty($massaction)) @@ -341,26 +341,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on 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'"; - else { - if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; - if ($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 { - if (is_array($actioncode)) - { - $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND c.code IN ('".implode("','", explode(',', $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'"; + else { + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + if ($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 { + if (is_array($actioncode)) + { + $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; + } else { + $sql .= " AND c.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); @@ -381,10 +381,10 @@ if ($search_note) $sql .= natural_search('a.note', $search_note); // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) @@ -405,13 +405,13 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -452,13 +452,13 @@ if ($resql) if ($showbirthday) $nav .= ''; print $nav; - //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); - //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - //print dol_get_fiche_end(); + //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); + //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + //print dol_get_fiche_end(); - // Add link to show birthdays - $link = ''; - /* + // Add link to show birthdays + $link = ''; + /* if (empty($conf->use_javascript_ajax)) { $newparam=$param; // newparam is for birthday links @@ -473,49 +473,49 @@ if ($resql) } */ - $s = $newtitle; + $s = $newtitle; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } - $viewmode = ''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewList").''; + $viewmode = ''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewList").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewCal").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewCal").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewWeek").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewWeek").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewDay").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewDay").''; - $viewmode .= ''; - //$viewmode .= ''; - $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); - //$viewmode .= ''; - $viewmode .= ''.$langs->trans("ViewPerUser").''; + $viewmode .= ''; + //$viewmode .= ''; + $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); + //$viewmode .= ''; + $viewmode .= ''.$langs->trans("ViewPerUser").''; $viewmode .= ''; @@ -538,21 +538,21 @@ if ($resql) print $s; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - $moreforfilter = ''; + $moreforfilter = ''; $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); - $i = 0; + $i = 0; - print '
'; - print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); - print '
'; + print '
'; + print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + print '
'; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; print ''; if (!empty($arrayfields['a.id']['checked'])) print ''; @@ -571,8 +571,8 @@ if ($resql) print ''; } if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - } + print ''; + } if (!empty($arrayfields['a.fk_contact']['checked'])) print ''; if (!empty($arrayfields['a.fk_element']['checked'])) print ''; @@ -588,10 +588,10 @@ if ($resql) if (!empty($arrayfields['a.tms']['checked'])) print ''; if (!empty($arrayfields['a.percent']['checked'])) { print ''; - } + $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); + print ajax_combobox('selectsearch_status'); + print ''; + } // Action column print ''; + print ''; } // Extra fields @@ -858,7 +858,7 @@ if ($resql) $i++; } print "
'; - $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); - print ajax_combobox('selectsearch_status'); - print ''; $searchpicto = $form->showFilterButtons(); @@ -610,10 +610,10 @@ if ($resql) if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -634,18 +634,18 @@ if ($resql) 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); - $contactListCache = array(); + $contactListCache = array(); while ($i < min($num, $limit)) { $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') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + { + $i++; + continue; + } $actionstatic->id = $obj->id; $actionstatic->ref = $obj->id; @@ -771,29 +771,29 @@ if ($resql) if (!empty($arrayfields['a.fk_contact']['checked'])) { print ''; - if (!empty($actionstatic->socpeopleassigned)) - { - $contactList = array(); - foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) - { - if (!isset($contactListCache[$socpeopleassigned['id']])) - { - // if no cache found we fetch it - $contact = new Contact($db); - if ($contact->fetch($socpeopleassigned['id']) > 0) - { - $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); - $contactList[] = $contact->getNomUrl(1, '', 0); - } - } else { - // use cache - $contactList[] = $contactListCache[$socpeopleassigned['id']]; - } - } - if (!empty($contactList)) { - print implode(', ', $contactList); - } - } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event + if (!empty($actionstatic->socpeopleassigned)) + { + $contactList = array(); + foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) + { + if (!isset($contactListCache[$socpeopleassigned['id']])) + { + // if no cache found we fetch it + $contact = new Contact($db); + if ($contact->fetch($socpeopleassigned['id']) > 0) + { + $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); + $contactList[] = $contact->getNomUrl(1, '', 0); + } + } else { + // use cache + $contactList[] = $contactListCache[$socpeopleassigned['id']]; + } + } + if (!empty($contactList)) { + print implode(', ', $contactList); + } + } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event { $contactstatic->id = $obj->fk_contact; $contactstatic->email = $obj->email; @@ -812,15 +812,15 @@ if ($resql) // Linked object if (!empty($arrayfields['a.fk_element']['checked'])) { - print ''; - //var_dump($obj->fkelement.' '.$obj->elementtype); - if ($obj->fk_element > 0 && !empty($obj->elementtype)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); - } else { - print " "; - } - print ''; + //var_dump($obj->fkelement.' '.$obj->elementtype); + if ($obj->fk_element > 0 && !empty($obj->elementtype)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); + } else { + print " "; + } + print '
"; - print '
'; + print '
'; print ''; $db->free($resql); diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index f0c1a0d1951..4f292047700 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -74,7 +74,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert = $user->id; + $filtert = $user->id; } //$action=GETPOST('action','alpha'); @@ -92,10 +92,10 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -126,16 +126,16 @@ if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $statu if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { - $action = 'show_month'; $day = ''; + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { - $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'alpha') || $action == 'show_day') { - $action = 'show_day'; $day = ($day ? $day : date("d")); + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day if (GETPOST('viewyear', 'alpha') || $action == 'show_year') { - $action = 'show_year'; + $action = 'show_year'; } // View by year // Load translation files required by the page @@ -151,13 +151,13 @@ $hookmanager->initHooks(array('agenda')); if ($action == 'delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $event->fetch_optionals(); - $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; - $result = $event->delete(); + $result = $event->delete(); } @@ -317,8 +317,8 @@ if ($conf->use_javascript_ajax) $s .= 'jQuery(".family_birthday").toggle();'."\n"; if ($action == "show_week" || $action == "show_month" || empty($action)) { - $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; - $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; } $s .= '});'."\n"; $s .= ''."\n"; @@ -345,15 +345,15 @@ if ($conf->use_javascript_ajax) //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } } } @@ -451,26 +451,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on 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'"; - else { - 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'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $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'"; + else { + 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'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $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); @@ -480,28 +480,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($action == 'show_day') { - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; - $sql .= ')'; + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= ')'; } else { - // To limit array - $sql .= " AND ("; - $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; - $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; - $sql .= ')'; + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; // End 7 days after + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, 1, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, 12, 1, $year) - (60 * 60 * 24 * 7))."'"; + $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; + $sql .= ')'; } if ($type) $sql .= " AND ca.id = ".$type; if ($status == '0') { $sql .= " AND a.percent = 0"; } @@ -512,10 +512,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action @@ -525,104 +525,104 @@ dol_syslog("comm/action/pertype.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + { + $i++; + continue; + } - $datep = $db->jdate($obj->datep); - $datep2 = $db->jdate($obj->datep2); + $datep = $db->jdate($obj->datep); + $datep2 = $db->jdate($obj->datep2); - // Create a new object action - $event = new ActionComm($db); - $event->id = $obj->id; - $event->datep = $datep; // datep and datef are GMT date - $event->datef = $datep2; - $event->type_code = $obj->code; - $event->type_color = $obj->color; - $event->label = $obj->label; - $event->percentage = $obj->percent; - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; - $event->location = $obj->location; - $event->transparency = $obj->transparency; + // Create a new object action + $event = new ActionComm($db); + $event->id = $obj->id; + $event->datep = $datep; // datep and datef are GMT date + $event->datef = $datep2; + $event->type_code = $obj->code; + $event->type_color = $obj->color; + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; - $event->fk_project = $obj->fk_project; + $event->fk_project = $obj->fk_project; - $event->socid = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; + $event->socid = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) - { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel = 1; - } + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + if ($event->percentage <= 0) + { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } else { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) - { - // This record is out of visible range - unset($event); - } else { + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + unset($event); + } else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; $event->fetch_userassigned(); // This load $event->userassigned 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_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; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $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); - do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; + // 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); + do { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; - $eventarray[$daykey][] = $event; - $j++; + $eventarray[$daykey][] = $event; + $j++; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; - } - $i++; - } - $db->free($resql); + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; + } + $i++; + } + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } $maxnbofchar = 18; @@ -634,7 +634,7 @@ $cacheusers = array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; if (is_readable($color_file)) { - include_once $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)); @@ -722,7 +722,7 @@ foreach ($typeofevents as $typeofevent) continue; } - // Show days of the current week + // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); $tmparray = dol_getdate($curtime, 'fast'); $tmpday = $tmparray['mday']; @@ -946,15 +946,15 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $busy = $event->transparency; $cases1[$h][$event->id]['busy'] = $busy; $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } - if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; - $cases1[$h][$event->id]['typecode'] = $event->type_code; + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } + if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; + $cases1[$h][$event->id]['typecode'] = $event->type_code; $cases1[$h][$event->id]['color'] = $color; if ($event->fk_project > 0) { @@ -993,13 +993,13 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s $cases2[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } - if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } + if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; $cases2[$h][$event->id]['typecode'] = $event->type_code; $cases2[$h][$event->id]['color'] = $color; if ($event->fk_project > 0) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 899925b16f6..8983dbff7f6 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -74,7 +74,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden(); if (!$user->rights->agenda->allactions->read) $canedit = 0; if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert = $user->id; + $filtert = $user->id; } //$action=GETPOST('action','alpha'); @@ -92,10 +92,10 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -129,13 +129,13 @@ if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $statu if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { - $action = 'show_month'; $day = ''; + $action = 'show_month'; $day = ''; } // View by month if (GETPOST('viewweek', 'alpha') || $action == 'show_week') { - $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); + $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d")); } // View by week if (GETPOST('viewday', 'alpha') || $action == 'show_day') { - $action = 'show_day'; $day = ($day ? $day : date("d")); + $action = 'show_day'; $day = ($day ? $day : date("d")); } // View by day // Load translation files required by the page @@ -151,13 +151,13 @@ $hookmanager->initHooks(array('agenda')); if ($action == 'delete_action') { - $event = new ActionComm($db); - $event->fetch($actionid); - $event->fetch_optionals(); - $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event = new ActionComm($db); + $event->fetch($actionid); + $event->fetch_optionals(); + $event->fetch_userassigned(); + $event->oldcopy = clone $event; - $result = $event->delete(); + $result = $event->delete(); } @@ -323,8 +323,8 @@ if ($conf->use_javascript_ajax) $s .= 'jQuery(".family_birthday").toggle();'."\n"; if ($action == "show_week" || $action == "show_month" || empty($action)) { - $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; - $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; + $s .= 'jQuery( "td.sortable" ).sortable({connectWith: ".sortable",placeholder: "ui-state-highlight",items: "div:not(.unsortable)", receive: function( event, ui ) {'; + $s .= 'var frm=jQuery("#move_event");frm.attr("action",ui.item.find("a.cal_event").attr("href")).children("#newdate").val(jQuery(event.target).closest("div").attr("id"));frm.submit();}});'."\n"; } $s .= '});'."\n"; $s .= ''."\n"; @@ -351,15 +351,15 @@ if ($conf->use_javascript_ajax) //$s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; // Calendars from hooks - $parameters = array(); $object = null; + $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { - $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) + if (empty($reshook)) { - $s = $hookmanager->resPrint; - } + $s .= $hookmanager->resPrint; + } elseif ($reshook > 1) + { + $s = $hookmanager->resPrint; + } } } @@ -408,7 +408,7 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction //$param='month='.$monthshown.'&year='.$year; $hourminsec = '100000'; - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); @@ -457,26 +457,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on 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'"; - else { - 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'"; - else { - if (is_array($actioncode)) - { - $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; - } else { - $sql .= " AND ca.code IN ('".implode("','", explode(',', $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'"; + else { + 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'"; + else { + if (is_array($actioncode)) + { + $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; + } else { + $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); @@ -486,28 +486,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; 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($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow - $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow - $sql .= " OR "; - $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; - $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; - $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; - $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; - $sql .= ')'; + // To limit array + $sql .= " AND ("; + $sql .= " (a.datep BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; // Start 2 day before $firstdaytoshow + $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; // End 2 day after $lastdaytoshow + $sql .= " OR "; + $sql .= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; + $sql .= " AND '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; + $sql .= " OR "; + $sql .= " (a.datep < '".$db->idate($firstdaytoshow - (60 * 60 * 24 * 2))."'"; + $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; + $sql .= ')'; } if ($type) $sql .= " AND ca.id = ".$type; if ($status == '0') { $sql .= " AND a.percent = 0"; } @@ -518,10 +518,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ("; - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; - $sql .= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // Sort on date $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action @@ -531,105 +531,105 @@ dol_syslog("comm/action/peruser.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); - // Discard auto action if option is on - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') - { - $i++; - continue; - } + // Discard auto action if option is on + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') + { + $i++; + continue; + } - $datep = $db->jdate($obj->datep); - $datep2 = $db->jdate($obj->datep2); + $datep = $db->jdate($obj->datep); + $datep2 = $db->jdate($obj->datep2); - // Create a new object action - $event = new ActionComm($db); - $event->id = $obj->id; - $event->datep = $datep; // datep and datef are GMT date - $event->datef = $datep2; - $event->type_code = $obj->code; - $event->type_color = $obj->color; - $event->label = $obj->label; - $event->percentage = $obj->percent; - $event->authorid = $obj->fk_user_author; // user id of creator - $event->userownerid = $obj->fk_user_action; // user id of owner - $event->priority = $obj->priority; - $event->fulldayevent = $obj->fulldayevent; - $event->location = $obj->location; - $event->transparency = $obj->transparency; + // Create a new object action + $event = new ActionComm($db); + $event->id = $obj->id; + $event->datep = $datep; // datep and datef are GMT date + $event->datef = $datep2; + $event->type_code = $obj->code; + $event->type_color = $obj->color; + $event->label = $obj->label; + $event->percentage = $obj->percent; + $event->authorid = $obj->fk_user_author; // user id of creator + $event->userownerid = $obj->fk_user_action; // user id of owner + $event->priority = $obj->priority; + $event->fulldayevent = $obj->fulldayevent; + $event->location = $obj->location; + $event->transparency = $obj->transparency; - $event->fk_project = $obj->fk_project; + $event->fk_project = $obj->fk_project; - $event->socid = $obj->fk_soc; - $event->contact_id = $obj->fk_contact; + $event->socid = $obj->fk_soc; + $event->contact_id = $obj->fk_contact; - $event->fk_element = $obj->fk_element; - $event->elementtype = $obj->elementtype; + $event->fk_element = $obj->fk_element; + $event->elementtype = $obj->elementtype; - // Defined date_start_in_calendar and date_end_in_calendar property - // They are date start and end of action but modified to not be outside calendar view. - if ($event->percentage <= 0) - { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } else { - $event->date_start_in_calendar = $datep; - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; - else $event->date_end_in_calendar = $datep; - } - // Define ponctual property - if ($event->date_start_in_calendar == $event->date_end_in_calendar) - { - $event->ponctuel = 1; - } + // Defined date_start_in_calendar and date_end_in_calendar property + // They are date start and end of action but modified to not be outside calendar view. + if ($event->percentage <= 0) + { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } else { + $event->date_start_in_calendar = $datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; + else $event->date_end_in_calendar = $datep; + } + // Define ponctual property + if ($event->date_start_in_calendar == $event->date_end_in_calendar) + { + $event->ponctuel = 1; + } - // Check values - if ($event->date_end_in_calendar < $firstdaytoshow || - $event->date_start_in_calendar >= $lastdaytoshow) - { - // This record is out of visible range - unset($event); - } else { + // Check values + if ($event->date_end_in_calendar < $firstdaytoshow || + $event->date_start_in_calendar >= $lastdaytoshow) + { + // This record is out of visible range + unset($event); + } else { //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; - $event->fetch_userassigned(); // This load $event->userassigned + $event->fetch_userassigned(); // This load $event->userassigned if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); + if ($event->date_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; - $annee = date('Y', $daycursor); - $mois = date('m', $daycursor); - $jour = date('d', $daycursor); + // Add an entry in actionarray for each day + $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); - do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; + // 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); + do { + //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; - $eventarray[$daykey][] = $event; - $j++; + $eventarray[$daykey][] = $event; + $j++; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); - //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); - //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; - } - $i++; - } - $db->free($resql); + //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); + //print ' startincalendar='.dol_print_date($event->date_start_in_calendar).'-endincalendar='.dol_print_date($event->date_end_in_calendar).') was added in '.$j.' different index key of array
'; + } + $i++; + } + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } $maxnbofchar = 18; @@ -641,7 +641,7 @@ $cacheusers = array(); $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php"; if (is_readable($color_file)) { - include_once $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)); @@ -750,15 +750,15 @@ while ($currentdaytoshow < $lastdaytoshow) { { foreach ($eventarray as $daykey => $notused) { - // Get all assigned users for each event - foreach ($eventarray[$daykey] as $index => $event) - { - $event->fetch_userassigned(); + // Get all assigned users for each event + foreach ($eventarray[$daykey] as $index => $event) + { + $event->fetch_userassigned(); $listofuserid = $event->userassigned; foreach ($listofuserid as $userid => $tmp) { if (!in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; } - } + } } } else { /* Use this list to have for all users */ @@ -770,17 +770,17 @@ while ($currentdaytoshow < $lastdaytoshow) { //print $sql; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); $usernamesid[$obj->rowid] = $obj->rowid; $i++; - } - } + } + } } else dol_print_error($db); } //var_dump($usernamesid); @@ -846,7 +846,7 @@ while ($currentdaytoshow < $lastdaytoshow) { continue; } - // Show days of the current week + // Show days of the current week $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd'); $tmparray = dol_getdate($curtime, 'fast'); $tmpday = $tmparray['mday']; @@ -1102,13 +1102,13 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $busy = $event->transparency; $cases1[$h][$event->id]['busy'] = $busy; $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); - if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } + if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; $cases1[$h][$event->id]['typecode'] = $event->type_code; $cases1[$h][$event->id]['color'] = $color; @@ -1149,12 +1149,12 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases2[$h][$event->id]['busy'] = $busy; $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour'); if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) - { - $tmpa = dol_getdate($event->date_start_in_calendar, true); - $tmpb = dol_getdate($event->date_end_in_calendar, true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); - else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); - } + { + $tmpa = dol_getdate($event->date_start_in_calendar, true); + $tmpb = dol_getdate($event->date_end_in_calendar, true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour'); + else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour'); + } if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; $cases2[$h][$event->id]['typecode'] = $event->type_code; $cases2[$h][$event->id]['color'] = $color; @@ -1241,7 +1241,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } $ids1 = ''; - $ids2 = ''; + $ids2 = ''; if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h])); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index fbb49772d3e..3534d3d8996 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -91,13 +91,13 @@ $sql .= " ORDER BY year DESC, month DESC, df DESC"; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -113,7 +113,7 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; print '
'; - if ($optioncss != '') print ''; + if ($optioncss != '') print ''; print ''; print ''; print ''; @@ -125,10 +125,10 @@ if ($resql) $moreforfilter = ''; $i = 0; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php index 79836087775..84af27bb7b9 100644 --- a/htdocs/comm/admin/propal_extrafields.php +++ b/htdocs/comm/admin/propal_extrafields.php @@ -78,9 +78,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print ''; - print "
"; + print '
'; + print ''; + print "
"; } @@ -92,10 +92,10 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print "
"; + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -105,10 +105,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index df7e96fc742..bfff6cf1e35 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -487,7 +487,7 @@ if ($object->id > 0) print ''; } - if (! empty($conf->intracommreport->enabled)) + if (!empty($conf->intracommreport->enabled)) { // Transport mode by default print ''; @@ -1030,12 +1030,12 @@ if ($action == 'create') // Display of the TEST form if ($action == 'test') { - print '
'; - print load_fiche_titre($langs->trans("TestMailing")); + print '
'; + print load_fiche_titre($langs->trans("TestMailing")); - print dol_get_fiche_head(null, '', '', -1); + print dol_get_fiche_head(null, '', '', -1); - // Create mail form object + // Create mail form object include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->fromname = $object->email_from; @@ -1103,14 +1103,14 @@ if ($action == 'create') } print ''; - // Background color - /*print '';*/ print '
'.$langs->trans("Period").''.$langs->trans("EventsNb").''.$langs->trans("Action").'
'; @@ -675,15 +675,15 @@ if ($object->id > 0) if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { $warn = ''; if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpenedLate) { - $warn = ' ' . img_warning($langs->trans("OutstandingBillReached")); + $warn = ' '.img_warning($langs->trans("OutstandingBillReached")); } $text = $langs->trans("CurrentOutstandingBillLate"); - $link = DOL_URL_ROOT . '/compta/recap-compta.php?socid=' . $object->id; + $link = DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id; $icon = 'bill'; - if ($link) $boxstat .= ''; - $boxstat .= '
'; - $boxstat .= '' . img_object("", $icon) . ' ' . $text . '
'; - $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency) . $warn . ''; + if ($link) $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= ''.img_object("", $icon).' '.$text.'
'; + $boxstat .= ''.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.''; $boxstat .= '
'; if ($link) $boxstat .= '
'; } @@ -973,7 +973,7 @@ if ($object->id > 0) $late = ''; foreach ($contrat->lines as $line) { if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) { - if (((!empty($line->date_fin_validite)?$line->date_fin_validite:0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); + if (((!empty($line->date_fin_validite) ? $line->date_fin_validite : 0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); } } diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 1038afa923f..9c4e1437ced 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -59,13 +59,13 @@ llxHeader('', $langs->trans("Contacts")); if ($type == "c" || $type == "p") { - $label = $langs->trans("Customers"); - $urlfiche = "card.php"; + $label = $langs->trans("Customers"); + $urlfiche = "card.php"; } if ($type == "f") { - $label = $langs->trans("Suppliers"); - $urlfiche = "card.php"; + $label = $langs->trans("Suppliers"); + $urlfiche = "card.php"; } /* @@ -88,29 +88,29 @@ if ($socid) $sql .= " AND s.rowid = ".$socid; if (dol_strlen($stcomm)) { - $sql .= " AND s.fk_stcomm=".$db->escape($stcomm); + $sql .= " AND s.fk_stcomm=".$db->escape($stcomm); } if (!empty($search_lastname)) { - $sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; + $sql .= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; } if (!empty($search_firstname)) { - $sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; + $sql .= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; } if (!empty($search_company)) { - $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; + $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; } if (!empty($contactname)) // acces a partir du module de recherche { - $sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; - $sortfield = "p.name"; - $sortorder = "ASC"; + $sql .= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; + $sortfield = "p.name"; + $sortorder = "ASC"; } $sql .= $db->order($sortfield, $sortorder); @@ -171,7 +171,7 @@ if ($resql) $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } // End of page diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index bb74fb686aa..09ed51f9418 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -103,7 +103,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - $action = ''; + $action = ''; } // Action send emailing for everybody @@ -188,18 +188,18 @@ if (empty($reshook)) // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... $other = explode(';', $obj->other); $tmpfield = explode('=', $other[0], 2); $other1 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[1], 2); $other2 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[2], 2); $other3 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[3], 2); $other4 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); + $tmpfield = explode('=', $other[4], 2); $other5 = (isset($tmpfield[1]) ? $tmpfield[1] : $tmpfield[0]); - $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $user->signature : ''); - $targetobject = null; // Not defined with mass emailing - $parameters = array('mode'=>'emailing'); - $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object + $targetobject = null; // Not defined with mass emailing + $parameters = array('mode'=>'emailing'); + $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object - // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; @@ -253,7 +253,7 @@ if (empty($reshook)) } //$substitutionisok=true; - complete_substitutions_array($substitutionarray, $langs); + complete_substitutions_array($substitutionarray, $langs); $newsubject = make_substitutions($subject, $substitutionarray); $newmessage = make_substitutions($message, $substitutionarray); @@ -319,7 +319,7 @@ if (empty($reshook)) dol_print_error($db); } - //Update status communication of contact prospect + //Update status communication of contact prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("card.php: set prospect contact status", LOG_DEBUG); @@ -331,13 +331,13 @@ if (empty($reshook)) } } - if (!empty($conf->global->MAILING_DELAY)) - { - dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); - sleep($conf->global->MAILING_DELAY); - } + if (!empty($conf->global->MAILING_DELAY)) + { + dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); + sleep($conf->global->MAILING_DELAY); + } - //test if CHECK READ change statut prospect contact + //test if CHECK READ change statut prospect contact } else { // Mail failed $nbko++; @@ -417,7 +417,7 @@ if (empty($reshook)) $object->substitutionarrayfortest['__MAILTOEMAIL__'] = ''.$object->sendto.''; // Subject and message substitutions - complete_substitutions_array($object->substitutionarrayfortest, $langs); + complete_substitutions_array($object->substitutionarrayfortest, $langs); $tmpsujet = make_substitutions($object->sujet, $object->substitutionarrayfortest); $tmpbody = make_substitutions($object->body, $object->substitutionarrayfortest); @@ -426,11 +426,11 @@ if (empty($reshook)) $arr_name = array(); $arr_css = array(); - // Add CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; - if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; + // Add CSS + if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; + if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; - // Attached files + // Attached files $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); if (count($listofpaths)) { @@ -462,9 +462,9 @@ if (empty($reshook)) { $mesgs = array(); - $object->email_from = GETPOST("from", "none"); // Must allow 'name ' - $object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name ' - $object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name ' + $object->email_from = GETPOST("from", "none"); // Must allow 'name ' + $object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name ' + $object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name ' $object->title = GETPOST("title"); $object->sujet = GETPOST("sujet"); $object->body = GETPOST("bodyemail", 'restricthtml'); @@ -504,7 +504,7 @@ if (empty($reshook)) elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name ' elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name ' elseif ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name ' - elseif ($action == 'settitle' && empty($object->title)) { + elseif ($action == 'settitle' && empty($object->title)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } elseif ($action == 'setfrom' && empty($object->email_from)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); @@ -533,8 +533,8 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // Set tmp user directory - dol_add_file_process($upload_dir, 0, 0); + // Set tmp user directory + dol_add_file_process($upload_dir, 0, 0); $action = "edit"; } @@ -546,7 +546,7 @@ if (empty($reshook)) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing + dol_remove_file_process($_POST['removedfile'], 0, 0); // We really delete file linked to mailing $action = "edit"; } @@ -611,14 +611,14 @@ if (empty($reshook)) if ($object->id > 0) { $result = $object->setStatut(0); - if ($result > 0) - { - //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result > 0) + { + //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } else { dol_print_error($db); } @@ -717,7 +717,7 @@ if ($action == 'create') // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); @@ -782,7 +782,7 @@ if ($action == 'create') */ if ($action == 'sendall') { - // Define message to recommand from command line + // Define message to recommand from command line $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE; if (empty($sendingmode)) $sendingmode = $conf->global->MAIN_MAIL_SENDMODE; if (empty($sendingmode)) $sendingmode = 'mail'; // If not defined, we use php mail function @@ -802,29 +802,29 @@ if ($action == 'create') $_GET["action"] = ''; } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); // The feature is forbidden from GUI, we show just message to use from command line. - setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages('', null, 'warnings'); if ($conf->file->mailing_limit_sendbyweb != '-1') // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it. { - setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } $_GET["action"] = ''; } else { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); - $text = ''; - if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) - { - $text .= $langs->trans("MailingNeedCommand"); - $text .= '
'; - $text .= '

'; - } - $text .= $langs->trans('ConfirmSendingEmailing').'
'; + $text = ''; + if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) + { + $text .= $langs->trans("MailingNeedCommand"); + $text .= '
'; + $text .= '

'; + } + $text .= $langs->trans('ConfirmSendingEmailing').'
'; $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', $formquestion, '', 1, 330, 600); } @@ -896,23 +896,23 @@ if ($action == 'create') $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))) - { - if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) - { - $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - } else { - $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); - } - } - if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + $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); + } else { + $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); + } + } + if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; if ($text) - { - print $form->textwithpicto($nbemail, $text, 1, 'warning'); - } else { - print $nbemail; - } + { + print $form->textwithpicto($nbemail, $text, 1, 'warning'); + } else { + print $nbemail; + } } print '
'.$langs->trans("BackgroundColorByDefault").''; + // Background color + /*print '
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor,'bgcolor','',0); print '
'; - // Message + // Message print '
'; if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area { @@ -1186,7 +1186,7 @@ if ($action == 'create') // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); @@ -1261,7 +1261,7 @@ if ($action == 'create') print $out; print ''; - // Background color + // Background color print ''.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor, 'bgcolor', '', 0); print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 7c219cc448a..0d621dfa186 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -78,13 +78,13 @@ if ($action == 'add') foreach ($modulesdir as $dir) { - // Load modules attributes in arrays (name, numero, orders) from dir directory - //print $dir."\n
"; - dol_syslog("Scan directory ".$dir." for modules"); + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + dol_syslog("Scan directory ".$dir." for modules"); - // Loading Class - $file = $dir."/".$module.".modules.php"; - $classname = "mailing_".$module; + // Loading Class + $file = $dir."/".$module.".modules.php"; + $classname = "mailing_".$module; if (file_exists($file)) { @@ -337,12 +337,12 @@ 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); + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + dol_syslog("Scan directory ".$dir." for modules"); + $handle = @opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) @@ -396,7 +396,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; } else { - print '
'; + print '
'; } print '
'; @@ -425,14 +425,14 @@ if ($object->fetch($id) >= 0) print '
'; if ($allowaddtarget) { - try { - $filter = $obj->formFilter(); - } catch (Exception $e) - { - dol_syslog($e->getMessage(), LOG_ERR); - } - if ($filter) print $filter; - else print $langs->trans("None"); + try { + $filter = $obj->formFilter(); + } catch (Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } + if ($filter) print $filter; + else print $langs->trans("None"); } print '
'; @@ -441,7 +441,7 @@ if ($object->fetch($id) >= 0) { print ''; } else { - print ''; + print ''; //print $langs->trans("MailNoChangePossible"); print " "; } @@ -474,13 +474,13 @@ if ($object->fetch($id) >= 0) $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets @@ -503,7 +503,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; print ''; - print ''; + print ''; print ''; $morehtmlcenter = ''; @@ -521,7 +521,7 @@ if ($object->fetch($id) >= 0) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -611,30 +611,30 @@ if ($object->fetch($id) >= 0) print ''.$obj->firstname.''; print ''.$obj->other.''; print ''; - if (empty($obj->source_id) || empty($obj->source_type)) - { - print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility - } else { - if ($obj->source_type == 'member') - { + if (empty($obj->source_id) || empty($obj->source_type)) + { + print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility + } else { + if ($obj->source_type == 'member') + { $objectstaticmember->fetch($obj->source_id); - print $objectstaticmember->getNomUrl(1); - } elseif ($obj->source_type == 'user') - { + print $objectstaticmember->getNomUrl(1); + } elseif ($obj->source_type == 'user') + { $objectstaticuser->fetch($obj->source_id); - print $objectstaticuser->getNomUrl(1); - } elseif ($obj->source_type == 'thirdparty') - { + print $objectstaticuser->getNomUrl(1); + } elseif ($obj->source_type == 'thirdparty') + { $objectstaticcompany->fetch($obj->source_id); - print $objectstaticcompany->getNomUrl(1); - } elseif ($obj->source_type == 'contact') - { - $objectstaticcontact->fetch($obj->source_id); - print $objectstaticcontact->getNomUrl(1); - } else { - print $obj->source_url; - } - } + print $objectstaticcompany->getNomUrl(1); + } elseif ($obj->source_type == 'contact') + { + $objectstaticcontact->fetch($obj->source_id); + print $objectstaticcontact->getNomUrl(1); + } else { + print $obj->source_url; + } + } print ''; // Date last update @@ -680,9 +680,9 @@ if ($object->fetch($id) >= 0) } else { if ($object->statut < 2) { - print ''; - print $langs->trans("NoTargetYet"); - print ''; + print ''; + print $langs->trans("NoTargetYet"); + print ''; } } print "
"; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index b5e115d8463..447b970f39e 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -28,10 +28,10 @@ */ class AdvanceTargetingMailing extends CommonObject { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -58,20 +58,20 @@ class AdvanceTargetingMailing extends CommonObject */ public $id; - public $name; - public $entity; - public $fk_element; - public $type_element; - public $filtervalue; - public $fk_user_author; - public $datec = ''; - public $fk_user_mod; - public $tms = ''; + public $name; + public $entity; + public $fk_element; + public $type_element; + public $filtervalue; + public $fk_user_author; + public $datec = ''; + public $fk_user_mod; + public $tms = ''; - public $select_target_type = array(); - public $type_statuscommprospect = array(); - public $thirdparty_lines; - public $contact_lines; + public $select_target_type = array(); + public $type_statuscommprospect = array(); + public $thirdparty_lines; + public $contact_lines; /** @@ -79,7 +79,7 @@ class AdvanceTargetingMailing extends CommonObject * * @param DoliDb $db Database handler */ - public function __construct($db) + public function __construct($db) { global $langs; $langs->load('customers'); @@ -108,7 +108,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - public function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -177,7 +177,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - public function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -226,16 +226,16 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * * @param int $id Id object * @return int <0 if KO, >0 if OK */ - public function fetch_by_mailing($id = 0) + public function fetch_by_mailing($id = 0) { - // phpcs:enable + // phpcs:enable global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -290,7 +290,7 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * @@ -298,9 +298,9 @@ class AdvanceTargetingMailing extends CommonObject * @param string $type_element Type target * @return int <0 if KO, >0 if OK */ - public function fetch_by_element($id = 0, $type_element = 'mailing') + public function fetch_by_element($id = 0, $type_element = 'mailing') { - // phpcs:enable + // phpcs:enable global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -359,7 +359,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -389,9 +389,9 @@ class AdvanceTargetingMailing extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } // Commit or rollback if ($error) @@ -416,7 +416,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error = 0; @@ -457,7 +457,7 @@ class AdvanceTargetingMailing extends CommonObject * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - public function savequery($user, $arrayquery) + public function savequery($user, $arrayquery) { global $langs, $conf; @@ -477,16 +477,16 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - public function query_thirdparty($arrayquery) + public function query_thirdparty($arrayquery) { - // phpcs:enable + // phpcs:enable global $langs, $conf, $extrafields; $sql = "SELECT"; @@ -625,7 +625,7 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * @@ -633,9 +633,9 @@ class AdvanceTargetingMailing extends CommonObject * @param int $withThirdpartyFilter add contact with tridparty filter * @return int <0 if KO, >0 if OK */ - public function query_contact($arrayquery, $withThirdpartyFilter = 0) + public function query_contact($arrayquery, $withThirdpartyFilter = 0) { - // phpcs:enable + // phpcs:enable global $langs, $conf; $sql = "SELECT"; @@ -878,8 +878,8 @@ class AdvanceTargetingMailing extends CommonObject * For exemple jean;joe;jim%%;!jimo;!jima%> will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima * @return string Sql to use for the where condition */ - public function transformToSQL($column_to_test, $criteria) - { + public function transformToSQL($column_to_test, $criteria) + { $return_sql_criteria = '('; //This is a multiple value test diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 53fafb0ce61..9d230404cba 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -28,9 +28,9 @@ class FormAdvTargetEmailing extends Form { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -42,12 +42,12 @@ class FormAdvTargetEmailing extends Form * * @param DoliDB $db handler */ - public function __construct($db) - { - global $langs; + public function __construct($db) + { + global $langs; - $this->db = $db; - } + $this->db = $db; + } /** * Affiche un champs select contenant une liste @@ -56,8 +56,8 @@ class FormAdvTargetEmailing extends Form * @param string $htmlname select field * @return string select field */ - public function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') - { + public function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') + { global $conf, $langs; $options_array = array(); @@ -84,7 +84,7 @@ class FormAdvTargetEmailing extends Form dol_print_error($this->db); } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return combo list of activated countries, into language of user @@ -93,8 +93,8 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array or Code or Label of preselected country * @return string HTML string with select */ - public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) - { + public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) + { global $conf, $langs; $langs->load("dict"); @@ -142,7 +142,7 @@ class FormAdvTargetEmailing extends Form } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return select list for categories (to use in form search selectors) @@ -152,14 +152,14 @@ class FormAdvTargetEmailing extends Form * @param User $user User action * @return string combo list code */ - public function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) - { + public function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) + { global $conf; $options_array = array(); - $sql_usr = ''; + $sql_usr = ''; $sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; $sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql_usr .= " WHERE u2.entity IN (0,".$conf->entity.")"; @@ -183,7 +183,7 @@ class FormAdvTargetEmailing extends Form } return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return select list for categories (to use in form search selectors) @@ -192,8 +192,8 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array selected array * @return string combo list code */ - public function multiselectselectLanguage($htmlname = '', $selected_array = array()) - { + public function multiselectselectLanguage($htmlname = '', $selected_array = array()) + { global $conf, $langs; @@ -208,7 +208,7 @@ class FormAdvTargetEmailing extends Form } asort($options_array); return $this->advMultiselectarray($htmlname, $options_array, $selected_array); - } + } /** * Return multiselect list of entities for extrafeild type sellist @@ -330,14 +330,14 @@ class FormAdvTargetEmailing extends Form * @param int $showempty show empty * @return string HTML combo */ - public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) - { + public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) + { global $conf, $langs; $form = new Form($this->db); $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0, '', 0, 295); return $return; - } + } /** * Return a combo list to select emailing target selector @@ -349,8 +349,8 @@ class FormAdvTargetEmailing extends Form * @param string $morecss More CSS * @return string HTML combo */ - public function selectAdvtargetemailingTemplate($htmlname = 'template_id', $selected = 0, $showempty = 0, $type_element = 'mailing', $morecss = '') - { + public function selectAdvtargetemailingTemplate($htmlname = 'template_id', $selected = 0, $showempty = 0, $type_element = 'mailing', $morecss = '') + { global $conf, $user, $langs; $out = ''; @@ -390,5 +390,5 @@ class FormAdvTargetEmailing extends Form } $this->db->free($resql); return $out; - } + } } diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index a4088975bd2..48c00c697a1 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -68,8 +68,8 @@ class Mailing extends CommonObject public $user_valid; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creat; @@ -81,13 +81,13 @@ class Mailing extends CommonObject public $statuts = array(); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { $this->db = $db; // List of language codes for status @@ -101,7 +101,7 @@ class Mailing extends CommonObject $this->statut_dest[1] = 'MailingStatusSent'; $this->statut_dest[2] = 'MailingStatusRead'; $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore - } + } /** * Create an EMailing @@ -224,8 +224,8 @@ class Mailing extends CommonObject $this->title = $obj->title; $this->sujet = $obj->sujet; - if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT|ENT_HTML5))) { - $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT|ENT_HTML5); + if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) { + $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5); } else { $this->body = $obj->body; } @@ -427,7 +427,7 @@ class Mailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete targets emailing * @@ -435,7 +435,7 @@ class Mailing extends CommonObject */ public function delete_targets() { - // phpcs:enable + // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " WHERE fk_mailing = ".$this->id; @@ -451,7 +451,7 @@ class Mailing extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Change status of each recipient * @@ -460,7 +460,7 @@ class Mailing extends CommonObject */ public function reset_targets_status($user) { - // phpcs:enable + // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut = 0"; $sql .= " WHERE fk_mailing = ".$this->id; @@ -485,26 +485,26 @@ class Mailing extends CommonObject */ public function countNbOfTargets($mode) { - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " WHERE fk_mailing = ".$this->id; - if ($mode == 'alreadysent') $sql .= " AND statut <> 0"; - elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0"; - elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1"; - else { - $this->error = 'BadValueForParameterMode'; - return -2; - } + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " WHERE fk_mailing = ".$this->id; + if ($mode == 'alreadysent') $sql .= " AND statut <> 0"; + elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0"; + elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1"; + else { + $this->error = 'BadValueForParameterMode'; + return -2; + } - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj) return $obj->nb; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - return 0; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj) return $obj->nb; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + return 0; } @@ -593,7 +593,7 @@ class Mailing extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -603,7 +603,7 @@ class Mailing extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("mailing"); diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index ddcdaabf14e..8c1e392ed68 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -57,19 +57,19 @@ print '
'; //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo //{ - // Recherche emails - print ''; - print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + // Recherche emails + print ''; + print ''; + print '
'; + print '
'.$langs->trans("SearchAMailing").'
'; - print $langs->trans("Ref").':
'; - print $langs->trans("Other").':
'; + print ''; + print ''; + print ''; + print ''; - print "
'.$langs->trans("SearchAMailing").'
'; + print $langs->trans("Ref").':
'; + print $langs->trans("Other").':

\n"; + print "

\n"; //} @@ -82,63 +82,63 @@ $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) - { - $modulename = $reg[1]; - if ($modulename == 'example') continue; + while (($file = readdir($handle)) !== false) + { + if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) + { + $modulename = $reg[1]; + if ($modulename == 'example') continue; - // Loading Class - $file = $dir."/".$modulename.".modules.php"; - $classname = "mailing_".$modulename; - require_once $file; - $mailmodule = new $classname($db); + // Loading Class + $file = $dir."/".$modulename.".modules.php"; + $classname = "mailing_".$modulename; + require_once $file; + $mailmodule = new $classname($db); - $qualified = 1; - foreach ($mailmodule->require_module as $key) - { - if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) - { - $qualified = 0; - //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; - break; - } - } + $qualified = 1; + foreach ($mailmodule->require_module as $key) + { + if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) + { + $qualified = 0; + //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; + break; + } + } - // Si le module mailing est qualifi� - if ($qualified) - { - foreach ($mailmodule->getSqlArrayForStats() as $sql) - { - print ''; + // Si le module mailing est qualifi� + if ($qualified) + { + foreach ($mailmodule->getSqlArrayForStats() as $sql) + { + print ''; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); - $i = 0; + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - print ''.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; - $i++; - } + while ($i < $num) + { + $obj = $db->fetch_object($result); + print ''.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; + $i++; + } - $db->free($result); - } else { - dol_print_error($db); - } - print ''; - } - } - } - } - } - closedir($handle); + $db->free($result); + } else { + dol_print_error($db); + } + print ''; + } + } + } + } + } + closedir($handle); } @@ -160,42 +160,42 @@ $sql .= " ORDER BY m.date_creat DESC"; $sql .= " LIMIT ".$limit; $result = $db->query($sql); if ($result) { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; + print '
'.$langs->trans("LastMailings", $limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; - $num = $db->num_rows($result); - if ($num > 0) - { - $i = 0; + $num = $db->num_rows($result); + if ($num > 0) + { + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); + while ($i < $num) + { + $obj = $db->fetch_object($result); $mailstatic = new Mailing($db); $mailstatic->id = $obj->rowid; $mailstatic->ref = $obj->rowid; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } else { - print ''; - } - print "
'.$langs->trans("LastMailings", $limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'.$mailstatic->getNomUrl(1).''.dol_trunc($obj->title, 38).''.dol_print_date($db->jdate($obj->date_creat), 'day').''.($obj->nbemail ? $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->statut, 5).'
'.$langs->trans("None").'

"; - $db->free($result); + print ''; + print ''.$mailstatic->getNomUrl(1).''; + print ''.dol_trunc($obj->title, 38).''; + print ''.dol_print_date($db->jdate($obj->date_creat), 'day').''; + print ''.($obj->nbemail ? $obj->nbemail : "0").''; + print ''.$mailstatic->LibStatut($obj->statut, 5).''; + print ''; + $i++; + } + } else { + print ''.$langs->trans("None").''; + } + print "

"; + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } @@ -204,12 +204,12 @@ print '
'; if ($langs->file_exists("html/spam.html", 0)) { - print "



".$langs->trans("Note")."
"; - print '
'; - dol_print_file($langs, "html/spam.html", 0); - print '
'; + print "



".$langs->trans("Note")."
"; + print '
'; + dol_print_file($langs, "html/spam.html", 0); + print '
'; - print '
'; + print '
'; } $parameters = array('user' => $user); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 525064942a6..9da825e262e 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -60,7 +60,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'm.titre'=>'Ref', + 'm.titre'=>'Ref', ); @@ -169,7 +169,7 @@ if ($resql) $newcardbutton = ''; if ($user->rights->mailing->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create'); } $i = 0; @@ -190,8 +190,8 @@ if ($resql) $moreforfilter = ''; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; print ''; print ''; @@ -1718,9 +1718,9 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled)) { - print ''; - print '"; - print '"; + print ''; + print '"; + print '"; } } @@ -2208,21 +2208,21 @@ if ($action == 'create') print ''; } - $tmparray = $object->getTotalWeightVolume(); - $totalWeight = $tmparray['weight']; - $totalVolume = $tmparray['volume']; - if ($totalWeight) { - print ''; - print ''; - } - if ($totalVolume) { - print ''; - print ''; - } + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + if ($totalWeight) { + print ''; + print ''; + } + if ($totalVolume) { + print ''; + print ''; + } // Incoterms if (!empty($conf->incoterm->enabled)) @@ -2354,7 +2354,7 @@ if ($action == 'create') print '
'; if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { - print '
'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index dd84fbd651a..904f33cb1eb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -166,7 +166,7 @@ if (empty($reshook)) if ($object->id > 0) { if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY)) { //Get difference between old and new delivery date and change lines according to difference - $date_delivery = dol_mktime(12, 0, 0, + $date_delivery = dol_mktime(12, 0, 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int') @@ -174,7 +174,7 @@ if (empty($reshook)) if (!empty($object->date_livraison) && !empty($date_delivery)) { //Attempt to get the date without possible hour rounding errors - $old_date_delivery = dol_mktime(12, 0, 0, + $old_date_delivery = dol_mktime(12, 0, 0, dol_print_date($object->date_livraison, '%m'), dol_print_date($object->date_livraison, '%d'), dol_print_date($object->date_livraison, '%Y') @@ -666,82 +666,82 @@ if (empty($reshook)) } } // add lines from objectlinked elseif ($action == 'import_lines_from_object' - && $user->rights->propal->creer - && $object->statut == Propal::STATUS_DRAFT - ) + && $user->rights->propal->creer + && $object->statut == Propal::STATUS_DRAFT + ) { - $fromElement = GETPOST('fromelement'); - $fromElementid = GETPOST('fromelementid'); - $importLines = GETPOST('line_checkbox'); + $fromElement = GETPOST('fromelement'); + $fromElementid = GETPOST('fromelementid'); + $importLines = GETPOST('line_checkbox'); - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) - { - if ($fromElement == 'commande') - { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') - { - dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'PropaleLigne'; - } - $nextRang = count($object->lines) + 1; - $importCount = 0; - $error = 0; - foreach ($importLines as $lineId) - { - $lineId = intval($lineId); - $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) - { - $originLine->fetch_optionals(); - $desc = $originLine->desc; - $pu_ht = $originLine->subprice; - $qty = $originLine->qty; - $txtva = $originLine->tva_tx; - $txlocaltax1 = $originLine->localtax1_tx; - $txlocaltax2 = $originLine->localtax2_tx; - $fk_product = $originLine->fk_product; - $remise_percent = $originLine->remise_percent; - $date_start = $originLine->date_start; - $date_end = $originLine->date_end; - $ventil = 0; - $info_bits = $originLine->info_bits; - $fk_remise_except = $originLine->fk_remise_except; - $price_base_type = 'HT'; - $pu_ttc = 0; - $type = $originLine->product_type; - $rang = $nextRang++; - $special_code = $originLine->special_code; - $origin = $originLine->element; - $origin_id = $originLine->id; - $fk_parent_line = 0; - $fk_fournprice = $originLine->fk_fournprice; - $pa_ht = $originLine->pa_ht; - $label = $originLine->label; - $array_options = $originLine->array_options; - $situation_percent = 100; - $fk_prev_id = ''; - $fk_unit = $originLine->fk_unit; - $pu_ht_devise = $originLine->multicurrency_subprice; + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if ($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'OrderLine'; + } elseif ($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach ($importLines as $lineId) + { + $lineId = intval($lineId); + $originLine = new $lineClassName($db); + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + { + $originLine->fetch_optionals(); + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type = 'HT'; + $pu_ttc = 0; + $type = $originLine->product_type; + $rang = $nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + $situation_percent = 100; + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; - $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except); + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except); - if ($res > 0) { - $importCount++; - } else { - $error++; - } - } else { - $error++; - } - } + if ($res > 0) { + $importCount++; + } else { + $error++; + } + } else { + $error++; + } + } - if ($error) - { - setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); - } - } + if ($error) + { + setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); + } + } } include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -890,8 +890,8 @@ if (empty($reshook)) $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) @@ -1286,8 +1286,8 @@ if (empty($reshook)) header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } elseif ($action == 'classin' && $usercancreate) { - // Set project - $object->setProject(GETPOST('projectid', 'int')); + // Set project + $object->setProject(GETPOST('projectid', 'int')); } // Delivery time elseif ($action == 'setavailability' && $usercancreate) { $result = $object->set_availability($user, GETPOST('availability_id', 'int')); @@ -1530,7 +1530,7 @@ if ($action == 'create') if ($socid > 0) { - // Contacts (ask contact only if thirdparty already defined). + // Contacts (ask contact only if thirdparty already defined). print "
".$langs->trans("DefaultContact").''; $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print '
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva)."
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc)."
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva)."
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc)."
'.$langs->trans("CalculatedWeight").''; - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - print '
'.$langs->trans("CalculatedVolume").''; - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - print '
'.$langs->trans("CalculatedWeight").''; + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + print '
'.$langs->trans("CalculatedVolume").''; + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); + print '
'; + print '
'; } if (!empty($object->lines)) @@ -2379,7 +2379,7 @@ if ($action == 'create') if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { - print '
'; + print ''; } print '
'; @@ -2535,7 +2535,7 @@ if ($action == 'create') $compatibleImportElementsList = false; if ($user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT) { - $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index e5176cebdde..602e3445ae2 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1350,7 +1350,7 @@ class Propal extends CommonObject $object->id = 0; $object->ref = ''; - $object->entity = (! empty($forceentity) ? $forceentity : $object->entity); + $object->entity = (!empty($forceentity) ? $forceentity : $object->entity); $object->statut = self::STATUS_DRAFT; // Clear fields @@ -1499,14 +1499,14 @@ class Propal extends CommonObject $this->project = null; // Clear if another value was already set by fetch_projet $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated + $this->modelpdf = $obj->model_pdf; // deprecated $this->last_main_doc = $obj->last_main_doc; $this->note = $obj->note_private; // TODO deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->status = (int) $obj->fk_statut; - $this->statut = $this->status; // deprecated + $this->statut = $this->status; // deprecated $this->statut_libelle = $obj->statut_label; $this->datec = $this->db->jdate($obj->datec); // TODO deprecated @@ -2074,7 +2074,7 @@ class Propal extends CommonObject return $this->setDeliveryDate($user, $delivery_date, $notrigger); } - /** + /** * Set delivery date * * @param User $user Object user that modify @@ -2082,7 +2082,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function setDeliveryDate($user, $delivery_date, $notrigger = 0) + public function setDeliveryDate($user, $delivery_date, $notrigger = 0) { if (!empty($user->rights->propal->creer)) { @@ -2141,9 +2141,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_availability($user, $id, $notrigger = 0) + public function set_availability($user, $id, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (!empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) { $error = 0; @@ -2208,9 +2208,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function set_demand_reason($user, $id, $notrigger = 0) + public function set_demand_reason($user, $id, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (!empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) { $error = 0; @@ -2277,9 +2277,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function set_ref_client($user, $ref_client, $notrigger = 0) + public function set_ref_client($user, $ref_client, $notrigger = 0) { - // phpcs:enable + // phpcs:enable if (!empty($user->rights->propal->creer)) { $error = 0; @@ -2338,9 +2338,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function set_remise_percent($user, $remise, $notrigger = 0) + public function set_remise_percent($user, $remise, $notrigger = 0) { - // phpcs:enable + // phpcs:enable $remise = trim($remise) ?trim($remise) : 0; if (!empty($user->rights->propal->creer)) @@ -2403,9 +2403,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { - // phpcs:enable + // phpcs:enable $remise = trim($remise) ?trim($remise) : 0; if (!empty($user->rights->propal->creer)) @@ -2470,7 +2470,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function reopen($user, $statut, $note = '', $notrigger = 0) + public function reopen($user, $statut, $note = '', $notrigger = 0) { $this->statut = $statut; @@ -2529,7 +2529,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - public function cloture($user, $status, $note = "", $notrigger = 0) + public function cloture($user, $status, $note = "", $notrigger = 0) { global $langs, $conf; @@ -2628,7 +2628,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - public function classifyBilled(User $user, $notrigger = 0) + public function classifyBilled(User $user, $notrigger = 0) { $error = 0; @@ -2682,15 +2682,15 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function setDraft($user, $notrigger = 0) + public function setDraft($user, $notrigger = 0) { - // phpcs:enable + // phpcs:enable $error = 0; // Protection if ($this->statut <= self::STATUS_DRAFT) { - return 0; + return 0; } dol_syslog(get_class($this)."::setDraft", LOG_DEBUG); @@ -2723,10 +2723,10 @@ class Propal extends CommonObject if (!$error) { - $this->statut = self::STATUS_DRAFT; - $this->brouillon = 1; + $this->statut = self::STATUS_DRAFT; + $this->brouillon = 1; - $this->db->commit(); + $this->db->commit(); return 1; } else { foreach ($this->errors as $errmsg) @@ -2740,7 +2740,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of proposal (eventually filtered on user) into an array * @@ -2754,9 +2754,9 @@ class Propal extends CommonObject * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') { - // phpcs:enable + // phpcs:enable global $user; $ga = array(); @@ -2818,7 +2818,7 @@ class Propal extends CommonObject * * @return array Array of invoices */ - public function getInvoiceArrayList() + public function getInvoiceArrayList() { return $this->InvoiceArrayList($this->id); } @@ -2830,9 +2830,9 @@ class Propal extends CommonObject * @param int $id Id propal * @return array Array of invoices id */ - public function InvoiceArrayList($id) + public function InvoiceArrayList($id) { - // phpcs:enable + // phpcs:enable $ga = array(); $linkedInvoices = array(); @@ -2912,7 +2912,7 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int 1 if ok, otherwise if error */ - public function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2931,9 +2931,9 @@ class Propal extends CommonObject if (!$error) { - $main = MAIN_DB_PREFIX.'propaldet'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = ".$this->id.")"; + $main = MAIN_DB_PREFIX.'propaldet'; + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id; if ($this->db->query($sqlef) && $this->db->query($sql)) { @@ -3031,7 +3031,7 @@ class Propal extends CommonObject * @return int >0 if OK, <0 if KO * @deprecated use set_availability */ - public function availability($availability_id, $notrigger = 0) + public function availability($availability_id, $notrigger = 0) { global $user; @@ -3098,9 +3098,9 @@ class Propal extends CommonObject * @return int >0 si ok, <0 si ko * @deprecated use set_demand_reason */ - public function demand_reason($demand_reason_id, $notrigger = 0) + public function demand_reason($demand_reason_id, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $user; if ($this->statut >= self::STATUS_DRAFT) @@ -3164,7 +3164,7 @@ class Propal extends CommonObject * @param int $id Proposal id * @return void */ - public function info($id) + public function info($id) { $sql = "SELECT c.rowid, "; $sql .= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; @@ -3217,12 +3217,12 @@ class Propal extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status (draft, validated, ...) * @@ -3230,9 +3230,9 @@ class Propal extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($status, $mode = 1) + public function LibStatut($status, $mode = 1) { - // phpcs:enable + // phpcs:enable global $conf; // Init/load array of translation of status @@ -3263,7 +3263,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -3271,9 +3271,9 @@ class Propal extends CommonObject * @param int $mode "opened" for proposal to close, "signed" for proposal to invoice * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board($user, $mode) + public function load_board($user, $mode) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $clause = " WHERE"; @@ -3354,7 +3354,7 @@ class Propal extends CommonObject * * @return void */ - public function initAsSpecimen() + public function initAsSpecimen() { global $conf, $langs; @@ -3431,7 +3431,7 @@ class Propal extends CommonObject { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; - $line->product_ref = 'SPECIMEN'; + $line->product_ref = 'SPECIMEN'; } $this->lines[$xnbp] = $line; @@ -3450,9 +3450,9 @@ class Propal extends CommonObject * * @return int <0 if ko, >0 if ok */ - public function load_state_board() + public function load_state_board() { - // phpcs:enable + // phpcs:enable global $user; $this->nb = array(); @@ -3494,7 +3494,7 @@ class Propal extends CommonObject * @param Societe $soc Object thirdparty * @return string Reference libre pour la propale */ - public function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $langs; $langs->load("propal"); @@ -3549,10 +3549,10 @@ class Propal extends CommonObject * @param string $get_params Parametres added to url * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $addlinktonotes -1=Disable, 0=Just add label show notes, 1=Add private note (only internal user), 2=Add public note (internal or external user), 3=Add private (internal user) and public note (internal and external user) + * @param int $addlinktonotes -1=Disable, 0=Just add label show notes, 1=Add private note (only internal user), 2=Add public note (internal or external user), 3=Add private (internal user) and public note (internal and external user) * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = -1) + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = -1) { global $langs, $conf, $user; @@ -3620,45 +3620,45 @@ class Propal extends CommonObject if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; - if ($addlinktonotes >= 0) { - $txttoshow = ''; + if ($addlinktonotes >= 0) { + $txttoshow = ''; - if ($addlinktonotes == 0) { - if (!empty($this->note_private) || !empty($this->note_public)) { - $txttoshow = $langs->trans('ViewPrivateNote'); - } - } elseif ($addlinktonotes == 1) { - if (!empty($this->note_private)) { - $txttoshow .= ($user->socid > 0 ? '' : dol_string_nohtmltag($this->note_private, 1)); - } - } elseif ($addlinktonotes == 2) { - if (!empty($this->note_public)) { - $txttoshow .= dol_string_nohtmltag($this->note_public, 1); - } - } elseif ($addlinktonotes == 3) { - if ($user->socid > 0) { - if (!empty($this->note_public)) { - $txttoshow .= dol_string_nohtmltag($this->note_public, 1); - } - } else { - if (!empty($this->note_public)) { - $txttoshow .= dol_string_nohtmltag($this->note_public, 1); - } - if (!empty($this->note_private)) { - if (!empty($txttoshow)) $txttoshow .= '

'; - $txttoshow .= dol_string_nohtmltag($this->note_private, 1); - } - } - } + if ($addlinktonotes == 0) { + if (!empty($this->note_private) || !empty($this->note_public)) { + $txttoshow = $langs->trans('ViewPrivateNote'); + } + } elseif ($addlinktonotes == 1) { + if (!empty($this->note_private)) { + $txttoshow .= ($user->socid > 0 ? '' : dol_string_nohtmltag($this->note_private, 1)); + } + } elseif ($addlinktonotes == 2) { + if (!empty($this->note_public)) { + $txttoshow .= dol_string_nohtmltag($this->note_public, 1); + } + } elseif ($addlinktonotes == 3) { + if ($user->socid > 0) { + if (!empty($this->note_public)) { + $txttoshow .= dol_string_nohtmltag($this->note_public, 1); + } + } else { + if (!empty($this->note_public)) { + $txttoshow .= dol_string_nohtmltag($this->note_public, 1); + } + if (!empty($this->note_private)) { + if (!empty($txttoshow)) $txttoshow .= '

'; + $txttoshow .= dol_string_nohtmltag($this->note_private, 1); + } + } + } - if ($txttoshow) { - $result .= ' '; - $result .= ''; - $result .= img_picto('', 'note'); - $result .= ''; - $result .= ''; - } - } + if ($txttoshow) { + $result .= ' '; + $result .= ''; + $result .= img_picto('', 'note'); + $result .= ''; + $result .= ''; + } + } return $result; } @@ -3668,7 +3668,7 @@ class Propal extends CommonObject * * @return int >0 if OK, <0 if KO */ - public function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -3681,7 +3681,7 @@ class Propal extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -3740,68 +3740,68 @@ class PropaleLigne extends CommonObjectLine */ public $table_element = 'propaldet'; - public $oldline; + public $oldline; // From llx_propaldet - public $fk_propal; - public $fk_parent_line; - public $desc; // Description ligne - public $fk_product; // Id produit predefini + public $fk_propal; + public $fk_parent_line; + public $desc; // Description ligne + public $fk_product; // Id produit predefini /** * @deprecated * @see $product_type */ - public $fk_product_type; + public $fk_product_type; /** * Product type. * @var int * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE */ - public $product_type = Product::TYPE_PRODUCT; + public $product_type = Product::TYPE_PRODUCT; - public $qty; - public $tva_tx; - public $subprice; - public $remise_percent; - public $fk_remise_except; + public $qty; + public $tva_tx; + public $subprice; + public $remise_percent; + public $fk_remise_except; - public $rang = 0; + public $rang = 0; - public $fk_fournprice; - public $pa_ht; - public $marge_tx; - public $marque_tx; + public $fk_fournprice; + public $pa_ht; + public $marge_tx; + public $marque_tx; - public $special_code; // Tag for special lines (exlusive tags) + public $special_code; // Tag for special lines (exlusive tags) // 1: frais de port // 2: ecotaxe // 3: option line (when qty = 0) - public $info_bits = 0; // Some other info: + public $info_bits = 0; // Some other info: // Bit 0: 0 si TVA normal - 1 si TVA NPR // Bit 1: 0 ligne normale - 1 si ligne de remise fixe - public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne - public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne - public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne + public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne + public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne /** * @deprecated * @see $remise_percent, $fk_remise_except */ - public $remise; + public $remise; /** * @deprecated * @see $subprice */ - public $price; + public $price; // From llx_product /** * @deprecated * @see $product_ref */ - public $ref; + public $ref; /** * Product reference * @var string @@ -3811,7 +3811,7 @@ class PropaleLigne extends CommonObjectLine * @deprecated * @see $product_label */ - public $libelle; + public $libelle; /** * Product label * @var string @@ -3823,32 +3823,32 @@ class PropaleLigne extends CommonObjectLine */ public $product_desc; - public $localtax1_tx; // Local tax 1 - public $localtax2_tx; // Local tax 2 - public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type - public $total_localtax1; // Line total local tax 1 - public $total_localtax2; // Line total local tax 2 + public $localtax1_tx; // Local tax 1 + public $localtax2_tx; // Local tax 2 + public $localtax1_type; // Local tax 1 type + public $localtax2_type; // Local tax 2 type + public $total_localtax1; // Line total local tax 1 + public $total_localtax2; // Line total local tax 2 - public $date_start; - public $date_end; + public $date_start; + public $date_end; - public $skip_update_total; // Skip update price total for special lines + public $skip_update_total; // Skip update price total for special lines // Multicurrency - public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_subprice; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; /** * Class line Contructor * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -3859,7 +3859,7 @@ class PropaleLigne extends CommonObjectLine * @param int $rowid Propal line id * @return int <0 if KO, >0 if OK */ - public function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,'; $sql .= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; @@ -3949,7 +3949,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - public function insert($notrigger = 0) + public function insert($notrigger = 0) { global $conf, $user; @@ -3981,7 +3981,7 @@ class PropaleLigne extends CommonObjectLine if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; - // if buy price not defined, define buyprice as configured in margin admin + // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) @@ -4088,7 +4088,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function delete(User $user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf; @@ -4139,7 +4139,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - public function update($notrigger = 0) + public function update($notrigger = 0) { global $conf, $user; @@ -4147,7 +4147,7 @@ class PropaleLigne extends CommonObjectLine $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. - if (empty($this->id) && ! empty($this->rowid)) $this->id = $this->rowid; + if (empty($this->id) && !empty($this->rowid)) $this->id = $this->rowid; // Clean parameters if (empty($this->tva_tx)) $this->tva_tx = 0; @@ -4265,9 +4265,9 @@ class PropaleLigne extends CommonObjectLine * * @return int <0 if KO, >0 if OK */ - public function update_total() + public function update_total() { - // phpcs:enable + // phpcs:enable $this->db->begin(); // Mise a jour ligne en base diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 8f71447ab0b..ca95be53fc1 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -36,18 +36,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; */ class PropaleStats extends Stats { - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element; - public $socid; - public $userid; + public $socid; + public $userid; - public $from; - public $field; - public $where; - public $join; + public $from; + public $field; + public $where; + public $join; /** @@ -55,65 +55,65 @@ class PropaleStats extends Stats * * @param DoliDB $db Database handler * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. - * @param int $userid Id user for filter (creation user) + * @param int $userid Id user for filter (creation user) * @param string $mode Option ('customer', 'supplier') - * @param int $typentid Id typent of thirdpary for filter - * @param int $categid Id category of thirdpary for filter + * @param int $typentid Id typent of thirdpary for filter + * @param int $categid Id category of thirdpary for filter */ - public function __construct($db, $socid = 0, $userid = 0, $mode = 'customer', $typentid = 0, $categid = 0) + public function __construct($db, $socid = 0, $userid = 0, $mode = 'customer', $typentid = 0, $categid = 0) { global $user, $conf; $this->db = $db; - $this->socid = ($socid > 0 ? $socid : 0); - $this->userid = $userid; - $this->join = ''; + $this->socid = ($socid > 0 ? $socid : 0); + $this->userid = $userid; + $this->join = ''; - if ($mode == 'customer') - { - $object = new Propal($this->db); + if ($mode == 'customer') + { + $object = new Propal($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; - $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date = 'p.datep'; - $this->field = 'total_ht'; - $this->field_line = 'total_ht'; + $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; + $this->field_date = 'p.datep'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - //$this->where .= " p.fk_statut > 0"; - } - if ($mode == 'supplier') - { - $object = new SupplierProposal($this->db); + //$this->where .= " p.fk_statut > 0"; + } + if ($mode == 'supplier') + { + $object = new SupplierProposal($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; - $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date = 'p.date_valid'; - $this->field = 'total_ht'; - $this->field_line = 'total_ht'; + $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; + $this->field_date = 'p.date_valid'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - //$this->where .= " p.fk_statut > 0"; // Validated, accepted, refused and closed - } + //$this->where .= " p.fk_statut > 0"; // Validated, accepted, refused and closed + } //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; - $this->where .= ($this->where ? ' AND ' : '')."p.entity IN (".getEntity('propal').")"; + $this->where .= ($this->where ? ' AND ' : '')."p.entity IN (".getEntity('propal').")"; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($this->socid) { $this->where .= " AND p.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid; - if ($typentid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; - $this->where .= ' AND s.fk_typent = '.$typentid; - } + if ($typentid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; + $this->where .= ' AND s.fk_typent = '.$typentid; + } - if ($categid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = p.fk_soc'; - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; - $this->where .= ' AND c.rowid = '.$categid; - } + if ($categid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_soc = p.fk_soc'; + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as c ON c.rowid = cs.fk_categorie'; + $this->where .= ' AND c.rowid = '.$categid; + } } @@ -121,21 +121,21 @@ class PropaleStats extends Stats * Return propals number by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with number by month */ - public function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); return $res; @@ -147,17 +147,17 @@ class PropaleStats extends Stats * @return array Array with number by year * */ - public function getNbByYear() + public function getNbByYear() { global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -166,21 +166,21 @@ class PropaleStats extends Stats * Return the propals amount by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with amount by month */ - public function getAmountByMonth($year, $format) + public function getAmountByMonth($year, $format) { global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getAmountByMonth($year, $sql, $format); return $res; @@ -192,18 +192,18 @@ class PropaleStats extends Stats * @param int $year year for stats * @return array array with number by month */ - public function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -213,17 +213,17 @@ class PropaleStats extends Stats * * @return array Array of values */ - public function getAllByYear() + public function getAllByYear() { global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -234,23 +234,23 @@ class PropaleStats extends Stats * Return nb, amount of predefined product for year * * @param int $year Year to scan - * @param int $limit Limit + * @param int $limit Limit * @return array Array of values */ - public function getAllByProduct($year, $limit = 10) + public function getAllByProduct($year, $limit = 10) { global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; - $sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " GROUP BY product.ref"; - $sql .= $this->db->order('nb', 'DESC'); - //$sql.= $this->db->plimit(20); + $sql .= $this->db->order('nb', 'DESC'); + //$sql.= $this->db->plimit(20); return $this->_getAllByProduct($sql, $limit); } diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 9c491c7227c..4d70b11cdfe 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -76,11 +76,11 @@ if (!$error) if ($action == 'addcontact' && $user->rights->propale->creer) { - if ($object->id > 0) - { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + if ($object->id > 0) + { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } + } if ($result >= 0) { @@ -100,7 +100,7 @@ elseif ($action == 'swapstatut' && $user->rights->propale->creer) { if ($object->id > 0) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } } // Deletes a contact elseif ($action == 'deletecontact' && $user->rights->propale->creer) @@ -135,7 +135,7 @@ $formother = new FormOther($db); if ($object->id > 0) { - $head = propal_prepare_head($object); + $head = propal_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans("Proposal"), -1, 'propal'); @@ -153,36 +153,36 @@ if ($object->id > 0) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->propal->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->propal->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 309c2a44ad4..fbe7fdbec5c 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -78,9 +78,9 @@ $object->fetch($id, $ref); if ($object->id > 0) { - $object->fetch_thirdparty(); - $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; + $object->fetch_thirdparty(); + $upload_dir = $conf->propal->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } @@ -122,36 +122,36 @@ if ($object->id > 0) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->propal->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->propal->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 692f561867a..b51f138b0e5 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -154,7 +154,7 @@ if ($resql) } } - if ($conf->use_javascript_ajax) { + if ($conf->use_javascript_ajax) { print ''; print ''; diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index e56a5129c5c..cf63d919f62 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -46,8 +46,8 @@ $result = restrictedArea($user, 'propal', $id); $object = new Propal($db); if (!$object->fetch($id, $ref) > 0) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } @@ -82,36 +82,36 @@ $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->ge // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->propal->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->propal->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 80b991a2526..06be1179fb1 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -75,7 +75,7 @@ if ($id > 0 || !empty($ref)) { if ($object->fetch_thirdparty() > 0) { - $head = propal_prepare_head($object); + $head = propal_prepare_head($object); print dol_get_fiche_head($head, 'note', $langs->trans('Proposal'), -1, 'propal'); $cssclass = 'titlefield'; @@ -97,36 +97,36 @@ if ($id > 0 || !empty($ref)) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->propal->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->propal->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref .= ' : '; } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index e439056de5f..8b9c6b34dee 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -50,8 +50,8 @@ $socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $nowyear = strftime("%Y", dol_now()); @@ -77,19 +77,19 @@ $langs->loadLangs(array('propal', 'other', 'companies')); if ($mode == 'customer') { - $picto = 'propal'; - $title = $langs->trans("ProposalsStatistics"); - $dir = $conf->propale->dir_temp; - $cat_type = Categorie::TYPE_CUSTOMER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); + $picto = 'propal'; + $title = $langs->trans("ProposalsStatistics"); + $dir = $conf->propale->dir_temp; + $cat_type = Categorie::TYPE_CUSTOMER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); } if ($mode == 'supplier') { $picto = 'supplier_proposal'; - $title = $langs->trans("ProposalsStatisticsSuppliers"); - $dir = $conf->supplier_proposal->dir_temp; - $cat_type = Categorie::TYPE_SUPPLIER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); + $title = $langs->trans("ProposalsStatisticsSuppliers"); + $dir = $conf->supplier_proposal->dir_temp; + $cat_type = Categorie::TYPE_SUPPLIER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); } llxHeader('', $title); @@ -110,36 +110,36 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; + $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png'; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; + $filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { - $px1->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfProposals")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); + $px1->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfProposals")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); - $px1->draw($filenamenb, $fileurlnb); + $px1->draw($filenamenb, $fileurlnb); } // Build graphic amount of object @@ -148,36 +148,36 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, 0); if (!$user->rights->societe->client->voir || $user->socid) { - $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; - $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; + $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png'; - $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; + $filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; } $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { - $px2->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfProposals")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); + $px2->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfProposals")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode = 'depth'; + $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); - $px2->draw($filenameamount, $fileurlamount); + $px2->draw($filenameamount, $fileurlamount); } $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); @@ -185,38 +185,38 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); $fileurl_avg = ''; if (!$user->rights->societe->client->voir || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; } else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); + $px3->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); - $px3->draw($filename_avg, $fileurl_avg); + $px3->draw($filename_avg, $fileurl_avg); } @@ -260,23 +260,23 @@ print '
'; $filter = 's.client IN (1,2,3)'; print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"'); print ''; - // ThirdParty Type - print ''.$langs->trans("ThirdPartyType").''; - $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. - print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent); - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print ''; - // Category - print ''.$cat_label.''; - print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); - print ''; + // ThirdParty Type + print ''.$langs->trans("ThirdPartyType").''; + $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. + print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent); + if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ''; + // Category + print ''.$cat_label.''; + print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); + print ''; // User print ''.$langs->trans("CreatedBy").''; print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ''; // Status print ''.$langs->trans("Status").''; - $formpropal->selectProposalStatus(($object_status != '' ? $object_status : -1), 0, 0, 1, $mode, 'object_status'); + $formpropal->selectProposalStatus(($object_status != '' ? $object_status : -1), 0, 0, 1, $mode, 'object_status'); print ''; // Year print ''.$langs->trans("Year").''; @@ -306,31 +306,31 @@ print ''; $oldyear = 0; foreach ($data as $val) { - $year = $val['year']; - while (!empty($year) && $oldyear > $year + 1) - { // If we have empty year - $oldyear--; + $year = $val['year']; + while (!empty($year) && $oldyear > $year + 1) + { // If we have empty year + $oldyear--; - print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; - print '0'; - print ''; - print '0'; - print ''; - print '0'; - print ''; - print ''; - } - print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$year.''; - print ''.$val['nb'].''; + print ''; + print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; + print '0'; + print ''; + print '0'; + print ''; + print '0'; + print ''; + print ''; + } + print ''; + print ' 0 ? '&userid='.$userid : '').'">'.$year.''; + print ''.$val['nb'].''; print ''.round($val['nb_diff']).''; - print ''.price(price2num($val['total'], 'MT'), 1).''; + print ''.price(price2num($val['total'], 'MT'), 1).''; print ''.round($val['total_diff']).''; - print ''.price(price2num($val['avg'], 'MT'), 1).''; + print ''.price(price2num($val['avg'], 'MT'), 1).''; print ''.round($val['avg_diff']).''; - print ''; - $oldyear = $year; + print ''; + $oldyear = $year; } print ''; @@ -342,11 +342,11 @@ print '
'; // Show graphs print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); - print "
\n"; - print $px2->show(); - print "
\n"; - print $px3->show(); + print $px1->show(); + print "
\n"; + print $px2->show(); + print "
\n"; + print $px3->show(); } print '
'; diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 160ae657ce9..300b35cc868 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -25,8 +25,8 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { - print "Error, template page can't be called as URL"; - exit; + print "Error, template page can't be called as URL"; + exit; } @@ -46,42 +46,42 @@ $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; - print ''; - print ''.$langs->trans("Proposal"); - if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) - { - $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; - print ' '; - } - print ''; - print ''.$objectlink->getNomUrl(1).''; - print ''.$objectlink->ref_client.''; - print ''.dol_print_date($objectlink->date, 'day').''; - print ''; - if ($user->rights->propale->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + print ''; + print ''.$langs->trans("Proposal"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) + { + $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; + print ' '; } - print ''; - print ''.$objectlink->getLibStatut(3).''; - print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; - print "\n"; + print ''; + print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->ref_client.''; + print ''.dol_print_date($objectlink->date, 'day').''; + print ''; + if ($user->rights->propale->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } + print ''; + print ''.$objectlink->getLibStatut(3).''; + print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + print "\n"; } if (count($linkedObjectBlock) > 1) { - print ''; - print ''.$langs->trans("Total").''; - print ''; - print ''; - print ''; - print ''.price($total).''; - print ''; - print ''; - print "\n"; + print ''; + print ''.$langs->trans("Total").''; + print ''; + print ''; + print ''; + print ''.price($total).''; + print ''; + print ''; + print "\n"; } print "\n"; diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index d99b3509b26..7ae61362f09 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -206,11 +206,11 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) print img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.''; print ""; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->canvas = $obj->canvas; - print $companystatic->getNomUrl(1, '', 44); + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; + print $companystatic->getNomUrl(1, '', 44); print "\n"; print ""; print dol_print_date($db->jdate($obj->dp), 'day')."\n"; @@ -257,11 +257,11 @@ if ($resql) $obj = $db->fetch_object($resql); print ''; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = $obj->client; - $companystatic->canvas = $obj->canvas; - print $companystatic->getNomUrl(1, 'prospect', 44); + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->canvas = $obj->canvas; + print $companystatic->getNomUrl(1, 'prospect', 44); print ''; $i++; } diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php index 6302b7680ab..1acf2cbf218 100644 --- a/htdocs/comm/prospect/recap-prospect.php +++ b/htdocs/comm/prospect/recap-prospect.php @@ -34,8 +34,8 @@ if (!empty($conf->facture->enabled)) $langs->load("bills"); $socid = $_GET["socid"]; if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } @@ -48,38 +48,38 @@ llxHeader(); if ($socid > 0) { - $societe = new Societe($db); - $societe->fetch($socid); + $societe = new Societe($db); + $societe->fetch($socid); - /* + /* * Affichage onglets */ $head = societe_prepare_head($societe); - print dol_get_fiche_head($head, 'prospect', $langs->trans("ThirdParty"), 0, 'company'); + print dol_get_fiche_head($head, 'prospect', $langs->trans("ThirdParty"), 0, 'company'); - print "\n"; - print '
'; + print "\n"; + print '
'; - print ''; + print '
'; - // Name - print ''; + // Name + print ''; // Prefix - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } - print "
'.$langs->trans("Thirdpary").''.$societe->getNomUrl(1).'
'.$langs->trans("Thirdpary").''.$societe->getNomUrl(1).'
'.$langs->trans("Prefix").''; - print ($societe->prefix_comm ? $societe->prefix_comm : ' '); - print '
'.$langs->trans("Prefix").''; + print ($societe->prefix_comm ? $societe->prefix_comm : ' '); + print '
"; + print "
"; - print "
\n"; + print "\n"; - print '
'; + print '
'; print $langs->trans("FeatureNotYetAvailable"); diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index 9ac8062c156..254305a9443 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -34,8 +34,8 @@ if (!empty($conf->facture->enabled)) $langs->load("bills"); $socid = $_GET["socid"]; if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } @@ -48,38 +48,38 @@ llxHeader(); if ($socid > 0) { - $societe = new Societe($db); - $societe->fetch($socid); + $societe = new Societe($db); + $societe->fetch($socid); - /* + /* * Affichage onglets */ $head = societe_prepare_head($societe); - print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); + print dol_get_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); - print "\n"; - print '
'; + print "\n"; + print '
'; - print ''; + print '
'; - // Name - print ''; + // Name + print ''; - // Prefix - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } + // Prefix + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } - print "
'.$langs->trans("ThirdParty").''.$societe->getNomUrl(1).'
'.$langs->trans("ThirdParty").''.$societe->getNomUrl(1).'
'.$langs->trans("Prefix").''; - print ($societe->prefix_comm ? $societe->prefix_comm : ' '); - print '
'.$langs->trans("Prefix").''; + print ($societe->prefix_comm ? $societe->prefix_comm : ' '); + print '
"; + print "
"; - print "
\n"; + print "\n"; - print '
'; + print '
'; print $langs->trans("FeatureNotYetAvailable"); diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 21f06e7bc1d..34ac6229ac1 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -47,8 +47,8 @@ $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; + header("Location: ".$backtopage); + exit; } if (GETPOST('action', 'aZ09') == 'setremise') @@ -66,14 +66,14 @@ if (GETPOST('action', 'aZ09') == 'setremise') if ($result > 0) { - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } else { - header("Location: remise.php?id=".$_GET["id"]); - exit; - } + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } else { + header("Location: remise.php?id=".$_GET["id"]); + exit; + } } else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -108,28 +108,28 @@ if ($socid > 0) print '
'; print ''; print ''; - print ''; + print ''; print dol_get_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 '
'; - print '
'; + print '
'; - if (!$isCustomer && !$isSupplier) { - print '

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

'; + if (!$isCustomer && !$isSupplier) { + print '

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

'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print ''; + print ''; - // End of page - llxFooter(); - $db->close(); - exit; - } + // End of page + llxFooter(); + $db->close(); + exit; + } print ''; @@ -172,7 +172,7 @@ if ($socid > 0) print ''; } if ($isSupplier) { - print ' '; + print ' '; } print ''; } @@ -193,11 +193,11 @@ if ($socid > 0) print '
'; print ''; - if (!empty($backtopage)) - { - print '     '; - print ''; - } + if (!empty($backtopage)) + { + print '     '; + print ''; + } print '
'; print ""; @@ -234,22 +234,22 @@ if ($socid > 0) print ''; print ''; $num = $db->num_rows($resql); - if ($num > 0) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } + if ($num > 0) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } } else { - print ''; + print ''; } $db->free($resql); print "
'.$langs->trans("User").'
'.dol_print_date($db->jdate($obj->dc), "dayhour").''.price2num($obj->remise_percent).'%'.$obj->note.''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'
'.dol_print_date($db->jdate($obj->dc), "dayhour").''.price2num($obj->remise_percent).'%'.$obj->note.''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'
'.$langs->trans("None").'
'.$langs->trans("None").'
"; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 922e384af4d..98aa79161fb 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -52,8 +52,8 @@ if ($user->socid > 0) if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; + header("Location: ".$backtopage); + exit; } if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') @@ -138,8 +138,8 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') $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 - // 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; + // 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); @@ -181,13 +181,13 @@ if ($action == 'setremise' && $user->rights->societe->creer) if ($discountid > 0) { - if (!empty($backtopage)) - { - header("Location: ".$backtopage.'&discountid='.$discountid); - exit; - } else { - header("Location: remx.php?id=".$id); - exit; + if (!empty($backtopage)) + { + header("Location: ".$backtopage.'&discountid='.$discountid); + exit; + } else { + header("Location: remx.php?id=".$id); + exit; } } else { $error++; @@ -248,27 +248,27 @@ if ($socid > 0) print '
'; print ''; print ''; - print ''; + print ''; print dol_get_fiche_head($head, 'absolutediscount', $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 '
'; - print '
'; + print '
'; - if (!$isCustomer && !$isSupplier) { - print '

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

'; + if (!$isCustomer && !$isSupplier) { + print '

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

'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print ''; + print ''; - llxFooter(); - $db->close(); - exit; - } + llxFooter(); + $db->close(); + exit; + } print ''; @@ -298,7 +298,7 @@ if ($socid > 0) if (!empty($user->fk_soc)) // No need to show this for external users { print ''; - print ''; + print ''; } } @@ -341,56 +341,56 @@ if ($socid > 0) if ($user->rights->societe->creer) { - print '
'; + print '
'; - print load_fiche_titre($langs->trans("NewGlobalDiscount"), '', ''); + print load_fiche_titre($langs->trans("NewGlobalDiscount"), '', ''); - if ($isCustomer && !$isSupplier) { - print ''; - } + if ($isCustomer && !$isSupplier) { + print ''; + } - if (!$isCustomer && $isSupplier) { - print ''; - } + if (!$isCustomer && $isSupplier) { + print ''; + } - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print '
'.$langs->trans("CustomerAbsoluteDiscountMy").''.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'.$remise_user.' '.$langs->trans("Currency".$conf->currency).' '.$langs->trans("HT").'
'; + print '
'; if ($isCustomer && $isSupplier) { print ''; print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print "
'.$langs->trans('DiscountType').' '; print '   '; print '
'.$langs->trans("AmountHT").''; - print ' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("VAT").''; - print $form->load_tva('tva_tx', GETPOSTISSET('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0, $mysoc, $object, 0, 0, '', 0, 1); - print '
'.$langs->trans("NoteReason").'
'.$langs->trans("AmountHT").''; + print ' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("VAT").''; + print $form->load_tva('tva_tx', GETPOSTISSET('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0, $mysoc, $object, 0, 0, '', 0, 1); + print '
'.$langs->trans("NoteReason").'
"; + print ""; - print dol_get_fiche_end(); + print dol_get_fiche_end(); } if ($user->rights->societe->creer) { - print '
'; - print ''; - if (!empty($backtopage)) - { - print '     '; - print ''; - } - print '
'; - } + print '
'; + print ''; + if (!empty($backtopage)) + { + print '     '; + print ''; + } + print '
'; + } - print ''; + print ''; print '
'; @@ -441,13 +441,13 @@ if ($socid > 0) print ''.$langs->trans("AmountHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountHT").''; + print ''.$langs->trans("MulticurrencyAmountHT").''; } print ''.$langs->trans("VATRate").''; print ''.$langs->trans("AmountTTC").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountTTC").''; + print ''.$langs->trans("MulticurrencyAmountTTC").''; } print ''.$langs->trans("DiscountOfferedBy").''; print ' '; @@ -459,76 +459,76 @@ if ($socid > 0) $num = $db->num_rows($resql); if ($num > 0) { - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - print ''; - print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; - if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) - { - print ''; - $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 ''; - } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) - { - print ''; - $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 ''; - } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) - { - print ''; - $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 ''; - } else { - print ''; - print $obj->description; - print ''; - } - print ''.$langs->trans("NotConsumed").''; - print ''.price($obj->amount_ht).''; - if (!empty($conf->multicurrency->enabled)) - { - print ''.price($obj->multicurrency_amount_ht).''; - } - print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; - print ''.price($obj->amount_ttc).''; - if (!empty($conf->multicurrency->enabled)) - { - print ''.price($obj->multicurrency_amount_ttc).''; - } - print ''; - print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; - print ''; - if ($user->rights->societe->creer || $user->rights->facture->creer) - { - print ''; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; - print ''; - } else print ' '; - print ''; + print ''; + print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; + if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) + { + print ''; + $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 ''; + } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) + { + print ''; + $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 ''; + } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) + { + print ''; + $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 ''; + } else { + print ''; + print $obj->description; + print ''; + } + print ''.$langs->trans("NotConsumed").''; + print ''.price($obj->amount_ht).''; + if (!empty($conf->multicurrency->enabled)) + { + print ''.price($obj->multicurrency_amount_ht).''; + } + print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; + print ''.price($obj->amount_ttc).''; + if (!empty($conf->multicurrency->enabled)) + { + print ''.price($obj->multicurrency_amount_ttc).''; + } + print ''; + print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; + print ''; + if ($user->rights->societe->creer || $user->rights->facture->creer) + { + print ''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print ''; + } else print ' '; + print ''; - if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) - { - $showconfirminfo['rowid'] = $obj->rowid; - $showconfirminfo['amount_ttc'] = $obj->amount_ttc; - } - $i++; - } + if ($_GET["action"] == 'split' && GETPOST('remid') == $obj->rowid) + { + $showconfirminfo['rowid'] = $obj->rowid; + $showconfirminfo['amount_ttc'] = $obj->amount_ttc; + } + $i++; + } } else { $colspan = 8; if (!empty($conf->multicurrency->enabled)) $colspan += 2; - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } $db->free($resql); print ""; @@ -589,13 +589,13 @@ if ($socid > 0) print ''.$langs->trans("AmountHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountHT").''; + print ''.$langs->trans("MulticurrencyAmountHT").''; } print ''.$langs->trans("VATRate").''; print ''.$langs->trans("AmountTTC").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountTTC").''; + print ''.$langs->trans("MulticurrencyAmountTTC").''; } print ''.$langs->trans("DiscountOfferedBy").''; print ' '; @@ -646,13 +646,13 @@ if ($socid > 0) print ''.price($obj->amount_ht).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ht).''; + print ''.price($obj->multicurrency_amount_ht).''; } print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; print ''.price($obj->amount_ttc).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ttc).''; + print ''.price($obj->multicurrency_amount_ttc).''; } print ''; print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; @@ -770,13 +770,13 @@ if ($socid > 0) print ''.$langs->trans("AmountHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountHT").''; + print ''.$langs->trans("MulticurrencyAmountHT").''; } print ''.$langs->trans("VATRate").''; print ''.$langs->trans("AmountTTC").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountTTC").''; + print ''.$langs->trans("MulticurrencyAmountTTC").''; } print ''.$langs->trans("Author").''; print ' '; @@ -787,12 +787,12 @@ if ($socid > 0) $num = $db->num_rows($resql); if ($num > 0) { - for ($i = 0; $i < $num; $i++) - { - $sqlobj = $db->fetch_object($resql); - $tab_sqlobj[] = $sqlobj; - $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); - } + for ($i = 0; $i < $num; $i++) + { + $sqlobj = $db->fetch_object($resql); + $tab_sqlobj[] = $sqlobj; + $tab_sqlobjOrder[] = $db->jdate($sqlobj->dc); + } } $db->free($resql); @@ -809,69 +809,69 @@ if ($socid > 0) $num = count($tab_sqlobj); if ($num > 0) { - $i = 0; - while ($i < $num) - { - $obj = array_shift($tab_sqlobj); - print ''; - print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; - if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->invoice_source_ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->invoice_source_ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) - { - print ''; - $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->invoice_source_ref; - $facturestatic->type = $obj->type; - print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); - print ''; - } else { - print ''; - print $obj->description; - print ''; - } - print ''; - if ($obj->invoiceid) - { - print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; - } - print ''; - print ''.price($obj->amount_ht).''; - if (!empty($conf->multicurrency->enabled)) - { - print ''.price($obj->multicurrency_amount_ht).''; - } - print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; - print ''.price($obj->amount_ttc).''; - if (!empty($conf->multicurrency->enabled)) - { - print ''.price($obj->multicurrency_amount_ttc).''; - } - print ''; - print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; - print ''; - print ' '; - print ''; - $i++; - } + $i = 0; + while ($i < $num) + { + $obj = array_shift($tab_sqlobj); + print ''; + print ''.dol_print_date($db->jdate($obj->dc), 'dayhour').''; + if (preg_match('/\(CREDIT_NOTE\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->invoice_source_ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } elseif (preg_match('/\(DEPOSIT\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->invoice_source_ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } elseif (preg_match('/\(EXCESS RECEIVED\)/', $obj->description)) + { + print ''; + $facturestatic->id = $obj->fk_facture_source; + $facturestatic->ref = $obj->invoice_source_ref; + $facturestatic->type = $obj->type; + print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); + print ''; + } else { + print ''; + print $obj->description; + print ''; + } + print ''; + if ($obj->invoiceid) + { + print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + } + print ''; + print ''.price($obj->amount_ht).''; + if (!empty($conf->multicurrency->enabled)) + { + print ''.price($obj->multicurrency_amount_ht).''; + } + print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; + print ''.price($obj->amount_ttc).''; + if (!empty($conf->multicurrency->enabled)) + { + print ''.price($obj->multicurrency_amount_ttc).''; + } + print ''; + print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; + print ''; + print ' '; + print ''; + $i++; + } } else { $colspan = 8; if (!empty($conf->multicurrency->enabled)) $colspan += 2; - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; @@ -940,13 +940,13 @@ if ($socid > 0) print ''.$langs->trans("AmountHT").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountHT").''; + print ''.$langs->trans("MulticurrencyAmountHT").''; } print ''.$langs->trans("VATRate").''; print ''.$langs->trans("AmountTTC").''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans("MulticurrencyAmountTTC").''; + print ''.$langs->trans("MulticurrencyAmountTTC").''; } print ''.$langs->trans("Author").''; print ' '; @@ -1022,13 +1022,13 @@ if ($socid > 0) print ''.price($obj->amount_ht).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ht).''; + print ''.price($obj->multicurrency_amount_ht).''; } print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''; print ''.price($obj->amount_ttc).''; if (!empty($conf->multicurrency->enabled)) { - print ''.price($obj->multicurrency_amount_ttc).''; + print ''.price($obj->multicurrency_amount_ttc).''; } print ''; print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 901a0f6f385..b1194edd965 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -537,14 +537,14 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'setdate_livraison' && $usercancreate) { - // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); - $object->fetch($id); - $result = $object->setDeliveryDate($user, $datedelivery); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + $object->fetch($id); + $result = $object->setDeliveryDate($user, $datedelivery); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index fdc9ddaf646..5934dc066a3 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1357,7 +1357,7 @@ class Commande extends CommonOrder $this->shipping_method_id = $object->shipping_method_id; $this->warehouse_id = $object->warehouse_id; $this->fk_delivery_address = $object->fk_delivery_address; - $this->contact_id = $object->contact_id; + $this->contact_id = $object->contact_id; $this->ref_client = $object->ref_client; if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN)) @@ -1848,7 +1848,7 @@ class Commande extends CommonOrder $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; - $this->modelpdf = $obj->model_pdf; // deprecated + $this->modelpdf = $obj->model_pdf; // deprecated $this->last_main_doc = $obj->last_main_doc; $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index c9dc5eaffa8..57f8147cd57 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -35,18 +35,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; */ class CommandeStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - public $socid; - public $userid; + public $socid; + public $userid; - public $from; - public $field; - public $where; - public $join; + public $from; + public $field; + public $where; + public $join; /** @@ -56,8 +56,8 @@ class CommandeStats extends Stats * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) - * @param int $typentid Id typent of thirdpary for filter - * @param int $categid Id category of thirdpary for filter + * @param int $typentid Id typent of thirdpary for filter + * @param int $categid Id category of thirdpary for filter */ public function __construct($db, $socid, $mode, $userid = 0, $typentid = 0, $categid = 0) { @@ -66,9 +66,9 @@ class CommandeStats extends Stats $this->db = $db; $this->socid = ($socid > 0 ? $socid : 0); - $this->userid = $userid; + $this->userid = $userid; $this->cachefilesuffix = $mode; - $this->join = ''; + $this->join = ''; if ($mode == 'customer') { @@ -88,34 +88,34 @@ class CommandeStats extends Stats //$this->where .= " c.fk_statut > 2"; // Only approved & ordered } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where .= ($this->where ? ' AND ' : ''). 'c.entity IN ('.getEntity('commande').')'; + $this->where .= ($this->where ? ' AND ' : '').'c.entity IN ('.getEntity('commande').')'; if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($this->socid) { $this->where .= " AND c.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; - if ($typentid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc'; - $this->where .= ' AND s.fk_typent = '.$typentid; - } + if ($typentid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = c.fk_soc'; + $this->where .= ' AND s.fk_typent = '.$typentid; + } - if ($categid) - { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc'; - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie'; - $this->where .= ' AND cat.rowid = '.$categid; - } + if ($categid) + { + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc'; + $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie'; + $this->where .= ' AND cat.rowid = '.$categid; + } } /** * Return orders number by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with number by month */ public function getNbByMonth($year, $format = 0) @@ -125,11 +125,11 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); return $res; @@ -148,10 +148,10 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -160,7 +160,7 @@ class CommandeStats extends Stats * Return the orders amount by month for a year * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array with amount by month */ public function getAmountByMonth($year, $format = 0) @@ -170,11 +170,11 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getAmountByMonth($year, $sql, $format); return $res; @@ -193,11 +193,11 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -214,10 +214,10 @@ class CommandeStats extends Stats $sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -226,7 +226,7 @@ class CommandeStats extends Stats * Return nb, amount of predefined product for year * * @param int $year Year to scan - * @param int $limit Limit + * @param int $limit Limit * @return array Array of values */ public function getAllByProduct($year, $limit = 10) @@ -236,14 +236,14 @@ class CommandeStats extends Stats $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= $this->join; + $sql .= $this->join; $sql .= " WHERE ".$this->where; $sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; - $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; $sql .= " GROUP BY product.ref"; - $sql .= $this->db->order('nb', 'DESC'); - //$sql.= $this->db->plimit(20); + $sql .= $this->db->order('nb', 'DESC'); + //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql, $limit); + return $this->_getAllByProduct($sql, $limit); } } diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 84c4eb5626a..a3c31d4cf7b 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -53,11 +53,11 @@ if ($action == 'addcontact' && $user->rights->commande->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } + } if ($result >= 0) { @@ -79,7 +79,7 @@ elseif ($action == 'swapstatut' && $user->rights->commande->creer) { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } @@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) if ($object->fetch($id, $ref) > 0) { - $object->fetch_thirdparty(); + $object->fetch_thirdparty(); $head = commande_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), -1, 'order'); @@ -150,40 +150,40 @@ if ($id > 0 || !empty($ref)) $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); @@ -196,8 +196,8 @@ if ($id > 0 || !empty($ref)) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; } } else { // Contact not found diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index c3afff9e00d..f95f61b6025 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -107,7 +107,7 @@ if ($id > 0 || !empty($ref)) $totalsize = 0; foreach ($filearray as $key => $file) { - $totalsize += $file['size']; + $totalsize += $file['size']; } // Order card @@ -124,36 +124,36 @@ if ($id > 0 || !empty($ref)) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= '
'; diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 96476caeeed..4a18f96ddde 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -71,15 +71,15 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - // Search customer orders - print '
'; - print ''; - print '
'; - print ''; - print ''; - print ''; - print "
'.$langs->trans("Search").'
'; - print $langs->trans("CustomerOrder").':

\n"; + // Search customer orders + print '
'; + print ''; + print '
'; + print ''; + print ''; + print ''; + print "
'.$langs->trans("Search").'
'; + print $langs->trans("CustomerOrder").':

\n"; } @@ -100,81 +100,81 @@ $sql .= " GROUP BY c.fk_statut"; $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - $total = 0; - $totalinprocess = 0; - $dataseries = array(); - $colorseries = array(); - $vals = array(); - // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) - while ($i < $num) - { - $row = $db->fetch_row($resql); - if ($row) - { - //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) - { - if (!isset($vals[$row[1]])) $vals[$row[1]] = 0; - $vals[$row[1]] += $row[0]; - $totalinprocess += $row[0]; - } - $total += $row[0]; - } - $i++; - } - $db->free($resql); + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $colorseries = array(); + $vals = array(); + // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) + while ($i < $num) + { + $row = $db->fetch_row($resql); + if ($row) + { + //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) + { + if (!isset($vals[$row[1]])) $vals[$row[1]] = 0; + $vals[$row[1]] += $row[0]; + $totalinprocess += $row[0]; + } + $total += $row[0]; + } + $i++; + } + $db->free($resql); - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - print '
'; - print ''; - print ''."\n"; - $listofstatus = array(0, 1, 2, 3, -1); - foreach ($listofstatus as $status) - { - $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Commande::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; - if ($status == Commande::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; - if ($status == Commande::STATUS_SHIPMENTONPROCESS) $colorseries[$status] = $badgeStatus4; - if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $colorseries[$status] = $badgeStatus6; - if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) $colorseries[$status] = $badgeStatus6; - if ($status == Commande::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; + print '
'; + print '
'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
'; + print ''."\n"; + $listofstatus = array(0, 1, 2, 3, -1); + foreach ($listofstatus as $status) + { + $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if ($status == Commande::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; + if ($status == Commande::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; + if ($status == Commande::STATUS_SHIPMENTONPROCESS) $colorseries[$status] = $badgeStatus4; + if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $colorseries[$status] = $badgeStatus6; + if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) $colorseries[$status] = $badgeStatus6; + if ($status == Commande::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; - if (empty($conf->use_javascript_ajax)) - { - print ''; - print ''; - print ''; - print "\n"; - } - } - if ($conf->use_javascript_ajax) - { - print ''; + print ''; + print ''; + print "\n"; + } + } + if ($conf->use_javascript_ajax) + { + print ''; - } + print ''; + } - //if ($totalinprocess != $total) - print ''; - print "
'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
'.$commandestatic->LibStatut($status, 0, 0, 1).''.(isset($vals[$status]) ? $vals[$status] : 0).' '; - print $commandestatic->LibStatut($status, 0, 3, 1); - print '
'; + if (empty($conf->use_javascript_ajax)) + { + print '
'.$commandestatic->LibStatut($status, 0, 0, 1).''.(isset($vals[$status]) ? $vals[$status] : 0).' '; + print $commandestatic->LibStatut($status, 0, 3, 1); + print '
'; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); - print '
'.$langs->trans("Total").''.$total.'

"; + //if ($totalinprocess != $total) + print ''.$langs->trans("Total").''.$total.''; + print "

"; } else { - dol_print_error($db); + dol_print_error($db); } @@ -184,9 +184,9 @@ if ($resql) 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 .= ", 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"; @@ -199,7 +199,7 @@ if (!empty($conf->commande->enabled)) $resql = $db->query($sql); if ($resql) { - print '
'; + print '
'; print ''; print ''; print ''; @@ -212,8 +212,8 @@ 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; @@ -224,10 +224,10 @@ if (!empty($conf->commande->enabled)) print ''; print '"; - print '"; + print ''; + print ''; $i++; } } else { @@ -266,7 +266,7 @@ $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) { - print '
'; + print '
'; print '
'.$langs->trans("DraftOrders").'
'; print $commandestatic->getNomUrl(1); - print "'; + print "'; print $companystatic->getNomUrl(1, 'company', 16); - print '
'; print ''; print ''; @@ -310,8 +310,8 @@ if ($resql) print ''; print ''; + print $companystatic->getNomUrl(1, 'company', 16); + print ''; print ''; print ''; print ''; @@ -329,9 +329,9 @@ $max = 10; if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid"; - $sql .= ", s.client"; - $sql .= ", s.code_client"; - $sql .= ", s.canvas"; + $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"; @@ -347,7 +347,7 @@ if (!empty($conf->commande->enabled)) { $num = $db->num_rows($resql); - print '
'; + print '
'; print '
'.$langs->trans("LastModifiedOrders", $max).'
'; - print $companystatic->getNomUrl(1, 'company', 16); - print ''.dol_print_date($db->jdate($obj->datem), 'day').''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
'; print ''; print ''; @@ -389,10 +389,10 @@ if (!empty($conf->commande->enabled)) print ''; print ''; + print $companystatic->getNomUrl(1, 'company', 24); + print ''; - print ''."\n"; + print ''."\n"; print ''; @@ -414,9 +414,9 @@ if (!empty($conf->commande->enabled)) if (!empty($conf->commande->enabled)) { $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid"; - $sql .= ", s.client"; - $sql .= ", s.code_client"; - $sql .= ", s.canvas"; + $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"; @@ -432,7 +432,7 @@ if (!empty($conf->commande->enabled)) { $num = $db->num_rows($resql); - print '
'; + print '
'; print '
'.$langs->trans("OrdersToProcess").' '.$num.'
'; - print $companystatic->getNomUrl(1, 'company', 24); - print ''.dol_print_date($db->jdate($obj->date), 'day').''.dol_print_date($db->jdate($obj->date), 'day').''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
'; print ''; print ''; diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index dd31e547569..117afab2398 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -48,8 +48,8 @@ $result = restrictedArea($user, 'commande', $comid, ''); $object = new Commande($db); if (!$object->fetch($id, $ref) > 0) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } @@ -80,36 +80,36 @@ $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->ge // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= ''; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index cb9e06a5549..e9c379c9327 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -140,9 +140,9 @@ $checkedtypetiers = 0; $arrayfields = array( 'c.ref'=>array('label'=>"Ref", 'checked'=>1), 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>1), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), @@ -161,7 +161,7 @@ $arrayfields = array( 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))), 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), @@ -488,7 +488,7 @@ if ($resql) 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'cancelorders'=>$langs->trans("Cancel"), - 'presend'=>$langs->trans("SendByMail"), + 'presend'=>$langs->trans("SendByMail"), ); if ($user->rights->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->commande->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); @@ -670,7 +670,7 @@ if ($resql) // Project title if (!empty($arrayfields['p.title']['checked'])) { - print ''; + print ''; } // Thirpdarty if (!empty($arrayfields['s.nom']['checked'])) @@ -923,13 +923,13 @@ if ($resql) $text_warning = ''; $nbprod = 0; - $companystatic->id = $obj->socid; + $companystatic->id = $obj->socid; $companystatic->code_client = $obj->code_client; $companystatic->name = $obj->name; $companystatic->client = $obj->client; $companystatic->email = $obj->email; if (!isset($getNomUrl_cache[$obj->socid])) { - $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); + $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); } $generic_commande->id = $obj->rowid; @@ -1087,7 +1087,7 @@ if ($resql) print ''; if (!$i) $totalarray['nbfield']++; @@ -1096,13 +1096,13 @@ if ($resql) // Project label if (!empty($arrayfields['p.title']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; } // Third party diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index c996aea7601..0cf0da709da 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -93,36 +93,36 @@ if ($id > 0 || !empty($ref)) // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } } $morehtmlref .= ''; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 1da32f13e80..54846a32852 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -51,8 +51,8 @@ $socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $nowyear = strftime("%Y", dol_now()); @@ -81,8 +81,8 @@ $dir = $conf->commande->dir_temp; if ($mode == 'supplier') { $picto = 'supplier_order'; - $title = $langs->trans("OrdersStatisticsSuppliers"); - $dir = $conf->fournisseur->commande->dir_temp; + $title = $langs->trans("OrdersStatisticsSuppliers"); + $dir = $conf->fournisseur->commande->dir_temp; } llxHeader('', $title); @@ -111,38 +111,38 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; + $filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenamenb = $dir.'/ordersnbinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png'; - if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png'; + $filenamenb = $dir.'/ordersnbinyear-'.$year.'.png'; + if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png'; + if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { - $px1->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfOrder")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfOrdersByMonth")); + $px1->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfOrder")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NumberOfOrdersByMonth")); - $px1->draw($filenamenb, $fileurlnb); + $px1->draw($filenamenb, $fileurlnb); } // Build graphic amount of object @@ -152,38 +152,38 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; + $filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenameamount = $dir.'/ordersamountinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png'; + $filenameamount = $dir.'/ordersamountinyear-'.$year.'.png'; + if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png'; + if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$year.'.png'; } $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { - $px2->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfOrders")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); + $px2->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfOrders")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode = 'depth'; + $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); - $px2->draw($filenameamount, $fileurlamount); + $px2->draw($filenameamount, $fileurlamount); } @@ -191,38 +191,38 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; } else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); + $px3->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); - $px3->draw($filename_avg, $fileurl_avg); + $px3->draw($filename_avg, $fileurl_avg); } @@ -277,13 +277,13 @@ print ''; // Category if ($mode == 'customer') { - $cat_type = Categorie::TYPE_CUSTOMER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); + $cat_type = Categorie::TYPE_CUSTOMER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); } if ($mode == 'supplier') { - $cat_type = Categorie::TYPE_SUPPLIER; - $cat_label = $langs->trans("Supplier").' '.lcfirst($langs->trans("Customer")); + $cat_type = Categorie::TYPE_SUPPLIER; + $cat_label = $langs->trans("Supplier").' '.lcfirst($langs->trans("Customer")); } print ''; // Year @@ -376,11 +376,11 @@ print '
'; // Show graphs print '
'.$langs->trans("OnProcessOrders").' '.$num.'
'; if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); + print $projectstatic->getNomUrl(1); } print ''; - if ($obj->project_id > 0) - { - print $projectstatic->title; - } - print ''; + if ($obj->project_id > 0) + { + print $projectstatic->title; + } + print '
'.$cat_label.''; print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); @@ -295,18 +295,18 @@ print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0 print '
'.$langs->trans("Status").''; if ($mode == 'customer') { - $liststatus = array( - Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"), - Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSent"), - Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), - Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") - ); - print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4); + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSent"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") + ); + print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4); } if ($mode == 'supplier') { - $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ?-1 : $object_status), 0, 'object_status'); + $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ?-1 : $object_status), 0, 'object_status'); } print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); - print "
\n"; - print $px2->show(); - print "
\n"; - print $px3->show(); + print $px1->show(); + print "
\n"; + print $px2->show(); + print "
\n"; + print $px3->show(); } print '
'; diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index a593e10adf4..a9c01386bf7 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -40,44 +40,44 @@ $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; - echo ''; - echo ''.$langs->trans("CustomerOrder"); - if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print ' '; - echo ''.$objectlink->getNomUrl(1).''; - echo ''.$objectlink->ref_client.''; - echo ''.dol_print_date($objectlink->date, 'day').''; - echo ''; - if ($user->rights->commande->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } - echo ''; - echo ''.$objectlink->getLibStatut(3).''; - echo ''; - // For now, shipments must stay linked to order, so link is not deletable - if ($object->element != 'shipping') { - echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; - } - echo ''; - echo "\n"; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + echo ''; + echo ''.$langs->trans("CustomerOrder"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { + print ' '; + echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->ref_client.''; + echo ''.dol_print_date($objectlink->date, 'day').''; + echo ''; + if ($user->rights->commande->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } + echo ''; + echo ''.$objectlink->getLibStatut(3).''; + echo ''; + // For now, shipments must stay linked to order, so link is not deletable + if ($object->element != 'shipping') { + echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + } + echo ''; + echo "\n"; } if (count($linkedObjectBlock) > 1) { - echo ''; - echo ''.$langs->trans("Total").''; - echo ''; - echo ''; - echo ''; - echo ''.price($total).''; - echo ''; - echo ''; - echo "\n"; + echo ''; + echo ''.$langs->trans("Total").''; + echo ''; + echo ''; + echo ''; + echo ''.price($total).''; + echo ''; + echo ''; + echo "\n"; } echo "\n"; diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index ac31d091833..3b135637a25 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -19,10 +19,10 @@ */ /** - * \file htdocs/compta/accounting-files.php - * \ingroup compta - * \brief Page to show portoflio and files of a thirdparty and download it - */ + * \file htdocs/compta/accounting-files.php + * \ingroup compta + * \brief Page to show portoflio and files of a thirdparty and download it + */ if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); @@ -79,8 +79,8 @@ if (!$sortorder) $sortorder = "DESC"; $arrayfields = array( - 'type'=>array('label'=>"Type", 'checked'=>1), - 'date'=>array('label'=>"Date", 'checked'=>1), + 'type'=>array('label'=>"Type", 'checked'=>1), + 'date'=>array('label'=>"Date", 'checked'=>1), 'date_due'=>array('label'=>"DateDue", 'checked'=>1), 'ref'=>array('label'=>"Ref", 'checked'=>1), 'documents'=>array('label'=>"Documents", 'checked'=>1), @@ -93,10 +93,10 @@ $arrayfields = array( // Security check if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) { - accessforbidden(); + accessforbidden(); } if ($user->socid > 0) { - accessforbidden(); + accessforbidden(); } // Define $arrayofentities if multientity is set. @@ -150,242 +150,242 @@ if (($action == 'searchfiles' || $action == 'dl')) { if (GETPOST('selectinvoices')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql .= " WHERE datef between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; } - // Vendor invoices + // Vendor invoices if (GETPOST('selectsupplierinvoices')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql .= " WHERE datef between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; } - // Expense reports + // Expense reports if (GETPOST('selectexpensereports')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql .= " WHERE date_fin between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE date_fin between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; } - // Donations + // Donations if (GETPOST('selectdonations')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; - $sql .= " WHERE datedon between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; + $sql .= " WHERE datedon between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; } - // Payments of salaries + // Payments of salaries if (GETPOST('selectpaymentsofsalaries')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; } - // Social contributions + // Social contributions if (GETPOST('selectsocialcontributions')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; - $sql .= " WHERE t.date_ech between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; + $sql .= " WHERE t.date_ech between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; } - // Various payments + // Various payments if (GETPOST('selectvariouspayment')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; } - // Loan payments + // Loan payments if (GETPOST('selectloanspayment')) { if (!empty($sql)) $sql .= " UNION ALL"; $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan"; - $sql .= " WHERE datep between ".$wheretail; - $sql .= " AND l.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND l.entity IN (".($entity == 1 ? '0,1' : $entity).')'; } if ($sql) { - $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); //print $sql; - $resd = $db->query($sql); - $files = array(); - $link = ''; + $resd = $db->query($sql); + $files = array(); + $link = ''; - if ($resd) - { - $numd = $db->num_rows($resd); + if ($resd) + { + $numd = $db->num_rows($resd); - $tmpinvoice = new Facture($db); - $tmpinvoicesupplier = new FactureFournisseur($db); - $tmpdonation = new Don($db); + $tmpinvoice = new Facture($db); + $tmpinvoicesupplier = new FactureFournisseur($db); + $tmpdonation = new Don($db); - $upload_dir = ''; - $i = 0; - while ($i < $numd) - { - $objd = $db->fetch_object($resd); + $upload_dir = ''; + $i = 0; + while ($i < $numd) + { + $objd = $db->fetch_object($resd); - switch ($objd->item) - { - case "Invoice": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->facture->dir_output.'/'.$subdir; - $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "facture"; - break; - case "SupplierInvoice": - $tmpinvoicesupplier->fetch($objd->id); - $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "facture_fournisseur"; - break; - case "ExpenseReport": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; - $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "expensereport"; - break; - case "SalaryPayment": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->salaries->dir_output.'/'.$subdir; - $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "salaries"; - break; - case "Donation": - $tmpdonation->fetch($objp->id); - $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->don->dir_output.'/'.$subdir; - $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "don"; - break; - case "SocialContributions": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->tax->dir_output.'/'.$subdir; - $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "tax"; - break; - case "VariousPayment": - $subdir = ''; - $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->bank->dir_output.'/'.$subdir; - $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F'; - $modulepart = "banque"; - break; - case "LoanPayment": - // Loan payment has no linked file - $subdir = ''; - $upload_dir = $conf->loan->dir_output.'/'.$subdir; - $link = ""; - $modulepart = ""; - break; - default: - $subdir = ''; - $upload_dir = ''; - $link = ''; - break; - } + switch ($objd->item) + { + case "Invoice": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->facture->dir_output.'/'.$subdir; + $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "facture"; + break; + case "SupplierInvoice": + $tmpinvoicesupplier->fetch($objd->id); + $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; + $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "facture_fournisseur"; + break; + case "ExpenseReport": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; + $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "expensereport"; + break; + case "SalaryPayment": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->salaries->dir_output.'/'.$subdir; + $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "salaries"; + break; + case "Donation": + $tmpdonation->fetch($objp->id); + $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->don->dir_output.'/'.$subdir; + $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "don"; + break; + case "SocialContributions": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->tax->dir_output.'/'.$subdir; + $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "tax"; + break; + case "VariousPayment": + $subdir = ''; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->bank->dir_output.'/'.$subdir; + $link = "document.php?modulepart=banque&file=".str_replace('/', '%2F', $subdir).'%2F'; + $modulepart = "banque"; + break; + case "LoanPayment": + // Loan payment has no linked file + $subdir = ''; + $upload_dir = $conf->loan->dir_output.'/'.$subdir; + $link = ""; + $modulepart = ""; + break; + default: + $subdir = ''; + $upload_dir = ''; + $link = ''; + break; + } - if (!empty($upload_dir)) - { - $result = true; + if (!empty($upload_dir)) + { + $result = true; - $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); - //var_dump($upload_dir); - //var_dump($files); - if (count($files) < 1) - { - $nofile = array(); - $nofile['id'] = $objd->id; - $nofile['entity'] = $objd->entity; - $nofile['date'] = $db->idate($objd->date); - $nofile['date_due'] = $db->idate($objd->date_due); - $nofile['paid'] = $objd->paid; - $nofile['amount_ht'] = $objd->total_ht; - $nofile['amount_ttc'] = $objd->total_ttc; - $nofile['amount_vat'] = $objd->total_vat; - $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); - $nofile['fk'] = $objd->fk_soc; - $nofile['item'] = $objd->item; - $nofile['thirdparty_name'] = $objd->thirdparty_name; - $nofile['thirdparty_code'] = $objd->thirdparty_code; - $nofile['country_code'] = $objd->country_code; - $nofile['vatnum'] = $objd->vatnum; - $nofile['sens'] = $objd->sens; + $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); + //var_dump($upload_dir); + //var_dump($files); + if (count($files) < 1) + { + $nofile = array(); + $nofile['id'] = $objd->id; + $nofile['entity'] = $objd->entity; + $nofile['date'] = $db->idate($objd->date); + $nofile['date_due'] = $db->idate($objd->date_due); + $nofile['paid'] = $objd->paid; + $nofile['amount_ht'] = $objd->total_ht; + $nofile['amount_ttc'] = $objd->total_ttc; + $nofile['amount_vat'] = $objd->total_vat; + $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $nofile['fk'] = $objd->fk_soc; + $nofile['item'] = $objd->item; + $nofile['thirdparty_name'] = $objd->thirdparty_name; + $nofile['thirdparty_code'] = $objd->thirdparty_code; + $nofile['country_code'] = $objd->country_code; + $nofile['vatnum'] = $objd->vatnum; + $nofile['sens'] = $objd->sens; - $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; - } else { - foreach ($files as $key => $file) - { - $file['id'] = $objd->id; - $file['entity'] = $objd->entity; - $file['date'] = $db->idate($objd->date); - $file['date_due'] = $db->idate($objd->date_due); - $file['paid'] = $objd->paid; - $file['amount_ht'] = $objd->total_ht; - $file['amount_ttc'] = $objd->total_ttc; - $file['amount_vat'] = $objd->total_vat; - $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); - $file['fk'] = $objd->fk_soc; - $file['item'] = $objd->item; - $file['thirdparty_name'] = $objd->thirdparty_name; - $file['thirdparty_code'] = $objd->thirdparty_code; - $file['country_code'] = $objd->country_code; - $file['vatnum'] = $objd->vatnum; - $file['sens'] = $objd->sens; + $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; + } else { + foreach ($files as $key => $file) + { + $file['id'] = $objd->id; + $file['entity'] = $objd->entity; + $file['date'] = $db->idate($objd->date); + $file['date_due'] = $db->idate($objd->date_due); + $file['paid'] = $objd->paid; + $file['amount_ht'] = $objd->total_ht; + $file['amount_ttc'] = $objd->total_ttc; + $file['amount_vat'] = $objd->total_vat; + $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $file['fk'] = $objd->fk_soc; + $file['item'] = $objd->item; + $file['thirdparty_name'] = $objd->thirdparty_name; + $file['thirdparty_code'] = $objd->thirdparty_code; + $file['country_code'] = $objd->country_code; + $file['vatnum'] = $objd->vatnum; + $file['sens'] = $objd->sens; - // Save record into array (only the first time it is found) - if (empty($filesarray[$file['item'].'_'.$file['id']])) { - $filesarray[$file['item'].'_'.$file['id']] = $file; - } + // Save record into array (only the first time it is found) + if (empty($filesarray[$file['item'].'_'.$file['id']])) { + $filesarray[$file['item'].'_'.$file['id']] = $file; + } - // Add or concat file - if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) { - $filesarray[$file['item'].'_'.$file['id']]['files'] = array(); - } - $filesarray[$file['item'].'_'.$file['id']]['files'][] = array( - 'link' => $link.urlencode($file['name']), - 'name'=>$file['name'], - 'ref'=>$file['ref'], - 'fullname' => $file['fullname'], - 'relpath' => '/'.$file['name'], - 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], - 'modulepart' => $modulepart, - 'subdir' => $subdir, - ); - //var_dump($file['item'].'_'.$file['id']); - //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); - } - } - } + // Add or concat file + if (empty($filesarray[$file['item'].'_'.$file['id']]['files'])) { + $filesarray[$file['item'].'_'.$file['id']]['files'] = array(); + } + $filesarray[$file['item'].'_'.$file['id']]['files'][] = array( + 'link' => $link.urlencode($file['name']), + 'name'=>$file['name'], + 'ref'=>$file['ref'], + 'fullname' => $file['fullname'], + 'relpath' => '/'.$file['name'], + 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], + 'modulepart' => $modulepart, + 'subdir' => $subdir, + ); + //var_dump($file['item'].'_'.$file['id']); + //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); + } + } + } - $i++; - } - } else { - dol_print_error($db); - } + $i++; + } + } else { + dol_print_error($db); + } - $db->free($resd); + $db->free($resd); } else { setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'errors'); $error++; @@ -414,81 +414,81 @@ if ($result && $action == "dl" && !$error) exit; } - dol_mkdir($dirfortmpfile); + dol_mkdir($dirfortmpfile); - $log = $langs->transnoentitiesnoconv("Type"); - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - $log .= ','.$langs->transnoentitiesnoconv("Entity"); - } - $log .= ','.$langs->transnoentitiesnoconv("Date"); - $log .= ','.$langs->transnoentitiesnoconv("DateDue"); - $log .= ','.$langs->transnoentitiesnoconv("Ref"); - $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); - $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); - $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); - $log .= ','.$langs->transnoentitiesnoconv("Paid"); - $log .= ','.$langs->transnoentitiesnoconv("Document"); - $log .= ','.$langs->transnoentitiesnoconv("ItemID"); - $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); - $log .= ','.$langs->transnoentitiesnoconv("Code"); - $log .= ','.$langs->transnoentitiesnoconv("Country"); - $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); - $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; - $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; + $log = $langs->transnoentitiesnoconv("Type"); + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ','.$langs->transnoentitiesnoconv("Entity"); + } + $log .= ','.$langs->transnoentitiesnoconv("Date"); + $log .= ','.$langs->transnoentitiesnoconv("DateDue"); + $log .= ','.$langs->transnoentitiesnoconv("Ref"); + $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); + $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); + $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); + $log .= ','.$langs->transnoentitiesnoconv("Paid"); + $log .= ','.$langs->transnoentitiesnoconv("Document"); + $log .= ','.$langs->transnoentitiesnoconv("ItemID"); + $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); + $log .= ','.$langs->transnoentitiesnoconv("Code"); + $log .= ','.$langs->transnoentitiesnoconv("Country"); + $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); + $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; + $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; - dol_delete_file($zipname); + dol_delete_file($zipname); - $zip = new ZipArchive; - $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); - if ($res) - { - foreach ($filesarray as $key => $file) - { - if (!empty($file['files'])) { - foreach ($file['files'] as $filecursor) { - if (file_exists($filecursor["fullname"])) { - $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); - } - } - } + $zip = new ZipArchive; + $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); + if ($res) + { + foreach ($filesarray as $key => $file) + { + if (!empty($file['files'])) { + foreach ($file['files'] as $filecursor) { + if (file_exists($filecursor["fullname"])) { + $zip->addFile($filecursor["fullname"], $filecursor["relpathnamelang"]); + } + } + } - $log .= '"'.$langs->trans($file['item']).'"'; - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"'; - } - $log .= ','.dol_print_date($file['date'], 'dayrfc'); - $log .= ','.dol_print_date($file['date_due'], 'dayrfc'); - $log .= ',"'.$file['ref'].'"'; - $log .= ','.$file['amount_ht']; - $log .= ','.$file['amount_ttc']; - $log .= ','.$file['amount_vat']; - $log .= ','.$file['paid']; - $log .= ',"'.$file["name"].'"'; - $log .= ','.$file['fk']; - $log .= ',"'.$file['thirdparty_name'].'"'; - $log .= ',"'.$file['thirdparty_code'].'"'; - $log .= ',"'.$file['country_code'].'"'; - $log .= ',"'.$file['vatnum'].'"'; - $log .= ',"'.$file['sens'].'"'; - $log .= "\n"; - } - $zip->addFromString('transactions.csv', $log); - $zip->close(); + $log .= '"'.$langs->trans($file['item']).'"'; + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"'; + } + $log .= ','.dol_print_date($file['date'], 'dayrfc'); + $log .= ','.dol_print_date($file['date_due'], 'dayrfc'); + $log .= ',"'.$file['ref'].'"'; + $log .= ','.$file['amount_ht']; + $log .= ','.$file['amount_ttc']; + $log .= ','.$file['amount_vat']; + $log .= ','.$file['paid']; + $log .= ',"'.$file["name"].'"'; + $log .= ','.$file['fk']; + $log .= ',"'.$file['thirdparty_name'].'"'; + $log .= ',"'.$file['thirdparty_code'].'"'; + $log .= ',"'.$file['country_code'].'"'; + $log .= ',"'.$file['vatnum'].'"'; + $log .= ',"'.$file['sens'].'"'; + $log .= "\n"; + } + $zip->addFromString('transactions.csv', $log); + $zip->close(); - ///Then download the zipped file. - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename='.basename($zipname)); - header('Content-Length: '.filesize($zipname)); - readfile($zipname); + ///Then download the zipped file. + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename='.basename($zipname)); + header('Content-Length: '.filesize($zipname)); + readfile($zipname); - dol_delete_file($zipname); + dol_delete_file($zipname); - exit(); - } else { - setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); - } + exit(); + } else { + setEventMessages($langs->trans("FailedToOpenFile", $zipname), null, 'errors'); + } } @@ -571,222 +571,222 @@ print dol_get_fiche_end(); if (!empty($date_start) && !empty($date_stop)) { - $param = 'action=searchfiles'; - $param .= '&date_startday='.GETPOST('date_startday', 'int'); - $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); - $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); - $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); - $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); - $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); - foreach ($listofchoices as $choice => $val) { - $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); - } - print '
'."\n"; - print ''; + $param = 'action=searchfiles'; + $param .= '&date_startday='.GETPOST('date_startday', 'int'); + $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); + $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); + $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); + $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); + $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); + foreach ($listofchoices as $choice => $val) { + $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); + } + print ''."\n"; + print ''; - echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); + echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); - print ''; - print ''; - foreach ($listofchoices as $choice => $val) { - print ''; - } + print ''; + print ''; + foreach ($listofchoices as $choice => $val) { + print ''; + } - print ''; - print '
'."\n"; + print ''; + print ''."\n"; - print '
'; + print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; - print ''; - print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap '); - print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall '); - print ''; - print ''; - print ''; - print ''; - print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'.$langs->trans("Document").''.$langs->trans("Paid").''.$langs->trans("TotalHT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("TotalTTC").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("TotalVAT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').'
'; + print ''; + print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap '); + print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall '); + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; - print ''; - if ($conf->multicurrency->enabled) print ''; - print ''; - if ($result) - { - $TData = dol_sort_array($filesarray, $sortfield, $sortorder); + print ''; + if ($conf->multicurrency->enabled) print ''; + print ''; + if ($result) + { + $TData = dol_sort_array($filesarray, $sortfield, $sortorder); - if (empty($TData)) - { - print ''; - if (! empty($conf->multicurrency->enabled)) { - print ''; - } - print ''; - } else { - // Sort array by date ASC to calculate balance + if (empty($TData)) + { + print ''; + if (! empty($conf->multicurrency->enabled)) { + print ''; + } + print ''; + } else { + // Sort array by date ASC to calculate balance - $totalET_debit = 0; - $totalIT_debit = 0; - $totalVAT_debit = 0; - $totalET_credit = 0; - $totalIT_credit = 0; - $totalVAT_credit = 0; + $totalET_debit = 0; + $totalIT_debit = 0; + $totalVAT_debit = 0; + $totalET_credit = 0; + $totalIT_credit = 0; + $totalVAT_credit = 0; - // Display array - foreach ($TData as $data) - { - $html_class = ''; - //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; - //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; - print ''; + // Display array + foreach ($TData as $data) + { + $html_class = ''; + //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; + print ''; - // Type - print ''; + // Type + print ''; - // Date - print '\n"; + // Date + print '\n"; - // Date due - print '\n"; + // Date due + print '\n"; - // Ref - print ''; + print ''; - // File link - print '\n"; + // File link + print '\n"; - // Paid - print ''; + // Paid + print ''; - // Total ET - print '\n"; - // Total IT - print '\n"; - // Total VAT - print '\n"; + // Total ET + print '\n"; + // Total IT + print '\n"; + // Total VAT + print '\n"; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - if ($data['sens']) { - $totalET_credit += $data['amount_ht']; - $totalIT_credit += $data['amount_ttc']; - $totalVAT_credit += $data['amount_vat']; - } else { - $totalET_debit -= $data['amount_ht']; - $totalIT_debit -= $data['amount_ttc']; - $totalVAT_debit -= $data['amount_vat']; - } + if ($data['sens']) { + $totalET_credit += $data['amount_ht']; + $totalIT_credit += $data['amount_ttc']; + $totalVAT_credit += $data['amount_vat']; + } else { + $totalET_debit -= $data['amount_ht']; + $totalIT_debit -= $data['amount_ttc']; + $totalVAT_debit -= $data['amount_vat']; + } - if (! empty($conf->multicurrency->enabled)) { - print '\n"; - } + if (! empty($conf->multicurrency->enabled)) { + print '\n"; + } - print "\n"; - } + print "\n"; + } - // Total credits - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - // Total debits - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - // Balance - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - } - } - print "
'.$langs->trans("Document").''.$langs->trans("Paid").''.$langs->trans("TotalHT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("TotalTTC").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("TotalVAT").($conf->multicurrency->enabled ? ' ('.$conf->currency.')' : '').''.$langs->trans("ThirdParty").''.$langs->trans("Code").''.$langs->trans("Country").''.$langs->trans("VATIntra").''.$langs->trans("Currency").'
'.$langs->trans("VATIntra").''.$langs->trans("Currency").'
'.$langs->trans("NoItem").'
'.$langs->trans("NoItem").'
'.$langs->trans($data['item']).''.$langs->trans($data['item']).''; - print dol_print_date($data['date'], 'day'); - print "'; + print dol_print_date($data['date'], 'day'); + print "'; - print dol_print_date($data['date_due'], 'day'); - print "'; + print dol_print_date($data['date_due'], 'day'); + print "'; + // Ref + print ''; if ($data['item'] == 'Invoice') { $invoice->id = $data['id']; - $invoice->ref = $data['ref']; - $invoice->total_ht = $data['amount_ht']; - $invoice->total_ttc = $data['amount_ttc']; - $invoice->total_tva = $data['amount_vat']; - $invoice->multicurrency_code = $data['currency']; - print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + $invoice->ref = $data['ref']; + $invoice->total_ht = $data['amount_ht']; + $invoice->total_ttc = $data['amount_ttc']; + $invoice->total_tva = $data['amount_vat']; + $invoice->multicurrency_code = $data['currency']; + print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); } elseif ($data['item'] == 'SupplierInvoice') { - $supplier_invoice->id = $data['id']; - $supplier_invoice->ref = $data['ref']; - $supplier_invoice->total_ht = $data['amount_ht']; - $supplier_invoice->total_ttc = $data['amount_ttc']; - $supplier_invoice->total_tva = $data['amount_vat']; - $supplier_invoice->multicurrency_code = $data['currency']; - print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + $supplier_invoice->id = $data['id']; + $supplier_invoice->ref = $data['ref']; + $supplier_invoice->total_ht = $data['amount_ht']; + $supplier_invoice->total_ttc = $data['amount_ttc']; + $supplier_invoice->total_tva = $data['amount_vat']; + $supplier_invoice->multicurrency_code = $data['currency']; + print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); } elseif ($data['item'] == 'ExpenseReport') { - $expensereport->id = $data['id']; - $expensereport->ref = $data['ref']; - print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); + $expensereport->id = $data['id']; + $expensereport->ref = $data['ref']; + print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); } elseif ($data['item'] == 'SalaryPayment') { - $salary_payment->id = $data['id']; - $salary_payment->ref = $data['ref']; - print $salary_payment->getNomUrl(1, '', 0, '', 0); + $salary_payment->id = $data['id']; + $salary_payment->ref = $data['ref']; + print $salary_payment->getNomUrl(1, '', 0, '', 0); } elseif ($data['item'] == 'Donation') { - $don->id = $data['id']; - $don->ref = $data['ref']; - print $don->getNomUrl(1, 0, '', 0); + $don->id = $data['id']; + $don->ref = $data['ref']; + print $don->getNomUrl(1, 0, '', 0); } elseif ($data['item'] == 'SocialContributions') { - $charge_sociales->id = $data['id']; - $charge_sociales->ref = $data['ref']; - print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); + $charge_sociales->id = $data['id']; + $charge_sociales->ref = $data['ref']; + print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); } elseif ($data['item'] == 'VariousPayment') { - $various_payment->id = $data['id']; - $various_payment->ref = $data['ref']; - print $various_payment->getNomUrl(1, '', 0, 0); + $various_payment->id = $data['id']; + $various_payment->ref = $data['ref']; + print $various_payment->getNomUrl(1, '', 0, 0); } elseif ($data['item'] == 'LoanPayment') { - $payment_loan->id = $data['id']; - $payment_loan->ref = $data['ref']; - print $payment_loan->getNomUrl(1, 0, 0, '', 0); + $payment_loan->id = $data['id']; + $payment_loan->ref = $data['ref']; + print $payment_loan->getNomUrl(1, 0, 0, '', 0); } else { - print $data['ref']; + print $data['ref']; } - print ''; - if (!empty($data['files'])) - { - foreach ($data['files'] as $id=>$filecursor) { - print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; - } - } - print "
'; + if (!empty($data['files'])) + { + foreach ($data['files'] as $id=>$filecursor) { + print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; + } + } + print "
'.$data['paid'].''.$data['paid'].''.price($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'])."'.price($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'])."'.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."'.price($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'])."'.price($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'])."'.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."'.$data['thirdparty_name']."'.$data['thirdparty_name']."'.$data['thirdparty_code']."'.$data['thirdparty_code']."'.$data['country_code']."'.$data['country_code']."'.$data['vatnum']."'.$data['vatnum']."'.$data['currency']."'.$data['currency']."
'.$langs->trans('Total').' '.$langs->trans('Income').''.price(price2num($totalET_credit, 'MT')).''.price(price2num($totalIT_credit, 'MT')).''.price(price2num($totalVAT_credit, 'MT')).'
'.$langs->trans('Total').' '.$langs->trans('Outcome').''.price(price2num($totalET_debit, 'MT')).''.price(price2num($totalIT_debit, 'MT')).''.price(price2num($totalVAT_debit, 'MT')).'
'.$langs->trans('Total').''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).'
"; - print '
'; + // Total credits + print ''; + print ''.$langs->trans('Total').' '.$langs->trans('Income').''; + print ''.price(price2num($totalET_credit, 'MT')).''; + print ''.price(price2num($totalIT_credit, 'MT')).''; + print ''.price(price2num($totalVAT_credit, 'MT')).''; + print ''; + if (! empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + // Total debits + print ''; + print ''.$langs->trans('Total').' '.$langs->trans('Outcome').''; + print ''.price(price2num($totalET_debit, 'MT')).''; + print ''.price(price2num($totalIT_debit, 'MT')).''; + print ''.price(price2num($totalVAT_debit, 'MT')).''; + print ''; + if (! empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + // Balance + print ''; + print ''.$langs->trans('Total').''; + print ''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''; + print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''; + print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).''; + print ''; + if (! empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + } + } + print ""; + print '
'; } diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index f190ddb1471..a0650e9ffa4 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -148,20 +148,20 @@ $linkback = ', 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error */ - public function get_url($fk_bank = '', $url_id = '', $type = '') + public function get_url($fk_bank = '', $url_id = '', $type = '') { - // phpcs:enable + // phpcs:enable $lines = array(); // Check parameters @@ -481,7 +481,7 @@ class Account extends CommonObject * @param int $datev Date value * @return int Rowid of added entry, <0 if KO */ - public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null) + public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null) { // Deprecation warning if (is_numeric($oper)) { @@ -589,7 +589,7 @@ class Account extends CommonObject * @param int $notrigger 1=Disable triggers * @return int < 0 if KO, > 0 if OK */ - public function create(User $user, $notrigger = 0) + public function create(User $user, $notrigger = 0) { global $langs, $conf, $hookmanager; @@ -747,7 +747,7 @@ class Account extends CommonObject * @param int $notrigger 1=Disable triggers * @return int <0 if KO, >0 if OK */ - public function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $langs, $conf, $hookmanager; @@ -842,16 +842,16 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update BBAN (RIB) account fields * * @param User $user Object user making update * @return int <0 if KO, >0 if OK */ - public function update_bban(User $user = null) + public function update_bban(User $user = null) { - // phpcs:enable + // phpcs:enable global $conf, $langs; // Clean parameters @@ -907,7 +907,7 @@ class Account extends CommonObject * @param string $ref Ref of bank account to get * @return int <0 if KO, >0 if OK */ - public function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -925,11 +925,11 @@ class Account extends CommonObject $sql .= " ba.datec as date_creation, ba.tms as date_update,"; $sql .= ' c.code as country_code, c.label as country,'; $sql .= ' d.code_departement as state_code, d.nom as state'; - $sql .= ' , aj.code as accountancy_journal'; + $sql .= ' , aj.code as accountancy_journal'; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ba.fk_pays = c.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.state_id = d.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; $sql .= " WHERE ba.entity IN (".getEntity($this->element).")"; if ($id) $sql .= " AND ba.rowid = ".$id; if ($ref) $sql .= " AND ba.ref = '".$this->db->escape($ref)."'"; @@ -1007,10 +1007,10 @@ class Account extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ - public function setCategories($categories) - { + public function setCategories($categories) + { // Handle single category if (!is_array($categories)) { $categories = array($categories); @@ -1051,7 +1051,7 @@ class Account extends CommonObject * @param User $user User deleting * @return int <0 if KO, >0 if OK */ - public function delete(User $user = null) + public function delete(User $user = null) { global $conf; @@ -1115,12 +1115,12 @@ class Account extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Label */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->clos, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of given object status * @@ -1128,9 +1128,9 @@ class Account extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Label */ - public function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load('banks'); @@ -1148,15 +1148,15 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un compte peut etre supprimer ou non (sans mouvements) * * @return boolean vrai si peut etre supprime, faux sinon */ - public function can_be_deleted() + public function can_be_deleted() { - // phpcs:enable + // phpcs:enable $can_be_deleted = false; $sql = "SELECT COUNT(rowid) as nb"; @@ -1179,7 +1179,7 @@ class Account extends CommonObject * * @return string Error string */ - public function error() + public function error() { return $this->error; } @@ -1190,7 +1190,7 @@ class Account extends CommonObject * @param int $option 1=Exclude future operation date (this is to exclude input made in advance and have real account sold) * @return int Current sold (value date <= today) */ - public function solde($option = 0) + public function solde($option = 0) { $solde = 0; @@ -1216,7 +1216,7 @@ class Account extends CommonObject return price2num($solde, 'MU'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1224,9 +1224,9 @@ class Account extends CommonObject * @param int $filteraccountid To get info for a particular account id * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board(User $user, $filteraccountid = 0) + public function load_board(User $user, $filteraccountid = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe @@ -1272,15 +1272,15 @@ class Account extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @param int $filteraccountid To get info for a particular account id * @return int <0 if ko, >0 if ok */ - public function load_state_board($filteraccountid = 0) + public function load_state_board($filteraccountid = 0) { - // phpcs:enable + // phpcs:enable global $user; if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe @@ -1348,10 +1348,10 @@ class Account extends CommonObject * @param string $mode ''=Link to card, 'transactions'=Link to transactions card * @param string $option ''=Show ref, 'reflabel'=Show ref+label * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $notooltip 1=Disable tooltip + * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs, $user; @@ -1401,10 +1401,10 @@ class Account extends CommonObject $linkstart = 'getCountryCode(); @@ -1507,7 +1507,7 @@ class Account extends CommonObject * * @return int 1 = mandatory / 0 = Not mandatory */ - public function needIBAN() + public function needIBAN() { $country_code = $this->getCountryCode(); @@ -1557,7 +1557,7 @@ class Account extends CommonObject * @param int $id Id of object to load * @return void */ - public function info($id) + public function info($id) { } @@ -1640,7 +1640,7 @@ class Account extends CommonObject //Replace the old AccountNumber key with the new BankAccountNumber key $fieldlists = explode( ' ', - preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION) + preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', $conf->global->BANK_SHOW_ORDER_OPTION) ); } } @@ -1656,7 +1656,7 @@ class Account extends CommonObject * * @return void */ - public function initAsSpecimen() + public function initAsSpecimen() { $this->specimen = 1; $this->ref = 'MBA'; @@ -1688,10 +1688,10 @@ class AccountLine extends CommonObject */ public $error = ''; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string ID to identify managed object @@ -1713,54 +1713,54 @@ class AccountLine extends CommonObject */ public $id; - /** - * @var string Ref - */ - public $ref; + /** + * @var string Ref + */ + public $ref; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * Date (dateo) - * - * @var integer - */ + /** + * Date (dateo) + * + * @var integer + */ public $dateo; /** - * Date value (datev) - * - * @var integer - */ + * Date value (datev) + * + * @var integer + */ public $datev; public $amount; - /** - * @var string bank transaction lines label - */ - public $label; + /** + * @var string bank transaction lines label + */ + public $label; - public $note; + public $note; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_rappro; /** - * @var int ID - */ + * @var int ID + */ public $fk_type; public $rappro; // Is it conciliated @@ -1769,13 +1769,13 @@ class AccountLine extends CommonObject public $bank_chq; // Bank of cheque /** - * @var int ID of cheque receipt - */ + * @var int ID of cheque receipt + */ public $fk_bordereau; /** - * @var int ID of bank account - */ + * @var int ID of bank account + */ public $fk_account; /** @@ -1783,7 +1783,7 @@ class AccountLine extends CommonObject */ public $bank_account_label; - /** + /** * @var string Name of check issuer */ public $emetteur; @@ -1793,7 +1793,7 @@ class AccountLine extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct(DoliDB $db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -1806,7 +1806,7 @@ class AccountLine extends CommonObject * @param string $num External num to load (ex: num of transaction for paypal fee) * @return int <0 if KO, 0 if OK but not found, >0 if OK and found */ - public function fetch($rowid, $ref = '', $num = '') + public function fetch($rowid, $ref = '', $num = '') { global $conf; @@ -1926,9 +1926,9 @@ class AccountLine extends CommonObject * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - public function delete(User $user = null) + public function delete(User $user = null) { - global $conf; + global $conf; $nbko = 0; @@ -1988,16 +1988,16 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete bank line records * * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - public function delete_urls(User $user = null) + public function delete_urls(User $user = null) { - // phpcs:enable + // phpcs:enable $nbko = 0; if ($this->rappro) @@ -2032,7 +2032,7 @@ class AccountLine extends CommonObject * @param int $notrigger 0=Disable all triggers * @return int <0 if KO, >0 if OK */ - public function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { $this->db->begin(); @@ -2056,7 +2056,7 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update conciliation field * @@ -2065,9 +2065,9 @@ class AccountLine extends CommonObject * @param int $conciliated 1=Set transaction to conciliated, 0=Keep transaction non conciliated * @return int <0 if KO, >0 if OK */ - public function update_conciliation(User $user, $cat, $conciliated = 1) + public function update_conciliation(User $user, $cat, $conciliated = 1) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $this->db->begin(); @@ -2119,7 +2119,7 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase/decrease value date of a rowid * @@ -2127,9 +2127,9 @@ class AccountLine extends CommonObject * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ - public function datev_change($rowid, $sign = 1) + public function datev_change($rowid, $sign = 1) { - // phpcs:enable + // phpcs:enable $sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; $resql = $this->db->query($sql); if ($resql) @@ -2156,34 +2156,34 @@ class AccountLine extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase value date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - public function datev_next($id) + public function datev_next($id) { - // phpcs:enable + // phpcs:enable return $this->datev_change($id, 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Decrease value date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - public function datev_previous($id) + public function datev_previous($id) { - // phpcs:enable + // phpcs:enable return $this->datev_change($id, -1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase/decrease operation date of a rowid * @@ -2191,9 +2191,9 @@ class AccountLine extends CommonObject * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ - public function dateo_change($rowid, $sign = 1) + public function dateo_change($rowid, $sign = 1) { - // phpcs:enable + // phpcs:enable $sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; $resql = $this->db->query($sql); if ($resql) @@ -2220,29 +2220,29 @@ class AccountLine extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase operation date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - public function dateo_next($id) + public function dateo_next($id) { - // phpcs:enable + // phpcs:enable return $this->dateo_change($id, 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Decrease operation date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - public function dateo_previous($id) + public function dateo_previous($id) { - // phpcs:enable + // phpcs:enable return $this->dateo_change($id, -1); } @@ -2253,7 +2253,7 @@ class AccountLine extends CommonObject * @param int $id Id of object to load * @return void */ - public function info($id) + public function info($id) { $sql = 'SELECT b.rowid, b.datec, b.tms as datem,'; $sql .= ' b.fk_user_author, b.fk_user_rappro'; @@ -2301,7 +2301,7 @@ class AccountLine extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0) { global $langs; @@ -2358,12 +2358,12 @@ class AccountLine extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2371,9 +2371,9 @@ class AccountLine extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; //$langs->load('companies'); /* diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 9c92eed8e70..694a1d7f6f0 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -443,105 +443,105 @@ class BankAccounts extends DolibarrApi $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql .= " ORDER BY rowid"; + $sql .= " ORDER BY rowid"; - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - for ($i = 0; $i < $num; $i++) { - $obj = $this->db->fetch_object($result); - $accountLine = new AccountLine($this->db); - if ($accountLine->fetch($obj->rowid) > 0) { - $list[] = $this->_cleanObjectDatas($accountLine); - } - } - } else { - throw new RestException(503, 'Error when retrieving list of account lines: '.$accountLine->error); - } + if ($result) { + $num = $this->db->num_rows($result); + for ($i = 0; $i < $num; $i++) { + $obj = $this->db->fetch_object($result); + $accountLine = new AccountLine($this->db); + if ($accountLine->fetch($obj->rowid) > 0) { + $list[] = $this->_cleanObjectDatas($accountLine); + } + } + } else { + throw new RestException(503, 'Error when retrieving list of account lines: '.$accountLine->error); + } - return $list; - } + return $list; + } - /** - * Add a line to an account - * - * @param int $id ID of account - * @param int $date Payment date (timestamp) {@from body} {@type timestamp} - * @param string $type Payment mode (TYP,VIR,PRE,LIQ,VAD,CB,CHQ...) {@from body} - * @param string $label Label {@from body} - * @param float $amount Amount (may be 0) {@from body} - * @param int $category Category - * @param string $cheque_number Cheque numberl {@from body} - * @param string $cheque_writer Name of cheque writer {@from body} - * @param string $cheque_bank Bank of cheque writer {@from body} - * @return int ID of line - * - * @url POST {id}/lines - */ - public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') - { - if (!DolibarrApiAccess::$user->rights->banque->modifier) { - throw new RestException(401); - } + /** + * Add a line to an account + * + * @param int $id ID of account + * @param int $date Payment date (timestamp) {@from body} {@type timestamp} + * @param string $type Payment mode (TYP,VIR,PRE,LIQ,VAD,CB,CHQ...) {@from body} + * @param string $label Label {@from body} + * @param float $amount Amount (may be 0) {@from body} + * @param int $category Category + * @param string $cheque_number Cheque numberl {@from body} + * @param string $cheque_writer Name of cheque writer {@from body} + * @param string $cheque_bank Bank of cheque writer {@from body} + * @return int ID of line + * + * @url POST {id}/lines + */ + public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') + { + if (!DolibarrApiAccess::$user->rights->banque->modifier) { + throw new RestException(401); + } - $account = new Account($this->db); - $result = $account->fetch($id); - if (!$result) { - throw new RestException(404, 'account not found'); - } + $account = new Account($this->db); + $result = $account->fetch($id); + if (!$result) { + throw new RestException(404, 'account not found'); + } - $result = $account->addline( - $date, - $type, - $label, - $amount, - $cheque_number, - $category, - DolibarrApiAccess::$user, - $cheque_writer, $cheque_bank - ); - if ($result < 0) { - throw new RestException(503, 'Error when adding line to account: '.$account->error); - } - return $result; - } + $result = $account->addline( + $date, + $type, + $label, + $amount, + $cheque_number, + $category, + DolibarrApiAccess::$user, + $cheque_writer, $cheque_bank + ); + if ($result < 0) { + throw new RestException(503, 'Error when adding line to account: '.$account->error); + } + return $result; + } - /** - * Add a link to an account line - * - * @param int $id ID of account - * @param int $line_id ID of account line - * @param int $url_id ID to set in the URL {@from body} - * @param string $url URL of the link {@from body} - * @param string $label Label {@from body} - * @param string $type Type of link ('payment', 'company', 'member', ...) {@from body} - * @return int ID of link - * - * @url POST {id}/lines/{line_id}/links - */ - public function addLink($id, $line_id, $url_id, $url, $label, $type) - { - if (!DolibarrApiAccess::$user->rights->banque->modifier) { - throw new RestException(401); - } + /** + * Add a link to an account line + * + * @param int $id ID of account + * @param int $line_id ID of account line + * @param int $url_id ID to set in the URL {@from body} + * @param string $url URL of the link {@from body} + * @param string $label Label {@from body} + * @param string $type Type of link ('payment', 'company', 'member', ...) {@from body} + * @return int ID of link + * + * @url POST {id}/lines/{line_id}/links + */ + public function addLink($id, $line_id, $url_id, $url, $label, $type) + { + if (!DolibarrApiAccess::$user->rights->banque->modifier) { + throw new RestException(401); + } - $account = new Account($this->db); - $result = $account->fetch($id); - if (!$result) { - throw new RestException(404, 'account not found'); - } + $account = new Account($this->db); + $result = $account->fetch($id); + if (!$result) { + throw new RestException(404, 'account not found'); + } - $accountLine = new AccountLine($this->db); - $result = $accountLine->fetch($line_id); - if (!$result) { - throw new RestException(404, 'account line not found'); - } + $accountLine = new AccountLine($this->db); + $result = $accountLine->fetch($line_id); + if (!$result) { + throw new RestException(404, 'account line not found'); + } - $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); - if ($result < 0) { - throw new RestException(503, 'Error when adding link to account line: '.$account->error); - } - return $result; - } + $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); + if ($result < 0) { + throw new RestException(503, 'Error when adding link to account line: '.$account->error); + } + return $result; + } } diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index c7e86e51cfb..99a941b074d 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -30,20 +30,20 @@ class BankCateg // extends CommonObject { //public $element='bank_categ'; //!< Id that identify managed objects //public $table_element='bank_categ'; //!< Name of table without prefix where object is stored - /** + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'generic'; /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; /** - * @var string bank categories label - */ - public $label; + * @var string bank categories label + */ + public $label; /** @@ -213,46 +213,46 @@ class BankCateg // extends CommonObject // Delete link between tag and bank account if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; - $sql .= " WHERE fk_categorie = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; + $sql .= " WHERE fk_categorie = ".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } } // Delete link between tag and bank lines if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; - $sql .= " WHERE fk_categ = ".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; + $sql .= " WHERE fk_categ = ".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } } // Delete bank categ if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql .= " WHERE rowid=".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; + $sql .= " WHERE rowid=".$this->id; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->errors[] = "Error ".$this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); + } } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 157a7096eb8..2a29fa81681 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -63,35 +63,35 @@ class PaymentVarious extends CommonObject public $amount; public $type_payment; public $num_payment; - public $category_transaction; + public $category_transaction; /** - * @var string various payments label - */ - public $label; + * @var string various payments label + */ + public $label; public $accountancy_code; - public $subledger_account; + public $subledger_account; /** - * @var int ID - */ + * @var int ID + */ public $fk_project; /** - * @var int ID - */ + * @var int ID + */ public $fk_bank; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; @@ -131,7 +131,7 @@ class PaymentVarious extends CommonObject * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct($db) { $this->db = $db; $this->element = 'payment_various'; @@ -145,7 +145,7 @@ class PaymentVarious extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - public function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -173,7 +173,7 @@ class PaymentVarious extends CommonObject $sql .= " label='".$this->db->escape($this->label)."',"; $sql .= " note='".$this->db->escape($this->note)."',"; $sql .= " accountancy_code='".$this->db->escape($this->accountancy_code)."',"; - $sql .= " subledger_account='".$this->db->escape($this->subledger_account)."',"; + $sql .= " subledger_account='".$this->db->escape($this->subledger_account)."',"; $sql .= " fk_projet='".$this->db->escape($this->fk_project)."',"; $sql .= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank : "null").","; $sql .= " fk_user_author=".(int) $this->fk_user_author.","; @@ -214,7 +214,7 @@ class PaymentVarious extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - public function fetch($id, $user = null) + public function fetch($id, $user = null) { global $langs; $sql = "SELECT"; @@ -286,7 +286,7 @@ class PaymentVarious extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - public function delete($user) + public function delete($user) { global $conf, $langs; @@ -320,7 +320,7 @@ class PaymentVarious extends CommonObject * * @return void */ - public function initAsSpecimen() + public function initAsSpecimen() { $this->id = 0; @@ -331,7 +331,7 @@ class PaymentVarious extends CommonObject $this->amount = ''; $this->label = ''; $this->accountancy_code = ''; - $this->subledger_account = ''; + $this->subledger_account = ''; $this->note = ''; $this->fk_bank = ''; $this->fk_user_author = ''; @@ -362,7 +362,7 @@ class PaymentVarious extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - public function create($user) + public function create($user) { global $conf, $langs; @@ -460,13 +460,13 @@ class PaymentVarious extends CommonObject $sign = 1; if ($this->sens == '0') $sign = -1; - $bank_line_id = $acc->addline( + $bank_line_id = $acc->addline( $this->datep, $this->type_payment, $this->label, $sign * abs($this->amount), $this->num_payment, - ($this->category_transaction > 0 ? $this->category_transaction : 0), + ($this->category_transaction > 0 ? $this->category_transaction : 0), $user, '', '', @@ -525,16 +525,16 @@ class PaymentVarious extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between payment various and line generate into llx_bank * * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK */ - public function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { - // phpcs:enable + // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); @@ -554,12 +554,12 @@ class PaymentVarious extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -567,9 +567,9 @@ class PaymentVarious extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - public function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0) @@ -608,10 +608,10 @@ class PaymentVarious extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option link option * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $notooltip 1=Disable tooltip + * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $db, $conf, $langs, $hookmanager; global $langs; @@ -679,8 +679,8 @@ class PaymentVarious extends CommonObject * @param int $id Id of record * @return void */ - public function info($id) - { + public function info($id) + { $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; $sql .= ' WHERE v.rowid = '.$id; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 896b91545db..c67c0496727 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -41,11 +41,11 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check if ($user->socid) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } if ($user->socid) - $socid = $user->socid; + $socid = $user->socid; // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -57,9 +57,9 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) - $sortorder = "ASC"; + $sortorder = "ASC"; if (!$sortfield) - $sortfield = "name"; + $sortfield = "name"; $object = new Account($db); if ($id > 0 || !empty($ref)) $object->fetch($id, $ref); @@ -73,8 +73,8 @@ $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); if ($object->id > 0) { - $object->fetch_thirdparty(); - $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); + $object->fetch_thirdparty(); + $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); } include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -91,52 +91,52 @@ llxHeader('', $title, $helpurl); $form = new Form($db); if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref)) { - $upload_dir = $conf->bank->dir_output.'/'.$object->ref; + if ($object->fetch($id, $ref)) { + $upload_dir = $conf->bank->dir_output.'/'.$object->ref; - // Onglets - $head = bank_prepare_head($object); - print dol_get_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account'); + // Onglets + $head = bank_prepare_head($object); + print dol_get_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account'); - // Build file list - $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']; - } + // Build file list + $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']; + } - $morehtmlref = ''; + $morehtmlref = ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; - print ''; - print ''; - print ''; - print "
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
\n"; + print ''; + print ''; + print ''; + print "
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
\n"; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - $modulepart = 'bank'; - $permission = $user->rights->banque->modifier; - $permtoedit = $user->rights->banque->modifier; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; - } else { - dol_print_error($db); - } + $modulepart = 'bank'; + $permission = $user->rights->banque->modifier; + $permtoedit = $user->rights->banque->modifier; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + } else { + dol_print_error($db); + } } else { - Header('Location: index.php'); - exit; + Header('Location: index.php'); + exit; } // End of page diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 9350e211284..f141abc8e87 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -741,14 +741,14 @@ if ($account) if ($_GET["option"] != 'all') { $morehtml = ''.$langs->trans("ShowAllAccounts").''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); } else { $morehtml = ''.$langs->trans("BackToAccount").''; print $langs->trans("AllAccounts"); //print $morehtml; } } else { - $bankaccount = new Account($db); + $bankaccount = new Account($db); $listid = explode(',', $account); foreach ($listid as $key => $id) { diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 7ae7c995935..dd14ebf4e54 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -65,30 +65,30 @@ if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) accessf if ($cancel) { - if ($backtopage) - { - header("Location: ".$backtopage); - exit; - } + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } } if ($user->rights->banque->consolidate && $action == 'donext') { - $al = new AccountLine($db); - $al->dateo_next($_GET["rowid"]); + $al = new AccountLine($db); + $al->dateo_next($_GET["rowid"]); } elseif ($user->rights->banque->consolidate && $action == 'doprev') { - $al = new AccountLine($db); - $al->dateo_previous($_GET["rowid"]); + $al = new AccountLine($db); + $al->dateo_previous($_GET["rowid"]); } elseif ($user->rights->banque->consolidate && $action == 'dvnext') { - $al = new AccountLine($db); - $al->datev_next($_GET["rowid"]); + $al = new AccountLine($db); + $al->datev_next($_GET["rowid"]); } elseif ($user->rights->banque->consolidate && $action == 'dvprev') { - $al = new AccountLine($db); - $al->datev_previous($_GET["rowid"]); + $al = new AccountLine($db); + $al->datev_previous($_GET["rowid"]); } if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) @@ -96,10 +96,10 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban $cat1 = GETPOST("cat1", 'int'); if (!empty($rowid) && !empty($cat1)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid." AND fk_categ = ".$cat1; - if (!$db->query($sql)) - { - dol_print_error($db); - } + if (!$db->query($sql)) + { + dol_print_error($db); + } } else { setEventMessages($langs->trans("MissingIds"), null, 'errors'); } @@ -157,31 +157,31 @@ if ($user->rights->banque->modifier && $action == "update") $result = $db->query($sql); if (!$result) { - $error++; + $error++; } if (!$error) { - $arrayofcategs = GETPOST('custcats', 'array'); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid; - if (!$db->query($sql)) - { - $error++; - dol_print_error($db); - } - if (count($arrayofcategs)) - { - foreach ($arrayofcategs as $val) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")"; - if (!$db->query($sql)) - { - $error++; - dol_print_error($db); - } - } - // $arrayselected will be loaded after in page output - } + $arrayofcategs = GETPOST('custcats', 'array'); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".$rowid; + if (!$db->query($sql)) + { + $error++; + dol_print_error($db); + } + if (count($arrayofcategs)) + { + foreach ($arrayofcategs as $val) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".$rowid.", ".$val.")"; + if (!$db->query($sql)) + { + $error++; + dol_print_error($db); + } + } + // $arrayselected will be loaded after in page output + } } if (!$error) @@ -198,37 +198,37 @@ if ($user->rights->banque->modifier && $action == "update") // Reconcile if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile')) { - $num_rel = trim($_POST["num_rel"]); - $rappro = $_POST['reconciled'] ? 1 : 0; + $num_rel = trim($_POST["num_rel"]); + $rappro = $_POST['reconciled'] ? 1 : 0; - // Check parameters - if ($rappro && empty($num_rel)) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountStatement")), null, 'errors'); - $error++; - } + // Check parameters + if ($rappro && empty($num_rel)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountStatement")), null, 'errors'); + $error++; + } - if (!$error) - { - $db->begin(); + if (!$error) + { + $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql .= " SET num_releve=".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); - if (empty($num_rel)) $sql .= ", rappro = 0"; - else $sql .= ", rappro = ".$rappro; - $sql .= " WHERE rowid = ".$rowid; + $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; + $sql .= " SET num_releve=".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); + if (empty($num_rel)) $sql .= ", rappro = 0"; + else $sql .= ", rappro = ".$rappro; + $sql .= " WHERE rowid = ".$rowid; - dol_syslog("line.php", LOG_DEBUG); - $result = $db->query($sql); - if ($result) - { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - dol_print_error($db); - } - } + dol_syslog("line.php", LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + dol_print_error($db); + } + } } @@ -244,7 +244,7 @@ llxHeader('', $langs->trans("BankTransaction")); $c = new Categorie($db); $cats = $c->containing($rowid, Categorie::TYPE_BANK_LINE); foreach ($cats as $cat) { - $arrayselected[] = $cat->id; + $arrayselected[] = $cat->id; } $head = bankline_prepare_head($rowid); @@ -259,385 +259,385 @@ $sql .= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { - $i = 0; $total = 0; - if ($db->num_rows($result)) - { - $objp = $db->fetch_object($result); + $i = 0; $total = 0; + if ($db->num_rows($result)) + { + $objp = $db->fetch_object($result); - $total = $total + $objp->amount; + $total = $total + $objp->amount; - $acct = new Account($db); - $acct->fetch($objp->fk_account); - $account = $acct->id; + $acct = new Account($db); + $acct->fetch($objp->fk_account); + $account = $acct->id; - $bankline = new AccountLine($db); - $bankline->fetch($rowid, $ref); + $bankline = new AccountLine($db); + $bankline->fetch($rowid, $ref); - $links = $acct->get_url($rowid); - $bankline->load_previous_next_ref('', 'rowid'); + $links = $acct->get_url($rowid); + $bankline->load_previous_next_ref('', 'rowid'); - // Confirmations - if ($action == 'delete_categ') - { - print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); - } + // Confirmations + if ($action == 'delete_categ') + { + print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); + } - print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); + print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($bankline, 'rowid', $linkback); + dol_banner_tab($bankline, 'rowid', $linkback); print '
'; - print '
'; - print ''; + print '
'; + print '
'; - $i++; + $i++; - // Bank account - print ''; - print ''; - print ''; + // Bank account + print ''; + print ''; + print ''; - // Show links of bank transactions - if (count($links)) - { - print ''; - print ''; + print ''; - } + print $paymenttmp->getNomUrl(1); + } elseif ($links[$key]['type'] == 'company') { + $societe = new Societe($db); + $societe->fetch($links[$key]['url_id']); + print $societe->getNomUrl(1); + } elseif ($links[$key]['type'] == 'sc') { + print ''; + print img_object($langs->trans('SocialContribution'), 'bill').' '; + print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); + print ''; + } elseif ($links[$key]['type'] == 'payment_sc') { + print ''; + print img_object($langs->trans('Payment'), 'payment').' '; + print $langs->trans("SocialContributionPayment"); + print ''; + } elseif ($links[$key]['type'] == 'payment_vat') { + print ''; + print img_object($langs->trans('VAT'), 'payment').' '; + print $langs->trans("VATPayment"); + print ''; + } elseif ($links[$key]['type'] == 'payment_salary') { + print ''; + print img_object($langs->trans('PaymentSalary'), 'payment').' '; + print $langs->trans("SalaryPayment"); + print ''; + } elseif ($links[$key]['type'] == 'payment_loan') { + print ''; + print img_object($langs->trans('LoanPayment'), 'payment').' '; + print $langs->trans("PaymentLoan"); + print ''; + } elseif ($links[$key]['type'] == 'loan') { + print ''; + print img_object($langs->trans('Loan'), 'bill').' '; + print $langs->trans("Loan"); + print ''; + } elseif ($links[$key]['type'] == 'member') { + print ''; + print img_object($langs->trans('Member'), 'user').' '; + print $links[$key]['label']; + print ''; + } elseif ($links[$key]['type'] == 'payment_donation') { + print ''; + print img_object($langs->trans('Donation'), 'payment').' '; + print $langs->trans("DonationPayment"); + print ''; + } elseif ($links[$key]['type'] == 'banktransfert') { + print ''; + print img_object($langs->trans('Transaction'), 'payment').' '; + print $langs->trans("TransactionOnTheOtherAccount"); + print ''; + } elseif ($links[$key]['type'] == 'user') { + print ''; + print img_object($langs->trans('User'), 'user').' '; + print $langs->trans("User"); + print ''; + } elseif ($links[$key]['type'] == 'payment_various') { + print ''; + print img_object($langs->trans('VariousPayment'), 'payment').' '; + print $langs->trans("VariousPayment"); + print ''; + } else { + print ''; + print img_object('', 'generic').' '; + print $links[$key]['label']; + print ''; + } + } + print ''; + } - //$user->rights->banque->modifier=false; - //$user->rights->banque->consolidate=true; + //$user->rights->banque->modifier=false; + //$user->rights->banque->consolidate=true; - // Type of payment / Number - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ""; + // Type of payment / Number + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ""; - // Transmitter - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ""; + // Transmitter + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ""; - // Bank of cheque - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ""; + // Bank of cheque + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ""; - // Date ope - print ''; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ''; + // Date ope + print ''; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ''; - // Value date - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ""; + // Value date + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ""; - // Description - print ""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ''; + // Description + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ''; - // Amount - print ""; - if ($user->rights->banque->modifier) - { - print ''; - } else { - print ''; - } - print ""; + // Amount + print ""; + if ($user->rights->banque->modifier) + { + print ''; + } else { + print ''; + } + print ""; - // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) - { - $langs->load('categories'); + // Categories + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + { + $langs->load('categories'); - // Bank line - print '"; - } + // Bank line + print '"; + } - print "
'.$langs->trans("Account").''; - if (!$objp->rappro && !$bankline->getVentilExportCompta()) - { - $form->select_comptes($acct->id, 'accountid', 0, '', 0); - } else { - print $acct->getNomUrl(1, 'transactions', 'reflabel'); - } - print '
'.$langs->trans("Account").''; + if (!$objp->rappro && !$bankline->getVentilExportCompta()) + { + $form->select_comptes($acct->id, 'accountid', 0, '', 0); + } else { + print $acct->getNomUrl(1, 'transactions', 'reflabel'); + } + print '
'.$langs->trans("Links").''; - foreach ($links as $key=>$val) - { - if ($key) print '
'; - if ($links[$key]['type'] == 'payment') { - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - $paymenttmp = new Paiement($db); - $paymenttmp->fetch($links[$key]['url_id']); - $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; - /*print ''; + // Show links of bank transactions + if (count($links)) + { + print '
'.$langs->trans("Links").''; + foreach ($links as $key=>$val) + { + if ($key) print '
'; + if ($links[$key]['type'] == 'payment') { + require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $paymenttmp = new Paiement($db); + $paymenttmp->fetch($links[$key]['url_id']); + $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; + /*print ''; print img_object($langs->trans('Payment'),'payment').' '; print $langs->trans("Payment"); print '';*/ - print $paymenttmp->getNomUrl(1); - } elseif ($links[$key]['type'] == 'payment_supplier') { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; - $paymenttmp = new PaiementFourn($db); - $paymenttmp->fetch($links[$key]['url_id']); - $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; - /*print ''; + print $paymenttmp->getNomUrl(1); + } elseif ($links[$key]['type'] == 'payment_supplier') { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; + $paymenttmp = new PaiementFourn($db); + $paymenttmp->fetch($links[$key]['url_id']); + $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref; + /*print ''; print img_object($langs->trans('Payment'),'payment').' '; print $langs->trans("Payment"); print '';*/ - print $paymenttmp->getNomUrl(1); - } elseif ($links[$key]['type'] == 'company') { - $societe = new Societe($db); - $societe->fetch($links[$key]['url_id']); - print $societe->getNomUrl(1); - } elseif ($links[$key]['type'] == 'sc') { - print ''; - print img_object($langs->trans('SocialContribution'), 'bill').' '; - print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); - print ''; - } elseif ($links[$key]['type'] == 'payment_sc') { - print ''; - print img_object($langs->trans('Payment'), 'payment').' '; - print $langs->trans("SocialContributionPayment"); - print ''; - } elseif ($links[$key]['type'] == 'payment_vat') { - print ''; - print img_object($langs->trans('VAT'), 'payment').' '; - print $langs->trans("VATPayment"); - print ''; - } elseif ($links[$key]['type'] == 'payment_salary') { - print ''; - print img_object($langs->trans('PaymentSalary'), 'payment').' '; - print $langs->trans("SalaryPayment"); - print ''; - } elseif ($links[$key]['type'] == 'payment_loan') { - print ''; - print img_object($langs->trans('LoanPayment'), 'payment').' '; - print $langs->trans("PaymentLoan"); - print ''; - } elseif ($links[$key]['type'] == 'loan') { - print ''; - print img_object($langs->trans('Loan'), 'bill').' '; - print $langs->trans("Loan"); - print ''; - } elseif ($links[$key]['type'] == 'member') { - print ''; - print img_object($langs->trans('Member'), 'user').' '; - print $links[$key]['label']; - print ''; - } elseif ($links[$key]['type'] == 'payment_donation') { - print ''; - print img_object($langs->trans('Donation'), 'payment').' '; - print $langs->trans("DonationPayment"); - print ''; - } elseif ($links[$key]['type'] == 'banktransfert') { - print ''; - print img_object($langs->trans('Transaction'), 'payment').' '; - print $langs->trans("TransactionOnTheOtherAccount"); - print ''; - } elseif ($links[$key]['type'] == 'user') { - print ''; - print img_object($langs->trans('User'), 'user').' '; - print $langs->trans("User"); - print ''; - } elseif ($links[$key]['type'] == 'payment_various') { - print ''; - print img_object($langs->trans('VariousPayment'), 'payment').' '; - print $langs->trans("VariousPayment"); - print ''; - } else { - print ''; - print img_object('', 'generic').' '; - print $links[$key]['label']; - print ''; - } - } - print '
".$langs->trans("Type")." / ".$langs->trans("Numero"); - print ' ('.$langs->trans("ChequeOrTransferNumber").')'; - print "'; - $form->select_types_paiements($objp->fk_type, "value", '', 2); - print ''; - if ($objp->receiptid) - { - include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - $receipt = new RemiseCheque($db); - $receipt->fetch($objp->receiptid); - print '     '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2); - } - print ''.$objp->fk_type.' '.$objp->num_chq.'
".$langs->trans("Type")." / ".$langs->trans("Numero"); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print "'; + $form->select_types_paiements($objp->fk_type, "value", '', 2); + print ''; + if ($objp->receiptid) + { + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; + $receipt = new RemiseCheque($db); + $receipt->fetch($objp->receiptid); + print '     '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2); + } + print ''.$objp->fk_type.' '.$objp->num_chq.'
".$langs->trans("CheckTransmitter"); - print ' ('.$langs->trans("ChequeMaker").')'; - print "'; - print ''; - print ''.$objp->emetteur.'
".$langs->trans("CheckTransmitter"); + print ' ('.$langs->trans("ChequeMaker").')'; + print "'; + print ''; + print ''.$objp->emetteur.'
".$langs->trans("Bank"); - print ' ('.$langs->trans("ChequeBank").')'; - print "'; - print ''; - print ''.$objp->banque.'
".$langs->trans("Bank"); + print ' ('.$langs->trans("ChequeBank").')'; + print "'; + print ''; + print ''.$objp->banque.'
'.$langs->trans("DateOperation").''; - print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro); - if (!$objp->rappro) - { - print '   '; - print ''; - print img_edit_remove()." "; - print ''; - print img_edit_add().""; - } - print ''; - print dol_print_date($db->jdate($objp->do), "day"); - print '
'.$langs->trans("DateOperation").''; + print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro); + if (!$objp->rappro) + { + print '   '; + print ''; + print img_edit_remove()." "; + print ''; + print img_edit_add().""; + } + print ''; + print dol_print_date($db->jdate($objp->do), "day"); + print '
".$langs->trans("DateValue")."'; - print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro); - if (!$objp->rappro) - { - print '   '; - print ''; - print img_edit_remove()." "; - print ''; - print img_edit_add().""; - } - print ''; - print dol_print_date($db->jdate($objp->dv), "day"); - print '
".$langs->trans("DateValue")."'; + print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro); + if (!$objp->rappro) + { + print '   '; + print ''; + print img_edit_remove()." "; + print ''; + print img_edit_add().""; + } + print ''; + print dol_print_date($db->jdate($objp->dv), "day"); + print '
".$langs->trans("Label")."'; - print 'rappro ? ' disabled' : '').' value="'; - if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) - { - // Label generique car entre parentheses. On l'affiche en le traduisant - print $langs->trans($reg[1]); - } else { - print $objp->label; - } - print '">'; - print ''; - if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) - { - // Label generique car entre parentheses. On l'affiche en le traduisant - print $langs->trans($reg[1]); - } else { - print $objp->label; - } - print '
".$langs->trans("Label")."'; + print 'rappro ? ' disabled' : '').' value="'; + if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + print $langs->trans($reg[1]); + } else { + print $objp->label; + } + print '">'; + print ''; + if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + print $langs->trans($reg[1]); + } else { + print $objp->label; + } + print '
".$langs->trans("Amount")."'; - print 'rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); - print ''; - print price($objp->amount); - print '
".$langs->trans("Amount")."'; + print 'rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); + print ''; + print price($objp->amount); + print '
'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1); - print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%"); - print "
'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1); + print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%"); + print "
"; + print ""; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '

'; + print '

'; - print ""; + print ""; - // Releve rappro - if ($acct->canBeConciliated() > 0) // Si compte rapprochable - { - print load_fiche_titre($langs->trans("Reconciliation"), '', 'bank_account'); - print '
'."\n"; + // Releve rappro + if ($acct->canBeConciliated() > 0) // Si compte rapprochable + { + print load_fiche_titre($langs->trans("Reconciliation"), '', 'bank_account'); + print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; + print '
'; - print ''; + print '
'; - print '"; - if ($user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ''; + print '"; + if ($user->rights->banque->consolidate) + { + print ''; + } else { + print ''; + } + print ''; - print ""; - if ($user->rights->banque->consolidate) - { - print ''; - } else { - print ''; - } - print ''; - print '
'.$langs->trans("Conciliation")."'; - if ($objp->rappro) - { - print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; - print ''; - } else { - print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; - } - if ($objp->num_releve) print '   ('.$langs->trans("AccountStatement").' '.$objp->num_releve.')'; - print ''.$objp->num_releve.' 
'.$langs->trans("Conciliation")."'; + if ($objp->rappro) + { + print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; + print ''; + } else { + print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>'; + } + if ($objp->num_releve) print '   ('.$langs->trans("AccountStatement").' '.$objp->num_releve.')'; + print ''.$objp->num_releve.' 
".$langs->trans("BankLineConciliated")."'; - print 'rappro ? ' checked="checked"' : '')).'">'; - print ''.yn($objp->rappro).'
'; + print "".$langs->trans("BankLineConciliated").""; + if ($user->rights->banque->consolidate) + { + print ''; + print 'rappro ? ' checked="checked"' : '')).'">'; + print ''; + } else { + print ''.yn($objp->rappro).''; + } + print ''; + print ''; - print '
'; + print '
'; - print '
'; + print '
'; - print ''; - if ($backtopage) - { - print '   '; - print ''; - } - print '
'; + print ''; + if ($backtopage) + { + print '   '; + print ''; + } + print '
'; print '
'; - } - } + } + } - $db->free($result); + $db->free($result); } else dol_print_error($db); // End of page diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 4e3653d2ea4..22bd08da1ba 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -86,24 +86,24 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'b.ref'=>'Ref', - 'b.label'=>'Label', + 'b.ref'=>'Ref', + 'b.label'=>'Label', ); $checkedtypetiers = 0; $arrayfields = array( - 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1), - 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1), - 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), - 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), - 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), - 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), - 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0), + 'b.ref'=>array('label'=>$langs->trans("BankAccounts"), 'checked'=>1), + 'accountype'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), + 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), + 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>(!empty($conf->accounting->enabled) || !empty($conf->accounting->enabled))), + 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), + 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), + 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), ); // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) @@ -134,10 +134,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $search_ref = ''; - $search_label = ''; - $search_number = ''; - $search_status = ''; + $search_ref = ''; + $search_label = ''; + $search_number = ''; + $search_status = ''; } @@ -194,8 +194,8 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); } $sql .= $db->plimit($limit + 1, $offset); @@ -203,15 +203,15 @@ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $accounts[$objp->rowid] = $objp->courant; - $i++; - } - $db->free($resql); + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $accounts[$objp->rowid] = $objp->courant; + $i++; + } + $db->free($resql); } else dol_print_error($db); @@ -267,8 +267,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -302,53 +302,53 @@ print ''; // Ref if (!empty($arrayfields['b.ref']['checked'])) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Label if (!empty($arrayfields['b.label']['checked'])) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Account type if (!empty($arrayfields['accountype']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Bank number if (!empty($arrayfields['b.number']['checked'])) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Account number if (!empty($arrayfields['b.account_number']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Accountancy journal if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Transactions to reconcile if (!empty($arrayfields['toreconcile']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Currency if (!empty($arrayfields['b.currency_code']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -360,30 +360,30 @@ print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['b.datec']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Date modification if (!empty($arrayfields['b.tms']['checked'])) { - print ''; - print ''; + print ''; + print ''; } // Status if (!empty($arrayfields['b.clos']['checked'])) { - print ''; - $array = array( - 'opened'=>$langs->trans("Opened"), - 'closed'=>$langs->trans("Closed") - ); - print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); - print ''; + print ''; + $array = array( + 'opened'=>$langs->trans("Opened"), + 'closed'=>$langs->trans("Closed") + ); + print $form->selectarray("search_status", $array, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); + print ''; } // Balance if (!empty($arrayfields['balance']['checked'])) { - print ''; + print ''; } // Action column print ''; @@ -422,7 +422,7 @@ foreach ($accounts as $key=>$type) { if ($i >= $limit) break; - $found++; + $found++; $result = $objecttmp->fetch($key); @@ -439,163 +439,163 @@ foreach ($accounts as $key=>$type) print ''; - // Ref - if (!empty($arrayfields['b.ref']['checked'])) - { - print ''.$objecttmp->getNomUrl(1).''; - if (!$i) $totalarray['nbfield']++; - } + // Ref + if (!empty($arrayfields['b.ref']['checked'])) + { + print ''.$objecttmp->getNomUrl(1).''; + if (!$i) $totalarray['nbfield']++; + } - // Label - if (!empty($arrayfields['b.label']['checked'])) - { + // Label + if (!empty($arrayfields['b.label']['checked'])) + { print ''.$objecttmp->label.''; - if (!$i) $totalarray['nbfield']++; - } + if (!$i) $totalarray['nbfield']++; + } - // Account type - if (!empty($arrayfields['accountype']['checked'])) - { - print ''; + // Account type + if (!empty($arrayfields['accountype']['checked'])) + { + print ''; print $objecttmp->type_lib[$objecttmp->type]; print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Number - if (!empty($arrayfields['b.number']['checked'])) - { - print ''.$objecttmp->number.''; - if (!$i) $totalarray['nbfield']++; - } - - // Account number - if (!empty($arrayfields['b.account_number']['checked'])) - { - print ''; - if (!empty($conf->accounting->enabled) && !empty($objecttmp->account_number)) - { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $objecttmp->account_number, 1); - print $accountingaccount->getNomUrl(0, 1, 1, '', 1); - } else { - print $objecttmp->account_number; - } - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Accountancy journal - if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) - { - print ''; - if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) - { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objecttmp->fk_accountancy_journal); - print $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } else { - print ''; - } - print ''; if (!$i) $totalarray['nbfield']++; - } + } - // Currency - if (!empty($arrayfields['b.currency_code']['checked'])) - { - print ''; + // Number + if (!empty($arrayfields['b.number']['checked'])) + { + print ''.$objecttmp->number.''; + if (!$i) $totalarray['nbfield']++; + } + + // Account number + if (!empty($arrayfields['b.account_number']['checked'])) + { + print ''; + if (!empty($conf->accounting->enabled) && !empty($objecttmp->account_number)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('', $objecttmp->account_number, 1); + print $accountingaccount->getNomUrl(0, 1, 1, '', 1); + } else { + print $objecttmp->account_number; + } + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Accountancy journal + if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) + { + print ''; + if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) + { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objecttmp->fk_accountancy_journal); + print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } else { + print ''; + } + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Currency + if (!empty($arrayfields['b.currency_code']['checked'])) + { + print ''; print $objecttmp->currency_code; - print ''; - if (!$i) $totalarray['nbfield']++; - } + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Transactions to reconcile - if (!empty($arrayfields['toreconcile']['checked'])) - { - print ''; + // Transactions to reconcile + if (!empty($arrayfields['toreconcile']['checked'])) + { + print ''; - $conciliate = $objecttmp->canBeConciliated(); - if ($conciliate == -2) print ''.$langs->trans("CashAccount").''; - elseif ($conciliate == -3) print ''.$langs->trans("Closed").''; - elseif (empty($objecttmp->rappro)) { - print ''.$langs->trans("ConciliationDisabled").''; - } else { - $result = $objecttmp->load_board($user, $objecttmp->id); - if ($result < 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - } else { - print ''; - print ''; - print $result->nbtodo; - print ''; + $conciliate = $objecttmp->canBeConciliated(); + if ($conciliate == -2) print ''.$langs->trans("CashAccount").''; + elseif ($conciliate == -3) print ''.$langs->trans("Closed").''; + elseif (empty($objecttmp->rappro)) { + print ''.$langs->trans("ConciliationDisabled").''; + } else { + $result = $objecttmp->load_board($user, $objecttmp->id); + if ($result < 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + } else { + print ''; + print ''; + print $result->nbtodo; + print ''; print ''; - if ($result->nbtodolate) { - print ''; - print ' '.$result->nbtodolate; - print ''; - } - } - } + if ($result->nbtodolate) { + print ''; + print ' '.$result->nbtodolate; + print ''; + } + } + } - print ''; - if (!$i) $totalarray['nbfield']++; - } + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Extra fields + // Extra fields if (is_array($objecttmp->array_options)) { $obj = new stdClass(); foreach ($objecttmp->array_options as $k => $v) { $obj->$k = $v; } } - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook - print $hookmanager->resPrint; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook + print $hookmanager->resPrint; // Date creation - if (!empty($arrayfields['b.datec']['checked'])) - { - print ''; - print dol_print_date($objecttmp->date_creation, 'dayhour'); - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Date modification - if (!empty($arrayfields['b.tms']['checked'])) - { - print ''; - print dol_print_date($objecttmp->date_update, 'dayhour'); - print ''; - if (!$i) $totalarray['nbfield']++; - } + if (!empty($arrayfields['b.datec']['checked'])) + { + print ''; + print dol_print_date($objecttmp->date_creation, 'dayhour'); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date modification + if (!empty($arrayfields['b.tms']['checked'])) + { + print ''; + print dol_print_date($objecttmp->date_update, 'dayhour'); + print ''; + if (!$i) $totalarray['nbfield']++; + } - // Status - if (!empty($arrayfields['b.clos']['checked'])) - { + // Status + if (!empty($arrayfields['b.clos']['checked'])) + { print ''.$objecttmp->getLibStatut(5).''; - if (!$i) $totalarray['nbfield']++; - } + if (!$i) $totalarray['nbfield']++; + } - // Balance - if (!empty($arrayfields['balance']['checked'])) - { + // Balance + if (!empty($arrayfields['balance']['checked'])) + { print ''; print ''.price($solde, 0, $langs, 0, -1, -1, $objecttmp->currency_code).''; print ''; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'balance'; $totalarray['val']['balance'] += $solde; - } + } // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected = 0; - if (in_array($objecttmp->id, $arrayofselected)) $selected = 1; - print ''; + $selected = 0; + if (in_array($objecttmp->id, $arrayofselected)) $selected = 1; + print ''; } print ''; if (!$i) $totalarray['nbfield']++; @@ -610,9 +610,9 @@ foreach ($accounts as $key=>$type) // If no record found if (!$found) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } - print ''.$langs->trans("NoRecordFound").''; + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; } // Show total line diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 166d69fdd30..92dd2de75f4 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -93,8 +93,8 @@ if (!$sortfield) $sortfield = "s.nom"; $object = new Account($db); if ($id > 0 || !empty($ref)) { - $result = $object->fetch($id, $ref); - $account = $object->id; // Force the search field on id of account + $result = $object->fetch($id, $ref); + $account = $object->id; // Force the search field on id of account } @@ -371,15 +371,15 @@ if (empty($numref)) $morehtmlright .= ''; $morehtmlright .= '
'; - $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); - print load_fiche_titre($title, $morehtmlright, ''); + $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); + print load_fiche_titre($title, $morehtmlright, ''); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'bank_account', 0, '', '', 0, 1); print "
"; print ''; print ''; - print '
'; + print '
'; print ''; print ''; print ''; @@ -407,7 +407,7 @@ if (empty($numref)) } // Recherche les ecritures pour le releve - $sql = $sqlrequestforbankline; + $sql = $sqlrequestforbankline; $result = $db->query($sql); if ($result) @@ -441,17 +441,17 @@ if (empty($numref)) print "\n"; // Type and num - if ($objp->fk_type == 'SOLD') { - $type_label = ' '; - } else { - $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type; - } - $link = ''; - if ($objp->fk_bordereau > 0) { - $remisestatic->id = $objp->fk_bordereau; - $remisestatic->ref = $objp->ref; - $link = ' '.$remisestatic->getNomUrl(1); - } + if ($objp->fk_type == 'SOLD') { + $type_label = ' '; + } else { + $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type; + } + $link = ''; + if ($objp->fk_bordereau > 0) { + $remisestatic->id = $objp->fk_bordereau; + $remisestatic->ref = $objp->ref; + $link = ' '.$remisestatic->getNomUrl(1); + } print ''; // Description @@ -548,9 +548,9 @@ if (empty($numref)) print ')'; } } elseif ($links[$key]['type'] == 'company') { - $societestatic->id = $links[$key]['url_id']; - $societestatic->name = $links[$key]['label']; - print $societestatic->getNomUrl(1, 'company', 24); + $societestatic->id = $links[$key]['url_id']; + $societestatic->name = $links[$key]['label']; + print $societestatic->getNomUrl(1, 'company', 24); $newline = 0; } elseif ($links[$key]['type'] == 'member') { print ''; diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 70903f9120f..7e1b7fd0567 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -118,9 +118,9 @@ if ($action == 'add') if (!$error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, $amountto, '', '', $user); if (!($bank_line_id_to > 0)) $error++; - if (!$error) $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + if (!$error) $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); if (!($result > 0)) $error++; - if (!$error) $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); + if (!$error) $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, DOL_URL_ROOT.'/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'); if (!($result > 0)) $error++; if (!$error) @@ -133,7 +133,7 @@ if ($action == 'add') $db->rollback(); } } else { - $error++; + $error++; setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers"), null, 'errors'); } } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 03844897a15..6d811233b7a 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -98,15 +98,15 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print dol_get_fiche_end(); - print '
'; + print '
'; $solde = $object->solde(0); if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)$colspan = 6; else $colspan = 5; // Show next coming entries - print '
'; - print '
'.$langs->trans("DateOperationShort").''.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.'
'; + print '
'; + print '
'; // Ligne de titre tableau des ecritures print ''; @@ -277,13 +277,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // We discard lines with a remainder to pay to 0 if (price2num($total_ttc) != 0) { - // Show line - print ''; - print '"; - print ""; + // Show line + print ''; + print '"; + print ""; if ($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED) { if ($obj->family == 'invoice') { $mc->getInfo($obj->entity); @@ -292,11 +292,11 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ""; } } - print ""; - if ($obj->total_ttc < 0) { print '"; }; - if ($obj->total_ttc >= 0) { print '"; }; - print ''; - print ""; + print ""; + if ($obj->total_ttc < 0) { print '"; }; + if ($obj->total_ttc >= 0) { print '"; }; + print ''; + print ""; } $i++; @@ -310,7 +310,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { print $hookmanager->resPrint; - $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; + $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; } // solde @@ -320,7 +320,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''; print "
'; - if ($obj->dlr) print dol_print_date($db->jdate($obj->dlr), "day"); - else print $langs->trans("NotDefined"); - print "".$ref."
'; + if ($obj->dlr) print dol_print_date($db->jdate($obj->dlr), "day"); + else print $langs->trans("NotDefined"); + print "".$ref."".$refcomp."'.price(abs($total_ttc))."  '.price($total_ttc)."'.price($solde).'
".$refcomp."'.price(abs($total_ttc))."  '.price($total_ttc)."'.price($solde).'
"; - print "
"; + print "
"; } else { print $langs->trans("ErrorBankAccountNotFound"); } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 1950caa1de3..c1b5b1a06b0 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -120,7 +120,7 @@ if (empty($reshook)) $object->category_transaction = GETPOST("category_transaction", 'alpha'); $object->accountancy_code = GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "alpha") : ""; - $object->subledger_account = $subledger_account; + $object->subledger_account = $subledger_account; $object->sens = GETPOST('sens'); $object->fk_project = GETPOST('fk_project', 'int'); @@ -319,7 +319,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; $bankcateg = new BankCateg($db); foreach ($bankcateg->fetchAll() as $bankcategory) { - $options[$bankcategory->id] = $bankcategory->label; + $options[$bankcategory->id] = $bankcategory->label; } /* ************************************************************************** */ @@ -361,8 +361,8 @@ if ($action == 'create') // Sens print ''; print $form->editfieldkey('Sens', 'sens', '', $object, 0, 'string', '', 1).''; - $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); - print $form->selectarray('sens', $sensarray, $sens); + $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit")); + print $form->selectarray('sens', $sensarray, $sens); print ''; // Amount @@ -396,42 +396,42 @@ if ($action == 'create') print ''."\n"; } - // Project - if (!empty($conf->projet->enabled)) - { - $formproject = new FormProjets($db); + // Project + if (!empty($conf->projet->enabled)) + { + $formproject = new FormProjets($db); - // Associated project - $langs->load("projects"); + // Associated project + $langs->load("projects"); - print ''.$langs->trans("Project").''; + print ''.$langs->trans("Project").''; - $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); + $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); - print ''; - } + print ''; + } - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - // Category - if (is_array($options) && count($options) && $conf->categorie->enabled) - { - print ''.$langs->trans("RubriquesTransactions").''; - print Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1); - print ''; - } + // Category + if (is_array($options) && count($options) && $conf->categorie->enabled) + { + print ''.$langs->trans("RubriquesTransactions").''; + print Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1); + print ''; + } // Accountancy account if (!empty($conf->accounting->enabled)) { // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code print ''.$langs->trans("AccountAccounting").''; - print ''; + print ''; print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1); - print ''; + print ''; } else // For external software { print ''.$langs->trans("AccountAccounting").''; @@ -439,24 +439,24 @@ if ($action == 'create') print ''; } - // Subledger account - if (!empty($conf->accounting->enabled)) - { - print ''.$langs->trans("SubledgerAccount").'aaaa'; - print ''; - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) - { - print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); - } else { - print ''; - } - print ''; - } else // For external software - { - print ''.$langs->trans("SubledgerAccount").''; - print ''; - print ''; - } + // Subledger account + if (!empty($conf->accounting->enabled)) + { + print ''.$langs->trans("SubledgerAccount").'aaaa'; + print ''; + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + { + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); + } else { + print ''; + } + print ''; + } else // For external software + { + print ''.$langs->trans("SubledgerAccount").''; + print ''; + print ''; + } print ''; @@ -576,12 +576,12 @@ if ($id) } print ''; - // Subledger account - print ''; - print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); - print ''; - print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); - print ''; + // Subledger account + print ''; + print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); + print ''; + print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0); + print ''; if (!empty($conf->banque->enabled)) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 165c8675960..48da6483152 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -67,7 +67,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) $sortfield = "v.datep,v.rowid"; -if (!$sortorder) $sortorder="DESC,DESC"; +if (!$sortorder) $sortorder = "DESC,DESC"; $filtre = GETPOST("filtre", 'alpha'); diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 96299886070..546805e3aaa 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -59,7 +59,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thi if ($contextpage == 'takepos') { - $_GET['optioncss'] = 'print'; + $_GET['optioncss'] = 'print'; } // Security check @@ -164,8 +164,8 @@ if ($action == "start") $object->month_close = GETPOST('closemonth', 'int'); $object->year_close = GETPOST('closeyear', 'int'); - $object->opening = price2num(GETPOST('opening', 'alpha')); - $object->posmodule = GETPOST('posmodule', 'alpha'); + $object->opening = price2num(GETPOST('opening', 'alpha')); + $object->posmodule = GETPOST('posmodule', 'alpha'); $object->posnumber = GETPOST('posnumber', 'alpha'); $db->begin(); @@ -226,32 +226,32 @@ if ($action == "valid") // validate = close "; exit; } - $action = "view"; + $action = "view"; } // Action to delete if ($action == 'confirm_delete' && !empty($permissiontodelete)) { - $object->fetch($id); + $object->fetch($id); - if (!($object->id > 0)) - { - dol_print_error('', 'Error, object must be fetched before being deleted'); - exit; - } + if (!($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } - $result = $object->delete($user); - //var_dump($result); - if ($result > 0) - { - // Delete OK - setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".$backurlforlist); - exit; - } else { - if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } + $result = $object->delete($user); + //var_dump($result); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); + exit; + } else { + if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } } @@ -307,22 +307,22 @@ if ($action == "create" || $action == "start" || $action == 'close') if ($bankid > 0) { - $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; - $sql .= " WHERE fk_account = ".$bankid; - if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; - elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; - elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; - else dol_print_error('', 'Year not defined'); + $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account = ".$bankid; + if ($syear && !$smonth) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'"; + elseif ($syear && $smonth && !$sday) $sql .= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'"; + elseif ($syear && $smonth && $sday) $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; + else dol_print_error('', 'Year not defined'); - $resql = $db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; - } else dol_print_error($db); + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; + } else dol_print_error($db); } else { setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminaltouse), null, 'errors'); - $error++; + $error++; } } @@ -370,50 +370,50 @@ if ($action == "create" || $action == "start" || $action == 'close') print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register'); print ''; - print ''; + print ''; if ($contextpage == 'takepos') print ''; - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') - { - print ''; - } elseif ($action == 'close') - { - print ''; + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } elseif ($action == 'close') + { + print ''; print ''; - } else { - print ''; - } + } else { + print ''; + } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print '
'; + print '
'.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; $disabled = 0; $prefix = 'close'; - print ''; - print ''; - print ''; + print ''; + print ''; + $array = array(); + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for ($i = 1; $i <= $numterminals; $i++) { + $array[$i] = $i; + } + $selectedposnumber = 0; $showempty = 1; + if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') + { + $selectedposnumber = 1; $showempty = 0; + } + print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); + //print ''; + print ''; // Year print '
'.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; + print '
'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; - $array = array(); - $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); - for ($i = 1; $i <= $numterminals; $i++) { - $array[$i] = $i; - } - $selectedposnumber = 0; $showempty = 1; - if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') - { - $selectedposnumber = 1; $showempty = 0; - } - print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); - //print ''; - print ''; $retstring = ''; @@ -577,36 +577,36 @@ if ($action == "create" || $action == "start" || $action == 'close') print ''; } - print ''; + print ''; } } if (empty($action) || $action == "view" || $action == "close") { - $result = $object->fetch($id); + $result = $object->fetch($id); - llxHeader('', $langs->trans("CashControl")); + llxHeader('', $langs->trans("CashControl")); - if ($result <= 0) { - print $langs->trans("ErrorRecordNotFound"); - } else { - $head = array(); - $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; - $head[0][1] = $langs->trans("CashControl"); - $head[0][2] = 'cashcontrol'; + if ($result <= 0) { + print $langs->trans("ErrorRecordNotFound"); + } else { + $head = array(); + $head[0][0] = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$object->id; + $head[0][1] = $langs->trans("CashControl"); + $head[0][2] = 'cashcontrol'; - print dol_get_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); + print dol_get_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - $morehtmlref .= '
'; + $morehtmlref = '
'; + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; print '
'; print ''; @@ -633,36 +633,36 @@ if (empty($action) || $action == "view" || $action == "close") print ''; print '
'; - print '
'; + print '
'; - print '
'; + print '
'; print '
'; - print ''; + print '
'; - print ''; + print ''; - print '"; - foreach ($arrayofpaymentmode as $key => $val) - { - print '"; - } + print '"; + foreach ($arrayofpaymentmode as $key => $val) + { + print '"; + } print "
'; - print $langs->trans("DateCreationShort"); - print ''; - print dol_print_date($object->date_creation, 'dayhour'); - print '
'; + print $langs->trans("DateCreationShort"); + print ''; + print dol_print_date($object->date_creation, 'dayhour'); + print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans($val).''; - print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); - print "
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; + print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); + print "
'.$langs->trans($val).''; + print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print "
\n"; - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - if ($action != 'close') { + if ($action != 'close') { print '
'; print ''; @@ -679,22 +679,22 @@ if (empty($action) || $action == "view" || $action == "close") print '
'; if ($contextpage != 'takepos') print '
'; - } else { - print '
'; - print ''; + } else { + print ''; + print ''; if ($contextpage == 'takepos') print ''; - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') - { - print ''; - } elseif ($action == 'close') - { - print ''; - print ''; - } else { - print ''; - } + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } elseif ($action == 'close') + { + print ''; + print ''; + } else { + print ''; + } - /* + /* print '
'; print ''; print ''; @@ -745,127 +745,127 @@ if (empty($action) || $action == "view" || $action == "close") print ''; */ - // Table to see/enter balance - if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') - { - $posmodule = $object->posmodule; - $terminalid = $object->posnumber; + // Table to see/enter balance + if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') + { + $posmodule = $object->posmodule; + $terminalid = $object->posnumber; - print '
'; + print '
'; - print '
'; - print '
'; + print '
'; + print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - print ''; - print ''; + print ''; + print ''; + print ''; + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + print ''; + print ''; - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print ''; - print ''; - // Initial amount - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + print ''; + print ''; + // Initial amount + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; - print '
'.$langs->trans("InitialBankBalance"); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'.$langs->trans("InitialBankBalance"); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'; - print $langs->trans("AmountAtEndOfPeriod"); - print '
'; + print $langs->trans("AmountAtEndOfPeriod"); + print '
'.$langs->trans("Cash"); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'.$langs->trans($val); - //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); - print '
'.$langs->trans("Cash"); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'.$langs->trans($val); + //print '
'.$langs->trans("TheoricalAmount").'
'.$langs->trans("RealAmount"); + print '
'.$langs->trans("NbOfInvoices").''; - print ''; - print $theoricalnbofinvoiceforterminal[$terminalid][$key]; - print '
'.$langs->trans("NbOfInvoices").''; + print ''; + print $theoricalnbofinvoiceforterminal[$terminalid][$key]; + print '
'.$langs->trans("TheoricalAmount").''; - print price($initialbalanceforterminal[$terminalid]['cash']).'
'; - print '
'; - if ($key == 'cash') { - $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); - print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
'; - } else { - print price($theoricalamountforterminal[$terminalid][$key]).'
'; - } - print '
'.$langs->trans("TheoricalAmount").''; + print price($initialbalanceforterminal[$terminalid]['cash']).'
'; + print '
'; + if ($key == 'cash') { + $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); + print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
'; + } else { + print price($theoricalamountforterminal[$terminalid][$key]).'
'; + } + print '
'.$langs->trans("RealAmount").''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($action == 'start') print ''; - elseif ($action == 'close') print ''; - print '
'.$langs->trans("RealAmount").''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($action == 'start') print ''; + elseif ($action == 'close') print ''; + print '
'; - print '
'; - } + print '
'; + print '
'; + } - print ''; - } - } + print ''; + } + } } // End of page diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 0f60be3c3a8..07cffb3bf2c 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -66,8 +66,8 @@ class CashControl extends CommonObject 'cash' =>array('type'=>'price', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30), 'cheque' =>array('type'=>'price', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33), 'card' =>array('type'=>'price', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36), - 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>50, 'css'=>'center'), - 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'css'=>'center'), + 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>50, 'css'=>'center'), + 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'css'=>'center'), 'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60, 'css'=>'center'), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>490), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), @@ -94,8 +94,8 @@ class CashControl extends CommonObject public $date_valid; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; /** @@ -311,8 +311,8 @@ class CashControl extends CommonObject */ public function delete(User $user, $notrigger = false) { - return $this->deleteCommon($user, $notrigger); - //return $this->deleteCommon($user, $notrigger, 1); + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); } /** @@ -357,10 +357,10 @@ class CashControl extends CommonObject * Return clicable link of object (with eventually picto) * * @param int $withpicto Add picto into link - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) @@ -381,24 +381,24 @@ class CashControl extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkclose = ''; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - /* + /* $hookmanager->initHooks(array('myobjectdao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index c474054b2b4..515067900e3 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -29,8 +29,8 @@ * \brief List of bank transactions */ -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; @@ -52,13 +52,13 @@ $sortorder = 'ASC'; $sortfield = 'b.datev,b.dateo,b.rowid'; $arrayfields = array( - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), - 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), + 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), + 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1), + 'cp.code'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), ); $syear = $cashcontrol->year_close; @@ -141,10 +141,10 @@ if ($resql) { print $langs->trans("InitialBankBalance").' - '.$langs->trans("Cash")." : ".price($cashcontrol->opening); print "
"; - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; - $param = ''; + $param = ''; // Fields title print ''; @@ -162,24 +162,24 @@ if ($resql) { $sign = 1; $cash = $bank = $cheque = $other = 0; - $totalarray = array(); - $cachebankaccount = array(); - $amountpertype = array(); - while ($i < $num) { - $objp = $db->fetch_object($resql); + $totalarray = array(); + $cachebankaccount = array(); + $amountpertype = array(); + while ($i < $num) { + $objp = $db->fetch_object($resql); - if (empty($cachebankaccount[$objp->bankid])) { - $bankaccounttmp = new Account($db); - $bankaccounttmp->fetch($objp->bankid); - $cachebankaccount[$objp->bankid] = $bankaccounttmp; - $bankaccount = $bankaccounttmp; - } else { - $bankaccount = $cachebankaccount[$objp->bankid]; - } + if (empty($cachebankaccount[$objp->bankid])) { + $bankaccounttmp = new Account($db); + $bankaccounttmp->fetch($objp->bankid); + $cachebankaccount[$objp->bankid] = $bankaccounttmp; + $bankaccount = $bankaccounttmp; + } else { + $bankaccount = $cachebankaccount[$objp->bankid]; + } - $invoicetmp->fetch($objp->facid); + $invoicetmp->fetch($objp->facid); - /*if ($first == "yes") + /*if ($first == "yes") { print ''; print ''; @@ -191,19 +191,19 @@ if ($resql) { print ''; // Ref - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; - // Date ope - print '\n"; - if (!$i) $totalarray['nbfield']++; + // Date ope + print '\n"; + if (!$i) $totalarray['nbfield']++; - // Bank account - print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; - // Type - print '\n"; - if (!$i) $totalarray['nbfield']++; + // Type + print '\n"; + if (!$i) $totalarray['nbfield']++; - // Debit - print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; + // Debit + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; - // Credit - print '\n"; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; + $totalarray['val']['totalcredfield'] += $objp->amount; + $amountpertype[$objp->code] -= $objp->amount; + } + print "\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; print ""; @@ -304,7 +304,7 @@ if ($resql) { print ""; - print ''; + print ''; $db->free($resql); } else { diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index dae7ca358ac..79182ca89bd 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -104,10 +104,10 @@ print ''; $nav = ''; if ($mode != 'sconly') { - $nav = ($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, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 1); + $nav = ($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, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 1); } else { - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 0); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $nav, '', $limit, 0); } if ($year) $param .= '&year='.$year; @@ -135,7 +135,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; @@ -200,27 +200,27 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '\n"; // Date payment print ''; - // Type payment - print ''; + // Type payment + print ''; // Account - if (!empty($conf->banque->enabled)) - { - print ''; - } + if (!empty($conf->banque->enabled)) + { + print ''; + } // Paid print ''; - print ''; // A total here has no sense - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) print ''; - print '"; + print ''; + print ''; // A total here has no sense + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) print ''; + print '"; print ""; } else { dol_print_error($db); @@ -276,11 +276,11 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").'
'; - print $invoicetmp->getNomUrl(1); - print ''; + print $invoicetmp->getNomUrl(1); + print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; - print "'; + print ''.dol_print_date($db->jdate($objp->do), "day").""; + print "'; + // Bank account + print ''; print $bankaccount->getNomUrl(1); if ($cashcontrol->posmodule == "takepos") { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber; @@ -221,36 +221,36 @@ if ($resql) { else $other += $objp->amount; } print "'; - print $objp->code; - if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; - print "'; + print $objp->code; + if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; + print "'; - if ($objp->amount < 0) { - print price($objp->amount * -1); - $totalarray['val']['totaldebfield'] += $objp->amount; - $amountpertype[$objp->code] += $objp->amount; - } - print "'; + if ($objp->amount < 0) { + print price($objp->amount * -1); + $totalarray['val']['totaldebfield'] += $objp->amount; + $amountpertype[$objp->code] += $objp->amount; + } + print "'; - if ($objp->amount > 0) { + // Credit + print ''; + if ($objp->amount > 0) { print price($objp->amount); - $totalarray['val']['totalcredfield'] += $objp->amount; - $amountpertype[$objp->code] -= $objp->amount; - } - print "
'.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $obj->num_payment.''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; - if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - $accountstatic->accountancy_number = $obj->account_number; - $accountstatic->accountancy_journal = $obj->accountancy_journal; - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else print ' '; - print ''; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else print ' '; + print ''; if ($obj->totalpaye) print price($obj->totalpaye); @@ -232,13 +232,13 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $totalpaye = $totalpaye + $obj->totalpaye; $i++; } - print '
'.$langs->trans("Total").'   '.price($totalpaye)."
'.$langs->trans("Total").'   '.price($totalpaye)."
'; - print ''; + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print '
'; + print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); @@ -289,72 +289,72 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); - print "\n"; - $var = 1; - while ($i < $num) - { - $obj = $db->fetch_object($result); + print "\n"; + $var = 1; + while ($i < $num) + { + $obj = $db->fetch_object($result); - $total = $total + $obj->amount; + $total = $total + $obj->amount; - print ''; - print ''."\n"; + print ''; + print ''."\n"; - print "\n"; + print "\n"; - print '"; + print '"; - // Ref payment + // Ref payment $tva_static->id = $obj->rowid; $tva_static->ref = $obj->rowid; - print '\n"; + print '\n"; - // Date - print '\n"; + // Date + print '\n"; - // Type payment - print ''; + // Type payment + print ''; - // Account - if (!empty($conf->banque->enabled)) - { - print ''; - } + // Account + if (!empty($conf->banque->enabled)) + { + print ''; + } - // Paid - print '"; - print "\n"; + // Paid + print '"; + print "\n"; - $i++; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '"; - print ""; + $i++; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '"; + print ""; - print "
'.dol_print_date($db->jdate($obj->dm), 'day').'
'.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."".$obj->label."'.price($obj->amount)."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm), 'day')."'.dol_print_date($db->jdate($obj->dm), 'day')."'; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $obj->num_payment.''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; - if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - $accountstatic->accountancy_number = $obj->account_number; - $accountstatic->accountancy_journal = $obj->accountancy_journal; - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else print ' '; - print ''; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else print ' '; + print ''.price($obj->amount)."
'.price($obj->amount)."
'.$langs->trans("Total").''.price($total).'    '.price($total)."
'.$langs->trans("Total").''.price($total).'    '.price($total)."
"; - $db->free($result); + print ""; + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } } } diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 69baf710b95..1a1fd42d21b 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -59,22 +59,22 @@ class Deplacement extends CommonObject public $ismultientitymanaged = 0; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * Date (dated) - * - * @var integer - */ + /** + * Date (dated) + * + * @var integer + */ public $dated; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** @@ -82,20 +82,20 @@ class Deplacement extends CommonObject */ public $fk_user; - /** - * @var string km value formatted - */ - public $km; + /** + * @var string km value formatted + */ + public $km; - /** - * @var int Thirdparty id - */ + /** + * @var int Thirdparty id + */ public $socid; - /** - * @var int Status 0=draft, 1=validated, 2=Refunded - */ - public $statut; + /** + * @var int Status 0=draft, 1=validated, 2=Refunded + */ + public $statut; public $extraparams = array(); public $statuts = array(); @@ -116,7 +116,7 @@ class Deplacement extends CommonObject */ const STATUS_REFUNDED = 2; - /** + /** * Constructor * * @param DoliDB $db Database handler @@ -125,8 +125,8 @@ class Deplacement extends CommonObject { $this->db = $db; - $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); + $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); + $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); } /** @@ -152,9 +152,9 @@ class Deplacement extends CommonObject return -1; } - $now = dol_now(); + $now = dol_now(); - $this->db->begin(); + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement ("; $sql .= "datec"; @@ -185,14 +185,14 @@ class Deplacement extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement"); - // Call trigger - $result = $this->call_trigger('DEPLACEMENT_CREATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -2; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('DEPLACEMENT_CREATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers $result = $this->update($user); if ($result > 0) @@ -226,12 +226,12 @@ class Deplacement extends CommonObject // Check parameters if (!is_numeric($this->km)) $this->km = 0; - if (empty($this->date)) - { - $this->error = 'ErrorBadParameter'; - return -1; - } - if (empty($this->type) || $this->type < 0) + if (empty($this->date)) + { + $this->error = 'ErrorBadParameter'; + return -1; + } + if (empty($this->type) || $this->type < 0) { $this->error = 'ErrorBadParameter'; return -1; @@ -270,7 +270,7 @@ class Deplacement extends CommonObject } } - /** + /** * Load an object from database * * @param int $id Id of record to load @@ -312,7 +312,7 @@ class Deplacement extends CommonObject } } - /** + /** * Delete record * * @param int $id Id of record to delete @@ -349,7 +349,7 @@ class Deplacement extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -359,7 +359,7 @@ class Deplacement extends CommonObject */ public function LibStatut($status, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0) @@ -402,15 +402,15 @@ class Deplacement extends CommonObject global $langs; $result = ''; - $label = $langs->trans("Show").': '.$this->ref; + $label = $langs->trans("Show").': '.$this->ref; - $link = ''; + $link = ''; $linkend = ''; $picto = 'trip'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.$this->ref.$linkend; return $result; @@ -425,31 +425,31 @@ class Deplacement extends CommonObject */ public function listOfTypes($active = 1) { - global $langs; + global $langs; - $ret = array(); + $ret = array(); - $sql = "SELECT id, code, label"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; - $sql .= " WHERE active = ".$active; + $sql = "SELECT id, code, label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees"; + $sql .= " WHERE active = ".$active; - dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label); - $i++; - } - } else { - dol_print_error($this->db); - } + dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label); + $i++; + } + } else { + dol_print_error($this->db); + } - return $ret; + return $ret; } /** diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 953ee78a3d6..d6ad82a4cbe 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -30,24 +30,24 @@ include_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php' */ class DeplacementStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - public $socid; - public $userid; + public $socid; + public $userid; - public $from; - public $field; - public $where; + public $from; + public $field; + public $where; /** * Constructor * * @param DoliDB $db Database handler * @param int $socid Id third party - * @param mixed $userid Id user for filter or array of user ids + * @param mixed $userid Id user for filter or array of user ids * @return void */ public function __construct($db, $socid = 0, $userid = 0) @@ -55,8 +55,8 @@ class DeplacementStats extends Stats global $conf; $this->db = $db; - $this->socid = $socid; - $this->userid = $userid; + $this->socid = $socid; + $this->userid = $userid; $object = new Deplacement($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element; @@ -69,7 +69,7 @@ class DeplacementStats extends Stats $this->where .= " AND fk_soc = ".$this->socid; } if (is_array($this->userid) && count($this->userid) > 0) $this->where .= ' AND fk_user IN ('.join(',', $this->userid).')'; - elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid; + elseif ($this->userid > 0) $this->where .= ' AND fk_user = '.$this->userid; } @@ -93,7 +93,7 @@ class DeplacementStats extends Stats * Renvoie le nombre de facture par mois pour une annee donnee * * @param string $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array of values */ public function getNbByMonth($year, $format = 0) @@ -103,7 +103,7 @@ class DeplacementStats extends Stats $sql .= " WHERE YEAR(dated) = ".$year; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
'; @@ -115,7 +115,7 @@ class DeplacementStats extends Stats * Renvoie le montant de facture par mois pour une annee donnee * * @param int $year Year to scan - * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array of values */ public function getAmountByMonth($year, $format = 0) @@ -145,7 +145,7 @@ class DeplacementStats extends Stats $sql .= " WHERE date_format(dated,'%Y') = '".$this->db->escape($year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; - $sql .= $this->db->order('dm', 'DESC'); + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -155,14 +155,14 @@ class DeplacementStats extends Stats * * @return array Array of values */ - public function getAllByYear() - { - $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql .= " FROM ".$this->from; - $sql .= " WHERE ".$this->where; - $sql .= " GROUP BY year"; - $sql .= $this->db->order('year', 'DESC'); + public function getAllByYear() + { + $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 4768e082431..86d0dd383f1 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -101,9 +101,9 @@ if ($object->id) } - print ''; + print '
'; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print '"; - print ''; - print ''; - print '
'.$langs->trans("Ref").''; @@ -113,16 +113,16 @@ if ($object->id) // Societe //print "
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
'; + print '
'; - $modulepart = 'deplacement'; - $permission = $user->rights->deplacement->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'deplacement'; + $permission = $user->rights->deplacement->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 0cea847f9ce..bcebeb128d0 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -74,20 +74,20 @@ $sql .= " ORDER BY d.type"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); - $somme[$objp->type] = $objp->km; - $nb[$objp->type] = $objp->nb; - $totalnb += $objp->nb; - $i++; - } - $db->free($result); + $somme[$objp->type] = $objp->km; + $nb[$objp->type] = $objp->nb; + $totalnb += $objp->nb; + $i++; + } + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } @@ -106,24 +106,24 @@ print "\n"; $listoftype = $tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { - $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); + $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); } if ($conf->use_javascript_ajax) { - print ''; + print ''; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totalnb ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totalnb ? 0 : 1); - print ''; + print ''; } print ''; @@ -156,46 +156,46 @@ $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { - $var = false; - $num = $db->num_rows($result); + $var = false; + $num = $db->num_rows($result); - $i = 0; + $i = 0; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) - { - $total_ttc = $totalam = $total = 0; + print '
'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + $total_ttc = $totalam = $total = 0; - $deplacementstatic = new Deplacement($db); - $userstatic = new User($db); - while ($i < $num && $i < $max) - { - $obj = $db->fetch_object($result); - $deplacementstatic->ref = $obj->rowid; - $deplacementstatic->id = $obj->rowid; - $userstatic->id = $obj->uid; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $deplacementstatic = new Deplacement($db); + $userstatic = new User($db); + while ($i < $num && $i < $max) + { + $obj = $db->fetch_object($result); + $deplacementstatic->ref = $obj->rowid; + $deplacementstatic->id = $obj->rowid; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $i++; - } - } else { - print ''; - } - print '
'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
'.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->km.''.dol_print_date($db->jdate($obj->dm), 'day').''.$deplacementstatic->LibStatut($obj->fk_statut, 3).'
'.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->km.''.dol_print_date($db->jdate($obj->dm), 'day').''.$deplacementstatic->LibStatut($obj->fk_statut, 3).'
'.$langs->trans("None").'

'; + $i++; + } + } else { + print ''.$langs->trans("None").''; + } + print '
'; } else dol_print_error($db); diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php index 08c3ca768ee..586eac52ee7 100644 --- a/htdocs/compta/deplacement/info.php +++ b/htdocs/compta/deplacement/info.php @@ -52,11 +52,11 @@ if ($id) print dol_get_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip'); - print '
'; - dol_print_object_info($object); - print '
'; + print '
'; + dol_print_object_info($object); + print '
'; - print '
'; + print ''; } // End of page diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 78c1f32556d..df18b09e2b4 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -99,11 +99,11 @@ if ($socid) $sql .= " AND s.rowid = ".$socid; if ($search_ref) $sql .= " AND d.rowid=".$search_ref; if ($search_name) { - $sql .= natural_search('u.lastname', $search_name); + $sql .= natural_search('u.lastname', $search_name); } if ($search_company) { - $sql .= natural_search('s.nom', $search_company); + $sql .= natural_search('s.nom', $search_company); } $sql .= dolSqlDateFilter("d.dated", $day, $month, $year); @@ -114,90 +114,90 @@ $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); - $i = 0; - print '
'."\n"; - print ''; - print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "d.type", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.dated", "", "&socid=$socid", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "u.lastname", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'class="right"', $sortfield, $sortorder); - print_liste_field_titre(''); - print "\n"; + $i = 0; + print ''."\n"; + print '
'; + print ""; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "d.type", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.dated", "", "&socid=$socid", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "u.lastname", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=$socid", '', $sortfield, $sortorder); + print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'class="right"', $sortfield, $sortorder); + print_liste_field_titre(''); + print "\n"; - // Filters lines - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + // Filters lines + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); - $soc = new Societe($db); - if ($obj->socid) $soc->fetch($obj->socid); + $soc = new Societe($db); + if ($obj->socid) $soc->fetch($obj->socid); - print ''; - // Id - print ''; - // Type - print ''; - // Date - print ''; - // User - print ''; + print ''; + // Id + print ''; + // Type + print ''; + // Date + print ''; + // User + print ''; - if ($obj->socid) print ''; - else print ''; + if ($obj->socid) print ''; + else print ''; - print ''; + print ''; - $tripandexpense_static->statut = $obj->fk_statut; - print ''; - print "\n"; + $tripandexpense_static->statut = $obj->fk_statut; + print ''; + print "\n"; - $i++; - } + $i++; + } - print "
'; - print ''; - print ''; - print ' '; - print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); - print ''; - print ''; - print ''; - print ''; - print ''; - // print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; + print ''; + print ''; + print ' '; + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); + print ''; + print ''; + print ''; + print ''; + print ''; + // print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'.img_object($langs->trans("ShowTrip"), "trip").' '.$obj->rowid.''.$langs->trans($obj->type).''.dol_print_date($db->jdate($obj->dd), 'day').''; - $userstatic->id = $obj->fk_user; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - print $userstatic->getNomUrl(1); - print '
'.img_object($langs->trans("ShowTrip"), "trip").' '.$obj->rowid.''.$langs->trans($obj->type).''.dol_print_date($db->jdate($obj->dd), 'day').''; + $userstatic->id = $obj->fk_user; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + print $userstatic->getNomUrl(1); + print ''.$soc->getNomUrl(1).' '.$soc->getNomUrl(1).' '.$obj->km.''.$obj->km.''.$tripandexpense_static->getLibStatut(5).'
'.$tripandexpense_static->getLibStatut(5).'
"; - print "
\n"; - $db->free($resql); + print ""; + print "\n"; + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } // End of page diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index e9a2a3a93a7..389c8d9408f 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -164,38 +164,38 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; } else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) - { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); + $px3->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode = 'depth'; + $px3->SetTitle($langs->trans("AmountAverage")); - $px3->draw($filename_avg, $fileurl_avg); + $px3->draw($filename_avg, $fileurl_avg); } @@ -203,7 +203,7 @@ if (!$mesg) $data = $stats->getAllByYear(); $arrayyears = array(); foreach ($data as $val) { - $arrayyears[$val['year']] = $val['year']; + $arrayyears[$val['year']] = $val['year']; } if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -293,11 +293,11 @@ print '
'; // Show graphs print '
'; if ($mesg) { print $mesg; } else { - print $px1->show(); + print $px1->show(); print "
\n"; print $px2->show(); - print "
\n"; - print $px3->show(); + print "
\n"; + print $px3->show(); } print '
'; diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 54234b4a10c..0e971954d56 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -79,9 +79,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -94,9 +94,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -109,9 +109,9 @@ if ($action == 'edit' && !empty($attrname)) $langs->load("members"); print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 3f85d7ba074..dbc395e5d65 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -110,9 +110,9 @@ if ($action == 'edit' && !empty($attrname)) $langs->load("members"); print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 5b1daff5913..c07eb3ac2aa 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -107,10 +107,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 539fb89e675..772a3aa680c 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -80,9 +80,9 @@ print dol_get_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* @@ -107,10 +107,10 @@ if ($action == 'create') */ if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 0d483665e40..22f836e433b 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -191,15 +191,15 @@ if (empty($reshook)) $object->titre = GETPOST('title', 'nohtml'); // deprecated $object->title = GETPOST('title', 'nohtml'); $object->note_private = GETPOST('note_private', 'restricthtml'); - $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->model_pdf = GETPOST('modelpdf', 'alpha'); + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->model_pdf = GETPOST('modelpdf', 'alpha'); $object->usenewprice = GETPOST('usenewprice', 'alpha'); $object->frequency = $frequency; $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); $object->nb_gen_max = $nb_gen_max; $object->auto_validate = GETPOST('auto_validate', 'int'); - $object->generate_pdf = GETPOST('generate_pdf', 'int'); + $object->generate_pdf = GETPOST('generate_pdf', 'int'); $object->fk_project = $projectid; $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); @@ -315,7 +315,7 @@ if (empty($reshook)) elseif ($action == 'setauto_validate' && $user->rights->facture->creer) { $object->setAutoValidate(GETPOST('auto_validate', 'int')); - } // Set generate pdf + } // Set generate pdf elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) { $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); @@ -1047,12 +1047,12 @@ if ($action == 'create') print ""; } - // Model pdf - print "".$langs->trans('Model').""; - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $list = ModelePDFFactures::liste_modeles($db); - print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); - print ""; + // Model pdf + print "".$langs->trans('Model').""; + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; + $list = ModelePDFFactures::liste_modeles($db); + print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); + print ""; print ""; @@ -1327,7 +1327,7 @@ if ($action == 'create') print ''; if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; - } + } print ''; print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { @@ -1409,30 +1409,30 @@ if ($action == 'create') print ""; print ''; - // Model pdf - print ''; - print ''; - print '
'; - print $langs->trans('Model'); - print ''; - if (($action != 'editmodelpdf') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) - print 'id.'">'.img_edit($langs->trans('SetModel'), 1).'
'; - print ''; - if ($action == 'editmodelpdf') - { - include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $list = array(); - $models = ModelePDFFactures::liste_modeles($db); - foreach ($models as $k => $model) { - $list[] = str_replace(':', '|', $k).':'.$model; - } - $select = 'select;'.implode(',', $list); - print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select); - } else { - print $object->model_pdf; - } - print ""; - print ''; + // Model pdf + print ''; + print ''; + print '
'; + print $langs->trans('Model'); + print ''; + if (($action != 'editmodelpdf') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) + print 'id.'">'.img_edit($langs->trans('SetModel'), 1).'
'; + print ''; + if ($action == 'editmodelpdf') + { + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; + $list = array(); + $models = ModelePDFFactures::liste_modeles($db); + foreach ($models as $k => $model) { + $list[] = str_replace(':', '|', $k).':'.$model; + } + $select = 'select;'.implode(',', $list); + print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select); + } else { + print $object->model_pdf; + } + print ""; + print ''; // Other attributes $cols = 2; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 74947b7c591..bd06f9b0967 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -175,19 +175,19 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. - $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); - $objectutil->socid = $socid; - $result = $objectutil->createFromClone($user, $id); - if ($result > 0) { - header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); - exit(); - } else { - $langs->load("errors"); - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } + $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); + $objectutil->socid = $socid; + $result = $objectutil->createFromClone($user, $id); + if ($result > 0) { + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); + exit(); + } else { + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } } // Change status of invoice elseif ($action == 'reopen' && $usercancreate) { $result = $object->fetch($id); @@ -352,29 +352,29 @@ if (empty($reshook)) dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) { - $object->fetch($id); - $object->retained_warranty_fk_cond_reglement = 0; // To clean property - $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); - if ($result < 0) dol_print_error($db, $object->error); + $object->fetch($id); + $object->retained_warranty_fk_cond_reglement = 0; // To clean property + $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); + if ($result < 0) dol_print_error($db, $object->error); - $old_rw_date_lim_reglement = $object->retained_warranty_date_limit; - $new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); - if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement; - if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; - $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); + $old_rw_date_lim_reglement = $object->retained_warranty_date_limit; + $new_rw_date_lim_reglement = $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + if ($new_rw_date_lim_reglement > $old_rw_date_lim_reglement) $object->retained_warranty_date_limit = $new_rw_date_lim_reglement; + if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; + $result = $object->update($user); + if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); - if ($result < 0) - dol_print_error($db, $object->error); + $object->fetch($id); + $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); + if ($result < 0) + dol_print_error($db, $object->error); } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); - if ($result < 0) - dol_print_error($db, $object->error); + $object->fetch($id); + $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); + if ($result < 0) + dol_print_error($db, $object->error); } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); @@ -419,22 +419,22 @@ if (empty($reshook)) $db->begin(); - if (! $error) { + if (!$error) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) { - $error++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } - if (! $error) { + if (!$error) { $old_date_lim_reglement = $object->date_lim_reglement; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; $result = $object->update($user); if ($result < 0) { - $error++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } @@ -875,16 +875,16 @@ if (empty($reshook)) // Total credit note and deposit $total_creditnote_and_deposit = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; - $sql .= " WHERE fk_facture = ".$object->id; - $resql = $db->query($sql); - if (!empty($resql)) { - while ($obj = $db->fetch_object($resql)) { - $total_creditnote_and_deposit += $obj->amount_ttc; - } - } else dol_print_error($db); + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_facture = ".$object->id; + $resql = $db->query($sql); + if (!empty($resql)) { + while ($obj = $db->fetch_object($resql)) { + $total_creditnote_and_deposit += $obj->amount_ttc; + } + } else dol_print_error($db); $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; @@ -1086,12 +1086,12 @@ if (empty($reshook)) $facture_source = new Facture($db); // fetch origin object if ($facture_source->fetch($object->fk_facture_source) > 0) { - if ($facture_source->type == Facture::TYPE_SITUATION) - { - $object->situation_counter = $facture_source->situation_counter; - $object->situation_cycle_ref = $facture_source->situation_cycle_ref; - $facture_source->fetchPreviousNextSituationInvoice(); - } + if ($facture_source->type == Facture::TYPE_SITUATION) + { + $object->situation_counter = $facture_source->situation_counter; + $object->situation_cycle_ref = $facture_source->situation_cycle_ref; + $facture_source->fetchPreviousNextSituationInvoice(); + } } $id = $object->create($user); @@ -1122,84 +1122,84 @@ if (empty($reshook)) if ($facture_source->type == Facture::TYPE_SITUATION) { - $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id - $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from + $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id + $line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from - if (!empty($facture_source->tab_previous_situation_invoice)) - { - // search the last standard invoice in cycle and the possible credit note between this last and facture_source - // TODO Move this out of loop of $facture_source->lines - $tab_jumped_credit_notes = array(); - $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) - { - if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) - { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { - $tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id; - } - $lineIndex--; // go to previous invoice in cycle - } - } + if (!empty($facture_source->tab_previous_situation_invoice)) + { + // search the last standard invoice in cycle and the possible credit note between this last and facture_source + // TODO Move this out of loop of $facture_source->lines + $tab_jumped_credit_notes = array(); + $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) + { + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) { + $tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id; + } + $lineIndex--; // go to previous invoice in cycle + } + } - $maxPrevSituationPercent = 0; - foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) - { - if ($prevLine->id == $source_fk_prev_id) - { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + $maxPrevSituationPercent = 0; + foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if ($prevLine->id == $source_fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - //$line->subprice = $line->subprice - $prevLine->subprice; - $line->total_ht = $line->total_ht - $prevLine->total_ht; - $line->total_tva = $line->total_tva - $prevLine->total_tva; - $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; - $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; - $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; + //$line->subprice = $line->subprice - $prevLine->subprice; + $line->total_ht = $line->total_ht - $prevLine->total_ht; + $line->total_tva = $line->total_tva - $prevLine->total_tva; + $line->total_ttc = $line->total_ttc - $prevLine->total_ttc; + $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; + $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; - } - } + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; + } + } - // prorata - $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; + // prorata + $line->situation_percent = $maxPrevSituationPercent - $line->situation_percent; - //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) - $maxPrevSituationPercent = 0; - foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { - foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) - { - if ($prevLine->fk_prev_id == $source_fk_prev_id) - { - $maxPrevSituationPercent = $prevLine->situation_percent; + // If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta) + $maxPrevSituationPercent = 0; + foreach ($tab_jumped_credit_notes as $index => $creditnoteid) { + foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine) + { + if ($prevLine->fk_prev_id == $source_fk_prev_id) + { + $maxPrevSituationPercent = $prevLine->situation_percent; - $line->total_ht -= $prevLine->total_ht; - $line->total_tva -= $prevLine->total_tva; - $line->total_ttc -= $prevLine->total_ttc; - $line->total_localtax1 -= $prevLine->total_localtax1; - $line->total_localtax2 -= $prevLine->total_localtax2; + $line->total_ht -= $prevLine->total_ht; + $line->total_tva -= $prevLine->total_tva; + $line->total_ttc -= $prevLine->total_ttc; + $line->total_localtax1 -= $prevLine->total_localtax1; + $line->total_localtax2 -= $prevLine->total_localtax2; - $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; - $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; - $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; - } - } - } + $line->multicurrency_subprice -= $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht; + $line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva; + $line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc; + } + } + } - // prorata - $line->situation_percent += $maxPrevSituationPercent; + // prorata + $line->situation_percent += $maxPrevSituationPercent; - //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; - } + //print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'
'; + } } $line->fk_facture = $object->id; @@ -1282,7 +1282,7 @@ if (empty($reshook)) $object->note_public = trim(GETPOST('note_public', 'restricthtml')); $object->note_private = trim(GETPOST('note_private', 'restricthtml')); $object->ref_client = GETPOST('ref_client'); - $object->model_pdf = GETPOST('model'); + $object->model_pdf = GETPOST('model'); $object->fk_project = GETPOST('projectid', 'int'); $object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id')); $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); @@ -1361,11 +1361,11 @@ if (empty($reshook)) $object->retained_warranty_fk_cond_reglement = 0; } - $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { - $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); - } - $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); $object->fetch_thirdparty(); @@ -1647,7 +1647,7 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - $result = $object->addline( + $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, @@ -1737,7 +1737,7 @@ if (empty($reshook)) if (empty($datefacture)) { $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")); - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, null, 'errors'); } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); @@ -1745,8 +1745,8 @@ if (empty($reshook)) if (!($_POST['situations'] > 0)) { $error++; $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceSituation")); - setEventMessages($mesg, null, 'errors'); - $action = 'create'; + setEventMessages($mesg, null, 'errors'); + $action = 'create'; } if (!$error) { @@ -1764,23 +1764,23 @@ if (empty($reshook)) // retained warranty if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { - $retained_warranty = GETPOST('retained_warranty', 'int'); - if (price2num($retained_warranty) > 0) - { - $object->retained_warranty = price2num($retained_warranty); - } + $retained_warranty = GETPOST('retained_warranty', 'int'); + if (price2num($retained_warranty) > 0) + { + $object->retained_warranty = price2num($retained_warranty); + } - if (GETPOST('retained_warranty_fk_cond_reglement', 'int') > 0) - { - $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - } + if (GETPOST('retained_warranty_fk_cond_reglement', 'int') > 0) + { + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + } - $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { - $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); - } - $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); - } + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + } foreach ($object->lines as $i => &$line) { @@ -1804,16 +1804,16 @@ if (empty($reshook)) // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée if ($line->fk_remise_except) { - $discount = new DiscountAbsolute($line->db); - $result = $discount->fetch($line->fk_remise_except); - if ($result > 0) - { - // Check if discount not already affected to another invoice - if ($discount->fk_facture_line > 0) - { - $line->fk_remise_except = 0; - } - } + $discount = new DiscountAbsolute($line->db); + $result = $discount->fetch($line->fk_remise_except); + if ($result > 0) + { + // Check if discount not already affected to another invoice + if ($discount->fk_facture_line > 0) + { + $line->fk_remise_except = 0; + } + } } } } @@ -2263,20 +2263,20 @@ if (empty($reshook)) if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) { - // in case of situation credit note - if (GETPOST('progress') >= 0) - { - $mesg = $langs->trans("CantBeNullOrPositive"); - setEventMessages($mesg, null, 'warnings'); - $error++; - $result = -1; - } elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result - { - $mesg = $langs->trans("CantBeLessThanMinPercent"); - setEventMessages($mesg, null, 'warnings'); - $error++; - $result = -1; - } + // in case of situation credit note + if (GETPOST('progress') >= 0) + { + $mesg = $langs->trans("CantBeNullOrPositive"); + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } elseif (GETPOST('progress') < $line->situation_percent) // TODO : use a modified $line->get_prev_progress($object->id) result + { + $mesg = $langs->trans("CantBeLessThanMinPercent"); + setEventMessages($mesg, null, 'warnings'); + $error++; + $result = -1; + } } elseif (GETPOST('progress') < $percent) { $mesg = '
'.$langs->trans("CantBeLessThanMinPercent").'
'; @@ -2422,13 +2422,13 @@ if (empty($reshook)) if (!$object->fetch($id) > 0) dol_print_error($db); if (GETPOST('all_progress') != "") { - $all_progress = GETPOST('all_progress', 'int'); + $all_progress = GETPOST('all_progress', 'int'); foreach ($object->lines as $line) { $percent = $line->get_prev_progress($object->id); if (floatval($all_progress) < floatval($percent)) { - $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); - setEventMessages($mesg, null, 'warnings'); + $mesg = $langs->trans("Line").' '.$i.' : '.$langs->trans("CantBeLessThanMinPercent"); + setEventMessages($mesg, null, 'warnings'); $result = -1; } else $object->update_percent($line, $_POST['all_progress']); } @@ -2439,192 +2439,192 @@ if (empty($reshook)) } // Outing situation invoice from cycle elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $usercancreate) { - $object->fetch($id, '', '', '', true); + $object->fetch($id, '', '', '', true); - if ($object->statut == Facture::STATUS_VALIDATED - && $object->type == Facture::TYPE_SITUATION - && $usercancreate - && !$objectidnext - && $object->is_last_in_cycle() - && $usercanunvalidate - ) - { - $outingError = 0; - $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle - if ($newCycle > 1) - { - // Search credit notes - $lastCycle = $object->situation_cycle_ref; - $lastSituationCounter = $object->situation_counter; - $linkedCreditNotesList = array(); + if ($object->statut == Facture::STATUS_VALIDATED + && $object->type == Facture::TYPE_SITUATION + && $usercancreate + && !$objectidnext + && $object->is_last_in_cycle() + && $usercanunvalidate + ) + { + $outingError = 0; + $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle + if ($newCycle > 1) + { + // Search credit notes + $lastCycle = $object->situation_cycle_ref; + $lastSituationCounter = $object->situation_counter; + $linkedCreditNotesList = array(); - if (count($object->tab_next_situation_invoice) > 0) { - foreach ($object->tab_next_situation_invoice as $next_invoice) { - if ($next_invoice->type == Facture::TYPE_CREDIT_NOTE - && $next_invoice->situation_counter == $object->situation_counter - && $next_invoice->fk_facture_source == $object->id - ) - { - $linkedCreditNotesList[] = $next_invoice->id; - } - } - } + if (count($object->tab_next_situation_invoice) > 0) { + foreach ($object->tab_next_situation_invoice as $next_invoice) { + if ($next_invoice->type == Facture::TYPE_CREDIT_NOTE + && $next_invoice->situation_counter == $object->situation_counter + && $next_invoice->fk_facture_source == $object->id + ) + { + $linkedCreditNotesList[] = $next_invoice->id; + } + } + } - $object->situation_cycle_ref = $newCycle; - $object->situation_counter = 1; - $object->situation_final = 0; - if ($object->update($user) > 0) - { - $errors = 0; - if (count($linkedCreditNotesList) > 0) - { - // now, credit note must follow - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; - $sql .= ' SET situation_cycle_ref='.$newCycle; - $sql .= ' , situation_final=0'; - $sql .= ' , situation_counter='.$object->situation_counter; - $sql .= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; + $object->situation_cycle_ref = $newCycle; + $object->situation_counter = 1; + $object->situation_final = 0; + if ($object->update($user) > 0) + { + $errors = 0; + if (count($linkedCreditNotesList) > 0) + { + // now, credit note must follow + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; + $sql .= ' SET situation_cycle_ref='.$newCycle; + $sql .= ' , situation_final=0'; + $sql .= ' , situation_counter='.$object->situation_counter; + $sql .= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; - $resql = $db->query($sql); - if (!$resql) $errors++; + $resql = $db->query($sql); + if (!$resql) $errors++; - // Change each progression persent on each lines - foreach ($object->lines as $line) - { - // no traitement for special product - if ($line->product_type == 9) continue; + // Change each progression persent on each lines + foreach ($object->lines as $line) + { + // no traitement for special product + if ($line->product_type == 9) continue; - if (!empty($object->tab_previous_situation_invoice)) - { - // search the last invoice in cycle - $lineIndex = count($object->tab_previous_situation_invoice) - 1; - $searchPreviousInvoice = true; - while ($searchPreviousInvoice) - { - if ($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) - { - $searchPreviousInvoice = false; // find, exit; - break; - } else { - $lineIndex--; // go to previous invoice in cycle - } - } + if (!empty($object->tab_previous_situation_invoice)) + { + // search the last invoice in cycle + $lineIndex = count($object->tab_previous_situation_invoice) - 1; + $searchPreviousInvoice = true; + while ($searchPreviousInvoice) + { + if ($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + { + $searchPreviousInvoice = false; // find, exit; + break; + } else { + $lineIndex--; // go to previous invoice in cycle + } + } - $maxPrevSituationPercent = 0; - foreach ($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) - { - if ($prevLine->id == $line->fk_prev_id) - { - $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); - } - } + $maxPrevSituationPercent = 0; + foreach ($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + { + if ($prevLine->id == $line->fk_prev_id) + { + $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); + } + } - $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; + $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; - if ($line->update() < 0) $errors++; - } - } - } + if ($line->update() < 0) $errors++; + } + } + } - if (!$errors) - { - setEventMessages($langs->trans('Updated'), '', 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - } else { - setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); - } - } else { - setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); - } - } else { - setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); - } - } + if (!$errors) + { + setEventMessages($langs->trans('Updated'), '', 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + } else { + setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); + } + } else { + setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors'); + } + } else { + setEventMessages($langs->trans('ErrorFindNextSituationInvoice'), array(), 'errors'); + } + } } // add lines from objectlinked elseif ($action == 'import_lines_from_object' - && $usercancreate - && $object->statut == Facture::STATUS_DRAFT - && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) + && $usercancreate + && $object->statut == Facture::STATUS_DRAFT + && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) { - $fromElement = GETPOST('fromelement'); - $fromElementid = GETPOST('fromelementid'); - $importLines = GETPOST('line_checkbox'); + $fromElement = GETPOST('fromelement'); + $fromElementid = GETPOST('fromelementid'); + $importLines = GETPOST('line_checkbox'); - if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) - { - if ($fromElement == 'commande') - { - dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'OrderLine'; - } elseif ($fromElement == 'propal') - { - dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); - $lineClassName = 'PropaleLigne'; - } - $nextRang = count($object->lines) + 1; - $importCount = 0; - $error = 0; - foreach ($importLines as $lineId) - { - $lineId = intval($lineId); - $originLine = new $lineClassName($db); - if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) - { - $originLine->fetch_optionals(); - $desc = $originLine->desc; - $pu_ht = $originLine->subprice; - $qty = $originLine->qty; - $txtva = $originLine->tva_tx; - $txlocaltax1 = $originLine->localtax1_tx; - $txlocaltax2 = $originLine->localtax2_tx; - $fk_product = $originLine->fk_product; - $remise_percent = $originLine->remise_percent; - $date_start = $originLine->date_start; - $date_end = $originLine->date_end; - $ventil = 0; - $info_bits = $originLine->info_bits; - $fk_remise_except = $originLine->fk_remise_except; - $price_base_type = 'HT'; - $pu_ttc = 0; - $type = $originLine->product_type; - $rang = $nextRang++; - $special_code = $originLine->special_code; - $origin = $originLine->element; - $origin_id = $originLine->id; - $fk_parent_line = 0; - $fk_fournprice = $originLine->fk_fournprice; - $pa_ht = $originLine->pa_ht; - $label = $originLine->label; - $array_options = $originLine->array_options; - if ($object->type == Facture::TYPE_SITUATION) { - $situation_percent = 0; - } else { - $situation_percent = 100; - } - $fk_prev_id = ''; - $fk_unit = $originLine->fk_unit; - $pu_ht_devise = $originLine->multicurrency_subprice; + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + { + if ($fromElement == 'commande') + { + dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'OrderLine'; + } elseif ($fromElement == 'propal') + { + dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); + $lineClassName = 'PropaleLigne'; + } + $nextRang = count($object->lines) + 1; + $importCount = 0; + $error = 0; + foreach ($importLines as $lineId) + { + $lineId = intval($lineId); + $originLine = new $lineClassName($db); + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + { + $originLine->fetch_optionals(); + $desc = $originLine->desc; + $pu_ht = $originLine->subprice; + $qty = $originLine->qty; + $txtva = $originLine->tva_tx; + $txlocaltax1 = $originLine->localtax1_tx; + $txlocaltax2 = $originLine->localtax2_tx; + $fk_product = $originLine->fk_product; + $remise_percent = $originLine->remise_percent; + $date_start = $originLine->date_start; + $date_end = $originLine->date_end; + $ventil = 0; + $info_bits = $originLine->info_bits; + $fk_remise_except = $originLine->fk_remise_except; + $price_base_type = 'HT'; + $pu_ttc = 0; + $type = $originLine->product_type; + $rang = $nextRang++; + $special_code = $originLine->special_code; + $origin = $originLine->element; + $origin_id = $originLine->id; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; + $pa_ht = $originLine->pa_ht; + $label = $originLine->label; + $array_options = $originLine->array_options; + if ($object->type == Facture::TYPE_SITUATION) { + $situation_percent = 0; + } else { + $situation_percent = 100; + } + $fk_prev_id = ''; + $fk_unit = $originLine->fk_unit; + $pu_ht_devise = $originLine->multicurrency_subprice; - $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit, $pu_ht_devise); + $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit, $pu_ht_devise); - if ($res > 0) { - $importCount++; - } else { - $error++; - } - } else { - $error++; - } - } + if ($res > 0) { + $importCount++; + } else { + $error++; + } + } else { + $error++; + } + } - if ($error) - { - setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); - } - } + if ($error) + { + setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); + } + } } // Actions when printing a doc from card @@ -2885,7 +2885,7 @@ if ($action == 'create') $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) { - $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); + $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); } print info_admin($text, 0, 0, 0).'
'; } @@ -3161,26 +3161,26 @@ if ($action == 'create') print '
'; } } else { - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - print '
'; - $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); - print $desc; - print '
'; + if (!empty($conf->global->INVOICE_USE_SITUATION)) + { + print '
'; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; - print '
'; - $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); - print $desc; - print '
'; - } + print '
'; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + print $desc; + print '
'; + } - print '
'; + print '
'; $tmp = ' '; $text = ' '; $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; @@ -3263,8 +3263,8 @@ if ($action == 'create') print '
    0 ? 'checked' : '').' /> "; print '
'; - print '
'; - } + print '
'; + } } else { print '
'; if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp = ' '; @@ -3291,17 +3291,17 @@ if ($action == 'create') if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf { - // Add auto select default document model - $listtType = array(Facture::TYPE_STANDARD, Facture::TYPE_REPLACEMENT, Facture::TYPE_CREDIT_NOTE, Facture::TYPE_DEPOSIT, Facture::TYPE_SITUATION); - $jsListType = ''; - foreach ($listtType as $type) - { - $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; - $curent = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; - $jsListType .= (!empty($jsListType) ? ',' : '').'"'.$type.'":"'.$curent.'"'; - } + // Add auto select default document model + $listtType = array(Facture::TYPE_STANDARD, Facture::TYPE_REPLACEMENT, Facture::TYPE_CREDIT_NOTE, Facture::TYPE_DEPOSIT, Facture::TYPE_SITUATION); + $jsListType = ''; + foreach ($listtType as $type) + { + $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; + $curent = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + $jsListType .= (!empty($jsListType) ? ',' : '').'"'.$type.'":"'.$curent.'"'; + } - print ''."\n"; } - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print '
'; - print '
'; - print $langs->trans("Type").':   '; - print '
'; - print ''; - print '   '; - print ''; - print '
'; - print "
\n"; + print '
'; + print '
'; + print $langs->trans("Type").':   '; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + print "
\n"; - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print ''; + print '
'; - print ""; - print ''; + print ""; + print ''; - print ''; + print ''; // Label if ($refund == 1) { @@ -268,14 +268,14 @@ if ($action == 'create') // Amount print ''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) + { print ''; - } + print ''; + } - // Type payment + // Type payment print '\n"; @@ -286,22 +286,22 @@ if ($action == 'create') print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print ''."\n"; - // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - print '
'.$langs->trans("DatePayment").''; - print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); - print '
'.$langs->trans("DatePayment").''; + print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; - print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); - print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); + print '
'.$langs->trans("Amount").'
'.$langs->trans("BankAccount").''; $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 2); // List of bank account available - print '
'.$langs->trans("PaymentMode").''; $form->select_types_paiements(GETPOST("type_payment"), "type_payment"); print "
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); print '
'; print ''; print '     '; - print ''; + print ''; print '
'; - print '
'; + print ''; } // View mode diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 5f661609e52..b767e78294d 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -56,45 +56,45 @@ class Tva extends CommonObject public $num_payment; /** - * @var string label - */ - public $label; + * @var string label + */ + public $label; - /** - * @var int ID - */ + /** + * @var int ID + */ public $fk_bank; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_creat; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; $error = 0; $now = dol_now(); @@ -123,7 +123,7 @@ class Tva extends CommonObject $sql .= "fk_bank,"; $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; @@ -136,41 +136,41 @@ class Tva extends CommonObject $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); - // Call trigger - $result = $this->call_trigger('TVA_CREATE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('TVA_CREATE', $user); + if ($result < 0) $error++; + // End call triggers - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { $this->db->rollback(); return -1; - } - } else { + } + } else { $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; - } - } + } + } - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - public function update($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; @@ -188,7 +188,7 @@ class Tva extends CommonObject $this->db->begin(); // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; $sql .= " tms='".$this->db->idate($this->tms)."',"; $sql .= " datep='".$this->db->idate($this->datep)."',"; $sql .= " datev='".$this->db->idate($this->datev)."',"; @@ -198,46 +198,46 @@ class Tva extends CommonObject $sql .= " fk_bank=".$this->fk_bank.","; $sql .= " fk_user_creat=".$this->fk_user_creat.","; $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id).""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = "Error ".$this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = "Error ".$this->db->lasterror(); + $error++; + } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('TVA_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - } + // Call trigger + $result = $this->call_trigger('TVA_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $user = null) - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $user = null) + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.tms,"; @@ -255,20 +255,20 @@ class Tva extends CommonObject $sql .= " b.fk_type,"; $sql .= " b.rappro"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; - $sql .= " WHERE t.rowid = ".$id; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; $this->tms = $this->db->jdate($obj->tms); $this->datep = $this->db->jdate($obj->datep); $this->datev = $this->db->jdate($obj->datev); @@ -283,23 +283,23 @@ class Tva extends CommonObject $this->fk_account = $obj->fk_account; $this->fk_type = $obj->fk_type; $this->rappro = $obj->rappro; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ public function delete($user) { global $conf, $langs; @@ -328,11 +328,11 @@ class Tva extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ public function initAsSpecimen() { @@ -350,154 +350,154 @@ class Tva extends CommonObject } - /** - * Balance of VAT - * - * @param int $year Year - * @return double Amount - */ - public function solde($year = 0) - { + /** + * Balance of VAT + * + * @param int $year Year + * @return double Amount + */ + public function solde($year = 0) + { - $reglee = $this->tva_sum_reglee($year); + $reglee = $this->tva_sum_reglee($year); - $payee = $this->tva_sum_payee($year); - $collectee = $this->tva_sum_collectee($year); + $payee = $this->tva_sum_payee($year); + $collectee = $this->tva_sum_collectee($year); - $solde = $reglee - ($collectee - $payee); + $solde = $reglee - ($collectee - $payee); - return $solde; - } + return $solde; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total of the VAT from invoices emitted by the thirdparty. - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_collectee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Total of the VAT from invoices emitted by the thirdparty. + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_collectee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.tva) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; - if ($year) - { - $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; - } + $sql = "SELECT sum(f.tva) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1"; + if ($year) + { + $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); $ret = $obj->amount; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * VAT payed - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_payee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * VAT payed + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_payee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.total_tva) as total_tva"; - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - if ($year) - { - $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; - } + $sql = "SELECT sum(f.total_tva) as total_tva"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; + if ($year) + { + $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->total_tva; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->total_tva; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Total of the VAT payed - * - * @param int $year Year - * @return double Amount - */ - public function tva_sum_reglee($year = 0) - { - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Total of the VAT payed + * + * @param int $year Year + * @return double Amount + */ + public function tva_sum_reglee($year = 0) + { + // phpcs:enable - $sql = "SELECT sum(f.amount) as amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; + $sql = "SELECT sum(f.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; - if ($year) - { - $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' "; - } + if ($year) + { + $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' "; + } - $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $ret = $obj->amount; - $this->db->free($result); - return $ret; - } else { - $this->db->free($result); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $ret = $obj->amount; + $this->db->free($result); + return $ret; + } else { + $this->db->free($result); return 0; - } - } else { - print $this->db->lasterror(); - return -1; - } - } + } + } else { + print $this->db->lasterror(); + return -1; + } + } - /** - * Create in database - * + /** + * Create in database + * * @param User $user Object user that insert * @return int <0 if KO, rowid in tva table if OK - */ - public function addPayment($user) - { - global $conf, $langs; + */ + public function addPayment($user) + { + global $conf, $langs; - $this->db->begin(); + $this->db->begin(); - // Clean parameters - $this->amount = price2num(trim($this->amount)); - $this->label = trim($this->label); + // Clean parameters + $this->amount = price2num(trim($this->amount)); + $this->label = trim($this->label); $this->note = trim($this->note); $this->num_payment = trim($this->num_payment); $this->fk_bank = (int) $this->fk_bank; @@ -505,81 +505,81 @@ class Tva extends CommonObject $this->fk_user_modif = (int) $this->fk_user_modif; if (empty($this->datec)) $this->datec = dol_now(); - // Check parameters + // Check parameters if (!$this->label) { $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } - if ($this->amount == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -4; - } - if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -5; - } - if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -5; - } + if ($this->amount == '') + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -4; + } + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -5; + } + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + { + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -5; + } - // Insert into llx_tva - $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva ("; - $sql .= "datec"; - $sql .= ", datep"; - $sql .= ", datev"; + // Insert into llx_tva + $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva ("; + $sql .= "datec"; + $sql .= ", datep"; + $sql .= ", datev"; $sql .= ", amount"; $sql .= ", fk_typepayment"; $sql .= ", num_payment"; if ($this->note) $sql .= ", note"; - if ($this->label) $sql .= ", label"; - $sql .= ", fk_user_creat"; + if ($this->label) $sql .= ", label"; + $sql .= ", fk_user_creat"; $sql .= ", fk_bank"; $sql .= ", entity"; $sql .= ") "; - $sql .= " VALUES ("; - $sql .= " '".$this->db->idate($this->datec)."'"; - $sql .= ", '".$this->db->idate($this->datep)."'"; - $sql .= ", '".$this->db->idate($this->datev)."'"; + $sql .= " VALUES ("; + $sql .= " '".$this->db->idate($this->datec)."'"; + $sql .= ", '".$this->db->idate($this->datep)."'"; + $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", ".$this->amount; - $sql .= ", '".$this->db->escape($this->type_payment)."'"; + $sql .= ", '".$this->db->escape($this->type_payment)."'"; $sql .= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; - if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; - $sql .= ", '".$this->db->escape($user->id)."'"; + if ($this->label) $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($user->id)."'"; $sql .= ", NULL"; $sql .= ", ".$conf->entity; - $sql .= ")"; + $sql .= ")"; dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat' + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat' - // Call trigger - //XXX: Should be done just befor commit no ? - $result = $this->call_trigger('TVA_ADDPAYMENT', $user); - if ($result < 0) - { - $this->id = 0; - $ok = 0; - } - // End call triggers + // Call trigger + //XXX: Should be done just befor commit no ? + $result = $this->call_trigger('TVA_ADDPAYMENT', $user); + if ($result < 0) + { + $this->id = 0; + $ok = 0; + } + // End call triggers - if ($this->id > 0) - { - $ok = 1; + if ($this->id > 0) + { + $ok = 1; if (!empty($conf->banque->enabled) && !empty($this->amount)) - { - // Insert into llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + { + // Insert into llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); + $acc = new Account($this->db); $result = $acc->fetch($this->accountid); if ($result <= 0) dol_print_error($this->db); @@ -589,23 +589,23 @@ class Tva extends CommonObject $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user); } - // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction - if ($bank_line_id > 0) + // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction + if ($bank_line_id > 0) { - $this->update_fk_bank($bank_line_id); - } else { + $this->update_fk_bank($bank_line_id); + } else { $this->error = $acc->error; $ok = 0; } - // Update links - $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat"); - if ($result < 0) - { - $this->error = $acc->error; - $ok = 0; - } - } + // Update links + $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat"); + if ($result < 0) + { + $this->error = $acc->error; + $ok = 0; + } + } if ($ok) { @@ -615,27 +615,27 @@ class Tva extends CommonObject $this->db->rollback(); return -3; } - } else { - $this->db->rollback(); - return -2; - } - } else { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - } + } else { + $this->db->rollback(); + return -2; + } + } else { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Update link between payment tva and line generate into llx_bank - * - * @param int $id_bank Id bank account + * + * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK - */ + */ public function update_fk_bank($id_bank) { - // phpcs:enable + // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank; $sql .= ' WHERE rowid = '.(int) $this->id; $result = $this->db->query($sql); @@ -653,8 +653,8 @@ class Tva extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option link option - * @param int $notooltip 1=Disable tooltip - * @param string $morecss More CSS + * @param int $notooltip 1=Disable tooltip + * @param string $morecss More CSS * @return string Chaine with URL */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '') @@ -669,23 +669,23 @@ class Tva extends CommonObject $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; - $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; - $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowMyObject"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + $linkclose = ''; + if (empty($notooltip)) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - $linkstart = ''; - $linkend = ''; + $linkstart = ''; + $linkend = ''; $picto = 'payment'; @@ -698,34 +698,34 @@ class Tva extends CommonObject } /** - * Return amount of payments already done - * - * @return int Amount of payment already done, <0 if KO - */ - public function getSommePaiement() - { - $table = 'paiementcharge'; - $field = 'fk_charge'; + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + public function getSommePaiement() + { + $table = 'paiementcharge'; + $field = 'fk_charge'; - $sql = 'SELECT sum(amount) as amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$table; - $sql .= ' WHERE '.$field.' = '.$this->id; + $sql = 'SELECT sum(amount) as amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; - dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $amount = 0; + dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $amount = 0; - $obj = $this->db->fetch_object($resql); - if ($obj) $amount = $obj->amount ? $obj->amount : 0; + $obj = $this->db->fetch_object($resql); + if ($obj) $amount = $obj->amount ? $obj->amount : 0; - $this->db->free($resql); - return $amount; - } else { - return -1; - } - } + $this->db->free($resql); + return $amount; + } else { + return -1; + } + } /** * Informations of vat payment object @@ -780,10 +780,10 @@ class Tva extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -791,11 +791,11 @@ class Tva extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - return ''; - } + return ''; + } } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index a91d637c39d..cd0bbdd6c7a 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -53,10 +53,10 @@ $year = GETPOST("year", "int"); if (empty($year)) { $year_current = $current_date['year']; - $year_start = $year_current; + $year_start = $year_current; } else { - $year_current = $year; - $year_start = $year; + $year_current = $year; + $year_start = $year; } $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); @@ -64,35 +64,35 @@ $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endda if (empty($date_start) || empty($date_end)) // We define date_start and date_end { $q = GETPOST("q", "int"); - if (empty($q)) - { - if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { - if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter - $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); - $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat - if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { - if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year - $year_start--; - } - } else { - if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year - $year_start--; - } - } - $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); - $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month - $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); - $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; - } - } - } else { - if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } - if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } - if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } - if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } - } + if (empty($q)) + { + if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { + if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year + $year_start--; + } + } else { + if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year + $year_start--; + } + } + $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); + $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; + } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } + } + } else { + if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } + if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } + if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } + if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); } + } } $min = price2num(GETPOST("min", "alpha")); @@ -130,12 +130,12 @@ $morequerystring = ''; $listofparams = array('date_startmonth', 'date_startyear', 'date_startday', 'date_endmonth', 'date_endyear', 'date_endday'); foreach ($listofparams as $param) { - if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); + if (GETPOST($param) != '') $morequerystring .= ($morequerystring ? '&' : '').$param.'='.GETPOST($param); } $special_report = false; if (isset($_REQUEST['extra_report']) && $_REQUEST['extra_report'] == 1) { - $special_report = true; + $special_report = true; } llxHeader('', $langs->trans("VATReport"), '', '', 0, 0, '', '', $morequerystring); @@ -158,18 +158,18 @@ $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '. $prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { - $prevquarter--; + $prevquarter--; } else { - $prevquarter = 4; - $prevyear--; + $prevquarter = 4; + $prevyear--; } $nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { - $nextquarter++; + $nextquarter++; } else { - $nextquarter = 1; - $nextyear++; + $nextquarter = 1; + $nextyear++; } $builddate = dol_now(); @@ -178,7 +178,7 @@ if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description .= $langs->t if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description .= '
'.$langs->trans("RulesVATDueServices"); if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description .= '
'.$langs->trans("RulesVATInServices"); if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $description .= '
'.$langs->trans("DepositsAreNotIncluded"); + $description .= '
'.$langs->trans("DepositsAreNotIncluded"); } if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); @@ -186,15 +186,15 @@ if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs $description .= ($description ? '
' : '').$fsearch; if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT)) { - $description .= '
'; - $description .= ' '; - $description .= $langs->trans('SimpleReport'); - $description .= ''; - $description .= '
'; - $description .= ' '; - $description .= $langs->trans('AddExtraReport'); - $description .= ''; - $description .= '
'; + $description .= '
'; + $description .= ' '; + $description .= $langs->trans('SimpleReport'); + $description .= ''; + $description .= '
'; + $description .= ' '; + $description .= $langs->trans('AddExtraReport'); + $description .= ''; + $description .= '
'; } $elementcust = $langs->trans("CustomersInvoices"); @@ -202,13 +202,13 @@ $productcust = $langs->trans("Description"); $namerate = $langs->trans("VATRate"); $amountcust = $langs->trans("AmountHT"); if ($mysoc->tva_assuj) { - $vatcust .= ' ('.$langs->trans("StatusToPay").')'; + $vatcust .= ' ('.$langs->trans("StatusToPay").')'; } $elementsup = $langs->trans("SuppliersInvoices"); $productsup = $langs->trans("Description"); $amountsup = $langs->trans("AmountHT"); if ($mysoc->tva_assuj) { - $vatsup .= ' ('.$langs->trans("ToGetBack").')'; + $vatsup .= ' ('.$langs->trans("ToGetBack").')'; } report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); @@ -231,529 +231,529 @@ $x_paye = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'bu if (!is_array($x_coll) || !is_array($x_paye)) { - $langs->load("errors"); - if ($x_coll == -1) { - print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; - } elseif ($x_coll == -2) { - print ''.$langs->trans("FeatureNotYetAvailable").''; - } else { - print ''.$langs->trans("Error").''; - } + $langs->load("errors"); + if ($x_coll == -1) { + print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; + } elseif ($x_coll == -2) { + print ''.$langs->trans("FeatureNotYetAvailable").''; + } else { + print ''.$langs->trans("Error").''; + } } else { - $x_both = array(); - //now, from these two arrays, get another array with one rate per line - foreach (array_keys($x_coll) as $my_coll_thirdpartyid) - { - $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; - $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; - $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; - $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; - $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; - $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); - foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { - $invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id]; - $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id]; - $invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id]; - $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); - $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( - 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], - 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], - 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], - 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], - 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], - 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], - 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], - 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], - 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], - 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], - 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], - 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], - 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1, '', 12) - ); - } - } - // tva paid - foreach (array_keys($x_paye) as $my_paye_thirdpartyid) { - $x_both[$my_paye_thirdpartyid]['paye']['totalht'] = $x_paye[$my_paye_thirdpartyid]['totalht']; - $x_both[$my_paye_thirdpartyid]['paye']['vat'] = $x_paye[$my_paye_thirdpartyid]['vat']; - if (!isset($x_both[$my_paye_thirdpartyid]['coll']['totalht'])) { - $x_both[$my_paye_thirdpartyid]['coll']['totalht'] = 0; - $x_both[$my_paye_thirdpartyid]['coll']['vat'] = 0; - } - $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; - $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach (array_keys($x_coll) as $my_coll_thirdpartyid) + { + $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; + $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; + $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; + $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; + $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; + $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); + foreach ($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { + $invoice_customer->id = $x_coll[$my_coll_thirdpartyid]['facid'][$id]; + $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid]['facnum'][$id]; + $invoice_customer->type = $x_coll[$my_coll_thirdpartyid]['type'][$id]; + $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); + $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], + 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], + 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], + 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], + 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], + 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], + 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_customer->getNomUrl(1, '', 12) + ); + } + } + // tva paid + foreach (array_keys($x_paye) as $my_paye_thirdpartyid) { + $x_both[$my_paye_thirdpartyid]['paye']['totalht'] = $x_paye[$my_paye_thirdpartyid]['totalht']; + $x_both[$my_paye_thirdpartyid]['paye']['vat'] = $x_paye[$my_paye_thirdpartyid]['vat']; + if (!isset($x_both[$my_paye_thirdpartyid]['coll']['totalht'])) { + $x_both[$my_paye_thirdpartyid]['coll']['totalht'] = 0; + $x_both[$my_paye_thirdpartyid]['coll']['vat'] = 0; + } + $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; + $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); - foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) - { - // ExpenseReport - if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') - { - $expensereport->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; - $expensereport->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; - $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; + foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') + { + $expensereport->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $expensereport->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $expensereport->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; - $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$expensereport->getNomUrl(1) - ); - } else { - $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; - $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; - $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; - $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); - $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( - 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], - 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], - 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], - 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], - 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], - 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], - 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], - 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), - 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), - 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], - 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], - 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], - 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], - 'company_link'=>$company_static->getNomUrl(1, '', 20), - 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], - 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], - 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), - 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1, '', 12) - ); - } - } - } - //now we have an array (x_both) indexed by rates for coll and paye + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$expensereport->getNomUrl(1) + ); + } else { + $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid]['type'][$id]; + $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], + 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1, '', 20), + 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_supplier->getNomUrl(1, '', 12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye - //print table headers for this quadri - incomes first + //print table headers for this quadri - incomes first - $x_coll_sum = 0; - $x_coll_ht = 0; - $x_paye_sum = 0; - $x_paye_ht = 0; + $x_coll_sum = 0; + $x_coll_ht = 0; + $x_paye_sum = 0; + $x_paye_ht = 0; - $span = $columns; - if ($modetax != 1) $span += 2; + $span = $columns; + if ($modetax != 1) $span += 2; - //print ''..')'; + //print ''..')'; - // Customers invoices - print ''; - print ''.$elementcust.''; - print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; - print ''.$namerate.''; - print ''.$productcust.''; - if ($modetax != 1) - { - print ''.$amountcust.''; - print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; - } - print ''.$langs->trans("AmountHTVATRealReceived").''; - print ''.$vatcust.''; - print ''; + // Customers invoices + print ''; + print ''.$elementcust.''; + print ''.$langs->trans("DateInvoice").''; + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; + else print ''; + print ''.$namerate.''; + print ''.$productcust.''; + if ($modetax != 1) + { + print ''.$amountcust.''; + print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; + } + print ''.$langs->trans("AmountHTVATRealReceived").''; + print ''.$vatcust.''; + print ''; - $action = "tvadetail"; - $parameters["mode"] = $modetax; - $parameters["start"] = $date_start; - $parameters["end"] = $date_end; - $parameters["type"] = 'vat'; + $action = "tvadetail"; + $parameters["mode"] = $modetax; + $parameters["start"] = $date_start; + $parameters["end"] = $date_end; + $parameters["type"] = 'vat'; - $object = array(&$x_coll, &$x_paye, &$x_both); - // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array - $hookmanager->initHooks(array('externalbalance')); - $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $object = array(&$x_coll, &$x_paye, &$x_both); + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - foreach (array_keys($x_coll) as $thirdparty_id) { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; + foreach (array_keys($x_coll) as $thirdparty_id) { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) - { - if (is_array($x_both[$thirdparty_id]['coll']['detail'])) - { - // VAT Rate - print ""; - print ''; - if (is_numeric($thirdparty_id)) { - $company_static->fetch($thirdparty_id); - print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); - } else { - $tmpid = preg_replace('/userid_/', '', $thirdparty_id); - $user_static->fetch($tmpid); - print $langs->trans("User").': '.$user_static->getNomUrl(1); - } - print ''; - print ''."\n"; + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) + { + if (is_array($x_both[$thirdparty_id]['coll']['detail'])) + { + // VAT Rate + print ""; + print ''; + if (is_numeric($thirdparty_id)) { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } else { + $tmpid = preg_replace('/userid_/', '', $thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print ''; + print ''."\n"; - foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - print ''; + print ''; - // Ref - print ''.$fields['link'].''; + // Ref + print ''.$fields['link'].''; - // Invoice date - print ''.dol_print_date($fields['datef'], 'day').''; + // Invoice date + print ''.dol_print_date($fields['datef'], 'day').''; - // Payment date - if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { - print ''.dol_print_date($fields['datep'], 'day').''; - } else { - print ''; - } + // Payment date + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') { + print ''.dol_print_date($fields['datep'], 'day').''; + } else { + print ''; + } - // Rate - print ''.$fields['drate'].''; + // Rate + print ''.$fields['drate'].''; - // Description - print ''; - if ($fields['pid']) { - $product_static->id = $fields['pid']; - $product_static->ref = $fields['pref']; - $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - } - } else { - if ($type) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { - if ($reg[1] == 'DEPOSIT') { - $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); - } elseif ($reg[1] == 'CREDIT_NOTE') { - $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); - } else { - $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); - } - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + // Description + print ''; + if ($fields['pid']) { + $product_static->id = $fields['pid']; + $product_static->ref = $fields['pref']; + $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + } + } else { + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); - } - print ''; + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print ''; - // Total HT - if ($modetax != 1) { - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - } + // Total HT + if ($modetax != 1) { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + } - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) { - print ''; - //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) { - $payment_static->id = $fields['payment_id']; - print $payment_static->getNomUrl(2); - } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { - print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - print price(price2num($fields['payment_amount'], 'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; - } - } - print ''; - } + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) { + print ''; + //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) { + $payment_static->id = $fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; + } + } + print ''; + } - // Total collected - print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT'), 1); - print ''; + // Total collected + print ''; + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); + print ''; - // VAT - print ''; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - print price(price2num($temp_vat, 'MT'), 1); - //print price($fields['vat']); - print ''; - print ''; + // VAT + print ''; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print ''; + print ''; - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; - } - } - // Total customers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; - print ''; - } - } + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + // Total customers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''; + } + } - if (count($x_coll) == 0) // Show a total ine if nothing shown - { - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; - } + if (count($x_coll) == 0) // Show a total ine if nothing shown + { + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - // Blank line - print ' '; + // Blank line + print ' '; - // Print table headers for this quadri - expenses now - print ''; - print ''.$elementsup.''; - print ''.$langs->trans("DateInvoice").''; - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; - else print ''; - print ''.$namesup.''; - print ''.$productsup.''; - if ($modetax != 1) { - print ''.$amountsup.''; - print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; - } - print ''.$langs->trans("AmountHTVATRealPaid").''; - print ''.$vatsup.''; - print ''."\n"; + // Print table headers for this quadri - expenses now + print ''; + print ''.$elementsup.''; + print ''.$langs->trans("DateInvoice").''; + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''.$langs->trans("DatePayment").''; + else print ''; + print ''.$namesup.''; + print ''.$productsup.''; + if ($modetax != 1) { + print ''.$amountsup.''; + print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; + } + print ''.$langs->trans("AmountHTVATRealPaid").''; + print ''.$vatsup.''; + print ''."\n"; - foreach (array_keys($x_paye) as $thirdparty_id) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; + foreach (array_keys($x_paye) as $thirdparty_id) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) { - if (is_array($x_both[$thirdparty_id]['paye']['detail'])) { - print ""; - print ''; - if (is_numeric($thirdparty_id)) { - $company_static->fetch($thirdparty_id); - print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); - } else { - $tmpid = preg_replace('/userid_/', '', $thirdparty_id); - $user_static->fetch($tmpid); - print $langs->trans("User").': '.$user_static->getNomUrl(1); - } - print ''; - print ''."\n"; + if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) { + if (is_array($x_both[$thirdparty_id]['paye']['detail'])) { + print ""; + print ''; + if (is_numeric($thirdparty_id)) { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } else { + $tmpid = preg_replace('/userid_/', '', $thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print ''; + print ''."\n"; - foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - print ''; + print ''; - // Ref - print ''.$fields['link'].''; + // Ref + print ''.$fields['link'].''; - // Invoice date - print ''.dol_print_date($fields['datef'], 'day').''; + // Invoice date + print ''.dol_print_date($fields['datef'], 'day').''; - // Payment date - if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { - print ''.dol_print_date($fields['datep'], 'day').''; - } else { - print ''; - } + // Payment date + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') { + print ''.dol_print_date($fields['datep'], 'day').''; + } else { + print ''; + } - // Company name - print ''.$fields['company_link'].''; + // Company name + print ''.$fields['company_link'].''; - // Description - print ''; - if ($fields['pid']) { - $product_static->id = $fields['pid']; - $product_static->ref = $fields['pref']; - $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) { - print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - } - } else { - if ($type) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { - if ($reg[1] == 'DEPOSIT') { - $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); - } elseif ($reg[1] == 'CREDIT_NOTE') { - $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); - } else { - $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); - } - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + // Description + print ''; + if ($fields['pid']) { + $product_static->id = $fields['pid']; + $product_static->ref = $fields['pref']; + $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); + } + } else { + if ($type) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) { + if ($reg[1] == 'DEPOSIT') { + $fields['descr'] = $langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1] == 'CREDIT_NOTE') { + $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 24); - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); - } - print ''; + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print ''; - // Total HT - if ($modetax != 1) { - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - } + // Total HT + if ($modetax != 1) { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + } - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $paymentfourn_static->id = $fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); - } + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id = $fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } - if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) - { - print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - print price(price2num($fields['payment_amount'], 'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; - } - } - print ''; - } + if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) + { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice * 100, 2).'%)'; + } + } + print ''; + } - // VAT paid - print ''; - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT'), 1); - print ''; + // VAT paid + print ''; + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); + print ''; - // VAT - print ''; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - print price(price2num($temp_vat, 'MT'), 1); - //print price($fields['vat']); - print ''; - print ''; + // VAT + print ''; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print ''; + print ''; - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; - } - } - // Total suppliers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; - print ''.price(price2num($subtot_paye_vat, 'MT')).''; - print ''; - } - } + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + // Total suppliers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num($subtot_paye_total_ht, 'MT')).''; + print ''.price(price2num($subtot_paye_vat, 'MT')).''; + print ''; + } + } - if (count($x_paye) == 0) { // Show a total line if nothing shown - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; - } + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - // Total to pay - print ''; + // Total to pay + print ''; - $diff = $x_coll_sum - $x_paye_sum; - print ''; - print ''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''; - print ''.price(price2num($diff, 'MT'))."\n"; - print "\n"; + $diff = $x_coll_sum - $x_paye_sum; + print ''; + print ''.$langs->trans("TotalToPay").($q ? ', '.$langs->trans("Quadri").' '.$q : '').''; + print ''.price(price2num($diff, 'MT'))."\n"; + print "\n"; - $i++; + $i++; } print ''; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 10efd84288c..e310e61fcb8 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -36,8 +36,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -58,7 +58,7 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { - $page = 0; + $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -82,10 +82,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if ($action == 'setlib' && $user->rights->tax->charges->creer) { - $object->fetch($id); - $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('lib', 'alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); } @@ -104,9 +104,9 @@ if ($object->id) { $alreadypayed = $object->getSommePaiement(); - $head = vat_prepare_head($object); + $head = vat_prepare_head($object); - print dol_get_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment'); + print dol_get_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'payment'); $morehtmlref = '
'; // Label of social contribution @@ -123,33 +123,33 @@ if ($object->id) print '
'; print '
'; - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) - { - $totalsize += $file['size']; - } + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) + { + $totalsize += $file['size']; + } - print ''; + print '
'; - print ''; - print ''; - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
'; + print '
'; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - $permission = $user->rights->tax->charges->creer; - $permtoedit = $user->rights->fournisseur->facture->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $permission = $user->rights->tax->charges->creer; + $permtoedit = $user->rights->fournisseur->facture->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { - print $langs->trans("ErrorUnknown"); + print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index a4fd1293b4d..4a16d996ab8 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -108,100 +108,100 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); */ function pt($db, $sql, $date) { - global $conf, $bc, $langs; + global $conf, $bc, $langs; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print ''; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $totalclaimed = 0; - $totalpaid = 0; - $amountclaimed = 0; - $amountpaid = 0; - $previousmonth = ''; - $previousmode = ''; - $mode = ''; + $totalclaimed = 0; + $totalpaid = 0; + $amountclaimed = 0; + $amountpaid = 0; + $previousmonth = ''; + $previousmode = ''; + $mode = ''; - while ($i < $num) { - $obj = $db->fetch_object($result); - $mode = $obj->mode; + while ($i < $num) { + $obj = $db->fetch_object($result); + $mode = $obj->mode; - //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; - if ($obj->mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; + if ($obj->mode == 'claimed' && !empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - if ($obj->mode == 'claimed') - { - $amountclaimed = $obj->mm; - $totalclaimed = $totalclaimed + $amountclaimed; - } - if ($obj->mode == 'paid') - { - $amountpaid = $obj->mm; - $totalpaid = $totalpaid + $amountpaid; - } + if ($obj->mode == 'claimed') + { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') + { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaid; + } - if ($obj->mode == 'paid') - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - $previousmode = ''; - $previousmonth = ''; - } else { - $previousmode = $obj->mode; - $previousmonth = $obj->dm; - } + if ($obj->mode == 'paid') + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + $previousmonth = ''; + } else { + $previousmode = $obj->mode; + $previousmonth = $obj->dm; + } - $i++; - } + $i++; + } - if ($mode == 'claimed' && !empty($previousmode)) - { - print ''; - print '\n"; - print '\n"; - print '\n"; - print "\n"; + if ($mode == 'claimed' && !empty($previousmode)) + { + print ''; + print '\n"; + print '\n"; + print '\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - } + $amountclaimed = 0; + $amountpaid = 0; + } - print ''; - print ''; - print ''; - print ''; - print ""; + print ''; + print ''; + print ''; + print ''; + print ""; - print "
'.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
'.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
"; + print ""; - $db->free($result); - } else { - dol_print_error($db); - } + $db->free($result); + } else { + dol_print_error($db); + } } @@ -392,144 +392,144 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc } //now we have an array (x_both) indexed by rates for coll and paye - $action = "tva"; - $object = array(&$x_coll, &$x_paye, &$x_both); - $parameters["mode"] = $modetax; - $parameters["year"] = $y; - $parameters["month"] = $m; - $parameters["type"] = 'vat'; + $action = "tva"; + $object = array(&$x_coll, &$x_paye, &$x_both); + $parameters["mode"] = $modetax; + $parameters["year"] = $y; + $parameters["month"] = $m; + $parameters["type"] = 'vat'; - // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array - $hookmanager->initHooks(array('externalbalance')); - $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) - { - $langs->load("errors"); - print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) - { - print ''.$langs->trans("FeatureNotYetAvailable").''; - break; - } + if (!is_array($x_coll) && $coll_listbuy == -1) + { + $langs->load("errors"); + print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; + break; + } + if (!is_array($x_paye) && $coll_listbuy == -2) + { + print ''.$langs->trans("FeatureNotYetAvailable").''; + break; + } - print ''; - print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; + print ''; + print ''.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").''; - $x_coll_sum = 0; - foreach (array_keys($x_coll) as $rate) - { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) + { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; - } - } - print ''.price(price2num($x_coll_sum, 'MT')).''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + print ''.price(price2num($x_coll_sum, 'MT')).''; - $x_paye_sum = 0; - foreach (array_keys($x_paye) as $rate) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) - { - // Payment - $ratiopaymentinvoice = 1; - if ($modetax != 1) - { - // Define type - // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. - $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (!empty($fields['ddate_start'])) { - $type = 1; - } - if (!empty($fields['ddate_end'])) { - $type = 1; - } + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice = 1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type = 1; + } + if (!empty($fields['ddate_end'])) { + $type = 1; + } - if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') - || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) - { - //print $langs->trans("NA"); - } else { - if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { - $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); - } - } - } - //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); - $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; - $temp_vat = $fields['vat'] * $ratiopaymentinvoice; - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; - } - } - print ''.price(price2num($x_paye_sum, 'MT')).''; + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht = $fields['totalht'] * $ratiopaymentinvoice; + $temp_vat = $fields['vat'] * $ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + print ''.price(price2num($x_paye_sum, 'MT')).''; - $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; - $diff = $x_coll_sum - $x_paye_sum; - $total = $total + $diff; - $subtotal = price2num($subtotal + $diff, 'MT'); + $diff = $x_coll_sum - $x_paye_sum; + $total = $total + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print ''.price(price2num($diff, 'MT')).''."\n"; - print " \n"; - print "\n"; + print ''.price(price2num($diff, 'MT')).''."\n"; + print " \n"; + print "\n"; - $i++; $m++; - if ($i > 2) - { - print ''; - print ''.$langs->trans("SubTotal").':'; - print ''.price(price2num($subtotalcoll, 'MT')).''; - print ''.price(price2num($subtotalpaye, 'MT')).''; - print ''.price(price2num($subtotal, 'MT')).''; - print ' '; - $i = 0; - $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; - } + $i++; $m++; + if ($i > 2) + { + print ''; + print ''.$langs->trans("SubTotal").':'; + print ''.price(price2num($subtotalcoll, 'MT')).''; + print ''.price(price2num($subtotalpaye, 'MT')).''; + print ''.price(price2num($subtotal, 'MT')).''; + print ' '; + $i = 0; + $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; + } } print ''.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).''; print " \n"; @@ -578,37 +578,37 @@ if (!empty($conf->global->MAIN_FEATURES_LEVEL)) * Recap */ - print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation + print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation - $sql1 = "SELECT SUM(amount) as mm"; - $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; - $sql1 .= " WHERE f.entity = ".$conf->entity; - $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; - $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; + $sql1 = "SELECT SUM(amount) as mm"; + $sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f"; + $sql1 .= " WHERE f.entity = ".$conf->entity; + $sql1 .= " AND f.datev >= '".$db->idate($date_start)."'"; + $sql1 .= " AND f.datev <= '".$db->idate($date_end)."'"; - $result = $db->query($sql1); - if ($result) { - $obj = $db->fetch_object($result); - print ''; + $result = $db->query($sql1); + if ($result) { + $obj = $db->fetch_object($result); + print '
'; - print ""; - print ''; - print ''; - print "\n"; + print ""; + print ''; + print ''; + print "\n"; - print ""; - print ''; - print '\n"; - print "\n"; + print ""; + print ''; + print '\n"; + print "\n"; - $restopay = $total - $obj->mm; - print ""; - print ''; - print ''; - print "\n"; + $restopay = $total - $obj->mm; + print ""; + print ''; + print ''; + print "\n"; - print '
'.$langs->trans("VATDue").''.price(price2num($total, 'MT')).'
'.$langs->trans("VATDue").''.price(price2num($total, 'MT')).'
'.$langs->trans("VATPaid").''.price(price2num($obj->mm, 'MT'))."
'.$langs->trans("VATPaid").''.price(price2num($obj->mm, 'MT'))."
'.$langs->trans("RemainToPay").''.price(price2num($restopay, 'MT')).'
'.$langs->trans("RemainToPay").''.price(price2num($restopay, 'MT')).'
'; - } + print ''; + } } print '
'; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 554143e7a7e..a142518279f 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -44,26 +44,26 @@ $langs->loadLangs(array('compta', 'bills')); $action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$optioncss = GETPOST('optioncss', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist'; $search_ref = GETPOST('search_ref', 'alpha'); -$search_label = GETPOST('search_label', 'alpha'); -$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int')); -$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int')); -$search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); -$search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); -$search_type = GETPOST('search_type', 'int'); -$search_cheque = GETPOST('search_cheque', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int')); +$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int')); +$search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); +$search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); +$search_type = GETPOST('search_type', 'int'); +$search_cheque = GETPOST('search_cheque', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', '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 = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int'); -if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -357,13 +357,13 @@ while ($i < min($num, $limit)) { } // Label - if (!empty($arrayfields['t.label']['checked'])) { + if (!empty($arrayfields['t.label']['checked'])) { print ''.dol_trunc($obj->label, 40).''; if (!$i) $totalarray['nbfield']++; } // Date end period - if (!empty($arrayfields['t.datev']['checked'])) { + if (!empty($arrayfields['t.datev']['checked'])) { print ''.dol_print_date($db->jdate($obj->datev), 'day').''; if (!$i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 8fb4c32bf72..ba12b08b3b0 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -159,16 +159,16 @@ $prevyear = $year_start; $prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; } else { - $prevquarter = 4; - $prevyear--; + $prevquarter = 4; + $prevyear--; } $nextyear = $year_start; $nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; } else { - $nextquarter = 1; - $nextyear++; + $nextquarter = 1; + $nextyear++; } $description .= $fsearch; $builddate = dol_now(); diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 95ec50be24f..2aeb2e4e2a1 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -67,17 +67,17 @@ $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); - $objcanvas->getCanvas('contact', 'contactcard', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); } if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -110,19 +110,19 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { - $actioncode = ''; - $search_agenda_label = ''; - } + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $actioncode = ''; + $search_agenda_label = ''; + } } @@ -140,138 +140,138 @@ llxHeader('', $title, $help_url); if ($socid > 0) { - $objsoc = new Societe($db); - $objsoc->fetch($socid); + $objsoc = new Societe($db); + $objsoc->fetch($socid); } if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - if (empty($object->error) && $id) + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + if (empty($object->error) && $id) { $object = new Contact($db); $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->display_canvas($action); // Show template } else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- - // Confirm deleting contact - if ($user->rights->societe->contact->supprimer) - { - if ($action == 'delete') - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); - } - } + // Confirm deleting contact + if ($user->rights->societe->contact->supprimer) + { + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id.($backtopage ? '&backtopage='.$backtopage : ''), $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } + } - /* + /* * Onglets */ - $head = array(); - if ($id > 0) - { - // Si edition contact deja existant - $object = new Contact($db); - $res = $object->fetch($id, $user); - if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res = $object->fetch_optionals(); - if ($res < 0) { dol_print_error($db, $object->error); exit; } + $head = array(); + if ($id > 0) + { + // Si edition contact deja existant + $object = new Contact($db); + $res = $object->fetch($id, $user); + if ($res < 0) { dol_print_error($db, $object->error); exit; } + $res = $object->fetch_optionals(); + if ($res < 0) { dol_print_error($db, $object->error); exit; } - // Show tabs - $head = contact_prepare_head($object); + // 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 (!empty($id) && $action != 'edit' && $action != 'create') - { - $objsoc = new Societe($db); + if (!empty($id) && $action != 'edit' && $action != 'create') + { + $objsoc = new Societe($db); - /* + /* * Fiche en mode visualisation */ - dol_htmloutput_errors($error, $errors); + dol_htmloutput_errors($error, $errors); - print dol_get_fiche_head($head, 'agenda', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'agenda', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
'; + print '
'; - print '
'; + print '
'; - $object->info($id); - dol_print_object_info($object, 1); + $object->info($id); + dol_print_object_info($object, 1); - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - // Actions buttons + // Actions buttons - $objcon = $object; - $object->fetch_thirdparty(); - $objthirdparty = $object->thirdparty; + $objcon = $object; + $object->fetch_thirdparty(); + $objthirdparty = $object->thirdparty; - $out = ''; - $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) - { + $out = ''; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) + { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); - } + } - $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) - { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) - { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); - } - } + $newcardbutton = ''; + if (!empty($conf->agenda->enabled)) + { + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + } + } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { - print '
'; + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + print '
'; - $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + $param = '&id='.$id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - print load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, ''); - //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1); + print load_fiche_titre($langs->trans("ActionsOnContact"), $newcardbutton, ''); + //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1); - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; - show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder); - } - } + show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } + } } diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 415d9e47790..f6f6fa0b45e 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -27,15 +27,15 @@ */ abstract class ActionsContactCardCommon { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $dirmodule; - public $targetmodule; - public $canvas; - public $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container public $tpl = array(); @@ -55,14 +55,14 @@ abstract class ActionsContactCardCommon /** - * Get object + * Get object * - * @param int $id Object id - * @return object Object loaded - */ - public function getObject($id) - { - /*$ret = $this->getInstanceDao(); + * @param int $id Object id + * @return object Object loaded + */ + public function getObject($id) + { + /*$ret = $this->getInstanceDao(); if (is_object($this->object) && method_exists($this->object,'fetch')) { @@ -70,39 +70,39 @@ abstract class ActionsContactCardCommon } else {*/ - $object = new Contact($this->db); - if (!empty($id)) $object->fetch($id); - $this->object = $object; - //} - } + $object = new Contact($this->db); + if (!empty($id)) $object->fetch($id); + $this->object = $object; + //} + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set content of ->tpl array, to use into template - * - * @param string $action Type of action - * @param int $id Id - * @return string HTML output - */ - public function assign_values(&$action, $id) - { - // phpcs:enable - global $conf, $langs, $user, $canvas; - global $form, $formcompany, $objsoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set content of ->tpl array, to use into template + * + * @param string $action Type of action + * @param int $id Id + * @return string HTML output + */ + public function assign_values(&$action, $id) + { + // phpcs:enable + global $conf, $langs, $user, $canvas; + global $form, $formcompany, $objsoc; - if ($action == 'add' || $action == 'update') $this->assign_post(); + if ($action == 'add' || $action == 'update') $this->assign_post(); - foreach ($this->object as $key => $value) - { - $this->tpl[$key] = $value; - } + foreach ($this->object as $key => $value) + { + $this->tpl[$key] = $value; + } - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; - if ($action == 'create' || $action == 'edit') - { - if ($conf->use_javascript_ajax) + if ($action == 'create' || $action == 'edit') + { + if ($conf->use_javascript_ajax) { $this->tpl['ajax_selectcountry'] = "\n".''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) - { - $this->tpl['company'] = $objsoc->getNomUrl(1); - $this->tpl['company_id'] = $objsoc->id; - } else { - $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); - } + if (is_object($objsoc) && $objsoc->id > 0) + { + $this->tpl['company'] = $objsoc->getNomUrl(1); + $this->tpl['company_id'] = $objsoc->id; + } else { + $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); + } - // Civility - $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); + // Civility + $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); - // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) - { - if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; - if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; - if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; - if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone; - if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax; - if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; - } + // Predefined with third party + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) + { + if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; + if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; + if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; + if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->phone; + if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax; + if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; + } - // Zip - $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + // Zip + $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); - // Town - $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + // Town + $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; + if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; - // Country - $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); - $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + // Country + $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); + $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - // State - if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); - else $this->tpl['select_state'] = $countrynotdefined; + // State + if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); + else $this->tpl['select_state'] = $countrynotdefined; - // Public or private - $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); - $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0); - } + // Public or private + $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); + $this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0); + } - if ($action == 'view' || $action == 'edit' || $action == 'delete') - { - // Emailing - if (!empty($conf->mailing->enabled)) + if ($action == 'view' || $action == 'edit' || $action == 'delete') + { + // Emailing + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } - // Linked element - $this->tpl['contact_element'] = array(); - $i = 0; + // Linked element + $this->tpl['contact_element'] = array(); + $i = 0; - $this->object->load_ref_elements(); + $this->object->load_ref_elements(); - if (!empty($conf->commande->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder"); - $i++; - } - if (!empty($conf->propal->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal"); - $i++; - } - if (!empty($conf->contrat->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract"); - $i++; - } - if (!empty($conf->facture->enabled)) - { - $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices"); - $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); - $i++; - } + if (!empty($conf->commande->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder"); + $i++; + } + if (!empty($conf->propal->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal"); + $i++; + } + if (!empty($conf->contrat->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract"); + $i++; + } + if (!empty($conf->facture->enabled)) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice"); + $i++; + } - // Dolibarr user - if ($this->object->user_id) + // Dolibarr user + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); - } + } - if ($action == 'view' || $action == 'delete') - { - $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); + if ($action == 'view' || $action == 'delete') + { + $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) - { - $objsoc = new Societe($this->db); + if ($this->object->socid > 0) + { + $objsoc = new Societe($this->db); - $objsoc->fetch($this->object->socid); - $this->tpl['company'] = $objsoc->getNomUrl(1); - } else { - $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany"); - } + $objsoc->fetch($this->object->socid); + $this->tpl['company'] = $objsoc->getNomUrl(1); + } else { + $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany"); + } - $this->tpl['civility'] = $this->object->getCivilityLabel(); + $this->tpl['civility'] = $this->object->getCivilityLabel(); - $this->tpl['address'] = dol_nl2br($this->object->address); + $this->tpl['address'] = dol_nl2br($this->object->address); - $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); + $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : ''); - $img = picto_from_langcode($this->object->country_code); - $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; + $img = picto_from_langcode($this->object->country_code); + $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; - $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); - $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); - $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); + $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); + $this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX'); + $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); - $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); + $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); - $this->tpl['note'] = nl2br($this->object->note); - } + $this->tpl['note'] = nl2br($this->object->note); + } - if ($action == 'create_user') - { - // Full firstname and lastname separated with a dot : firstname.lastname - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $login = dol_buildlogin($this->object->lastname, $this->object->firstname); + if ($action == 'create_user') + { + // Full firstname and lastname separated with a dot : firstname.lastname + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $login = dol_buildlogin($this->object->lastname, $this->object->firstname); - $generated_password = getRandomPassword(false); - $password = $generated_password; + $generated_password = getRandomPassword(false); + $password = $generated_password; - // Create a form array - $formquestion = array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), - array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); + // Create a form array + $formquestion = array( + array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), + array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); - $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateContact"), "confirm_create_user", $formquestion, 'no'); - } - } + $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateContact"), "confirm_create_user", $formquestion, 'no'); + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Assign POST values into object - * - * @return string HTML output - */ - private function assign_post() - { - // phpcs:enable - global $langs, $mysoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Assign POST values into object + * + * @return string HTML output + */ + private function assign_post() + { + // phpcs:enable + global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->socid = $_POST["socid"]; - $this->object->lastname = $_POST["name"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->poste = $_POST["poste"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_pro = $_POST["phone_pro"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->fax = $_POST["fax"]; - $this->object->email = $_POST["email"]; - $this->object->jabberid = $_POST["jabberid"]; - $this->object->priv = $_POST["priv"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->socid = $_POST["socid"]; + $this->object->lastname = $_POST["name"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->poste = $_POST["poste"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_pro = $_POST["phone_pro"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->fax = $_POST["fax"]; + $this->object->email = $_POST["email"]; + $this->object->jabberid = $_POST["jabberid"]; + $this->object->priv = $_POST["priv"]; + $this->object->note = $_POST["note"]; + $this->object->canvas = $_POST["canvas"]; - // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) - { - $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - } else { - dol_print_error($this->db); - } - $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; - } - } + // We set country_id, and country_code label of the chosen country + if ($this->object->country_id) + { + $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + } else { + dol_print_error($this->db); + } + $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + } + } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 099c973b0a4..d399584b48d 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -29,22 +29,22 @@ include_once DOL_DOCUMENT_ROOT.'/contact/canvas/actions_contactcard_common.class */ class ActionsContactCardDefault extends ActionsContactCardCommon { - /** - * Constructor - * - * @param DoliDB $db Handler acces base de donnees - * @param string $dirmodule Name of directory of module - * @param string $targetmodule Name of directory of module where canvas is stored - * @param string $canvas Name of canvas - * @param string $card Name of tab (sub-canvas) - */ - public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) - { - $this->db = $db; - $this->dirmodule = $dirmodule; - $this->targetmodule = $targetmodule; - $this->canvas = $canvas; - $this->card = $card; + /** + * Constructor + * + * @param DoliDB $db Handler acces base de donnees + * @param string $dirmodule Name of directory of module + * @param string $targetmodule Name of directory of module where canvas is stored + * @param string $canvas Name of canvas + * @param string $card Name of tab (sub-canvas) + */ + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + { + $this->db = $db; + $this->dirmodule = $dirmodule; + $this->targetmodule = $targetmodule; + $this->canvas = $canvas; + $this->card = $card; } /** @@ -66,7 +66,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -76,50 +76,50 @@ class ActionsContactCardDefault extends ActionsContactCardCommon */ public function assign_values(&$action, $id) { - // phpcs:enable + // phpcs:enable global $limit, $offset, $sortfield, $sortorder; global $conf, $db, $langs, $user; global $form; $ret = $this->getObject($id); - parent::assign_values($action, $id); + parent::assign_values($action, $id); - $this->tpl['title'] = $this->getTitle($action); - $this->tpl['error'] = $this->error; - $this->tpl['errors'] = $this->errors; + $this->tpl['title'] = $this->getTitle($action); + $this->tpl['error'] = $this->error; + $this->tpl['errors'] = $this->errors; if ($action == 'view') { - // Card header - $head = contact_prepare_head($this->object); - $title = $this->getTitle($action); + // Card header + $head = contact_prepare_head($this->object); + $title = $this->getTitle($action); - $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact'); - $this->tpl['showend'] = dol_get_fiche_end(); + $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact'); + $this->tpl['showend'] = dol_get_fiche_end(); - $objsoc = new Societe($db); - $objsoc->fetch($this->object->socid); + $objsoc = new Societe($db); + $objsoc->fetch($this->object->socid); - $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); - $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); + $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->societe->contact->supprimer) - { - $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); - } + if ($action == 'delete' && $user->rights->societe->contact->supprimer) + { + $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); + } } if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); + $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -129,13 +129,13 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) + { + // phpcs:enable + global $conf, $langs; - //$this->getFieldList(); + //$this->getFieldList(); - $this->list_datas = array(); - } + $this->list_datas = array(); + } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index b4406207977..956c78c1679 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1249,14 +1249,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } } - // Select mail models is same action as presend - if (GETPOST('modelselected', 'alpha')) { - $action = 'presend'; - } + // Select mail models is same action as presend + if (GETPOST('modelselected', 'alpha')) { + $action = 'presend'; + } - if (!empty($id) && $action != 'edit' && $action != 'create') - { - $objsoc = new Societe($db); + if (!empty($id) && $action != 'edit' && $action != 'create') + { + $objsoc = new Societe($db); // View mode diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 10c844f3149..cd058bd716c 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -142,63 +142,63 @@ class Contact extends CommonObject public $state_code; // Code of department public $state; // Label of department - public $poste; // Position + public $poste; // Position public $socid; // fk_soc public $statut; // 0=inactif, 1=actif public $code; - /** - * Email - * @var string - */ + /** + * Email + * @var string + */ public $email; - /** - * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings + /** + * Unsuscribe all : 1 = contact has globaly unsubscribe of all mass emailings * @var int - */ + */ public $no_email; - /** - * @var array array of socialnetworks - */ - public $socialnetworks; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; - /** - * Skype username - * @var string - * @deprecated - */ + /** + * Skype username + * @var string + * @deprecated + */ public $skype; /** - * Twitter username - * @var string - * @deprecated - */ + * Twitter username + * @var string + * @deprecated + */ public $twitter; /** - * Facebook username - * @var string - * @deprecated - */ + * Facebook username + * @var string + * @deprecated + */ public $facebook; /** - * Linkedin username - * @var string - * @deprecated - */ - public $linkedin; + * Linkedin username + * @var string + * @deprecated + */ + public $linkedin; - /** - * Jabber username - * @var string - * @deprecated - */ + /** + * Jabber username + * @var string + * @deprecated + */ public $jabberid; public $photo; @@ -227,10 +227,10 @@ class Contact extends CommonObject // END MODULEBUILDER PROPERTIES - /** - * Old copy - * @var Contact - */ + /** + * Old copy + * @var Contact + */ public $oldcopy; // To contains a clone of this when we need to save old properties of object public $roles = array(); @@ -292,7 +292,7 @@ class Contact extends CommonObject }*/ } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * @@ -300,7 +300,7 @@ class Contact extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable global $user; $this->nb = array(); @@ -310,14 +310,14 @@ class Contact extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $clause = "AND"; } $sql .= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; $sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; - if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid; + if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid; $resql = $this->db->query($sql); if ($resql) @@ -352,9 +352,9 @@ class Contact extends CommonObject // Clean parameters $this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name); - $this->firstname = trim($this->firstname); + $this->firstname = trim($this->firstname); $this->setUpperOrLowerCase(); - if (empty($this->socid)) $this->socid = 0; + if (empty($this->socid)) $this->socid = 0; if (empty($this->priv)) $this->priv = 0; if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request @@ -363,11 +363,11 @@ class Contact extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople ("; $sql .= " datec"; $sql .= ", fk_soc"; - $sql .= ", lastname"; - $sql .= ", firstname"; - $sql .= ", fk_user_creat"; + $sql .= ", lastname"; + $sql .= ", firstname"; + $sql .= ", fk_user_creat"; $sql .= ", priv"; - $sql.= ", fk_stcommcontact"; + $sql .= ", fk_stcommcontact"; $sql .= ", statut"; $sql .= ", canvas"; $sql .= ", entity"; @@ -381,7 +381,7 @@ class Contact extends CommonObject $sql .= "'".$this->db->escape($this->firstname)."',"; $sql .= " ".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "null").","; $sql .= " ".$this->db->escape($this->priv).","; - $sql.= " 0,"; + $sql .= " 0,"; $sql .= " ".$this->db->escape($this->statut).","; $sql .= " ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null").","; $sql .= " ".$this->db->escape($this->entity).","; @@ -397,41 +397,41 @@ class Contact extends CommonObject if (!$error) { - $result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ... - if ($result < 0) - { - $error++; - $this->error = $this->db->lasterror(); - } + $result = $this->update($this->id, $user, 1, 'add'); // This include updateRoles(), ... + if ($result < 0) + { + $error++; + $this->error = $this->db->lasterror(); + } } if (!$error) - { - $result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update - if ($result < 0) - { - $error++; - $this->error = $this->db->lasterror(); - } - } + { + $result = $this->update_perso($this->id, $user, 1); // TODO Remove function update_perso, should be same than update + if ($result < 0) + { + $error++; + $this->error = $this->db->lasterror(); + } + } - if (!$error) - { - // Call trigger - $result = $this->call_trigger('CONTACT_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (!$error) + { + // Call trigger + $result = $this->call_trigger('CONTACT_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - if (!$error) - { - $this->db->commit(); - return $this->id; - } else { - $this->db->rollback(); - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -2; - } + if (!$error) + { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -2; + } } else { $this->error = $this->db->lasterror(); @@ -494,7 +494,7 @@ class Contact extends CommonObject $sql .= ", poste='".$this->db->escape($this->poste)."'"; $sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", email='".$this->db->escape($this->email)."'"; - $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); $sql .= ", note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); @@ -518,22 +518,22 @@ class Contact extends CommonObject $result = $this->db->query($sql); if ($result) { - unset($this->country_code); - unset($this->country); - unset($this->state_code); - unset($this->state); + unset($this->country_code); + unset($this->country); + unset($this->state_code); + unset($this->state); - $action = 'update'; + $action = 'update'; - // Actions on extra fields - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (!$error) { $result = $this->updateRoles(); @@ -640,14 +640,14 @@ class Contact extends CommonObject } } else { $this->error = $this->db->lasterror().' sql='.$sql; - $this->db->rollback(); + $this->db->rollback(); return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -659,7 +659,7 @@ class Contact extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN; @@ -669,8 +669,8 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Initialise tableau info (tableau des attributs LDAP) * @@ -678,12 +678,12 @@ class Contact extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; - $info = array(); + $info = array(); - // Object classes + // Object classes $info["objectclass"] = explode(',', $conf->global->LDAP_CONTACT_OBJECT_CLASS); $this->fullname = $this->getFullName($langs); @@ -712,8 +712,8 @@ class Contact extends CommonObject if ($this->phone_perso && !empty($conf->global->LDAP_CONTACT_FIELD_HOMEPHONE)) $info[$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE] = $this->phone_perso; if ($this->phone_mobile && !empty($conf->global->LDAP_CONTACT_FIELD_MOBILE)) $info[$conf->global->LDAP_CONTACT_FIELD_MOBILE] = $this->phone_mobile; if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; - if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; - if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); + if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; + if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); if ($this->email && !empty($conf->global->LDAP_CONTACT_FIELD_MAIL)) $info[$conf->global->LDAP_CONTACT_FIELD_MAIL] = $this->email; if ($conf->global->LDAP_SERVER_TYPE == 'egroupware') @@ -745,22 +745,22 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update field alert birthday * * @param int $id Id of contact * @param User $user User asking to change alert or birthday * @param int $notrigger 0=no, 1=yes - * @return int <0 if KO, >=0 if OK + * @return int <0 if KO, >=0 if OK */ public function update_perso($id, $user = null, $notrigger = 0) { - // phpcs:enable - $error = 0; - $result = false; + // phpcs:enable + $error = 0; + $result = false; - $this->db->begin(); + $this->db->begin(); // Mis a jour contact $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; @@ -791,8 +791,8 @@ class Contact extends CommonObject $result = $this->db->query($sql); if (!$result) { - $error++; - $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } } else { $result = true; @@ -803,27 +803,27 @@ class Contact extends CommonObject $result = $this->db->query($sql); if (!$result) { - $error++; - $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTACT_MODIFY', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_MODIFY', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) { - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else { - dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); - $this->db->rollback(); - return -$error; + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); + $this->db->rollback(); + return -$error; } } @@ -833,9 +833,9 @@ class Contact extends CommonObject * * @param int $id Id of contact * @param User $user Load also alerts of this user (subscribing to alerts) that want alerts about this contact - * @param string $ref_ext External reference, not given by Dolibarr - * @param string $email Email - * @param int $loadalsoroles Load also roles + * @param string $ref_ext External reference, not given by Dolibarr + * @param string $email Email + * @param int $loadalsoroles Load also roles * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ public function fetch($id, $user = null, $ref_ext = '', $email = '', $loadalsoroles = 0) @@ -859,9 +859,9 @@ class Contact extends CommonObject $sql .= " c.birthday,"; $sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; $sql .= " c.socialnetworks,"; - $sql .= " c.photo,"; + $sql .= " c.photo,"; $sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; - $sql.= " c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; + $sql .= " c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; $sql .= " c.import_key,"; $sql .= " c.datec as date_creation, c.tms as date_modification,"; $sql .= " co.label as country, co.code as country_code,"; @@ -873,7 +873,7 @@ class Contact extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; if ($id) $sql .= " WHERE c.rowid = ".((int) $id); else { $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; @@ -907,7 +907,7 @@ class Contact extends CommonObject $this->civility_code = $obj->civility_code; $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; - $this->lastname = $obj->lastname; + $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; $this->address = $obj->address; $this->zip = $obj->zip; @@ -931,11 +931,11 @@ class Contact extends CommonObject $this->fk_prospectlevel = $obj->fk_prospectcontactlevel; - $transcode=$langs->trans('StatusProspect'.$obj->fk_stcommcontact); - $libelle=($transcode!='StatusProspect'.$obj->fk_stcommcontact?$transcode:$obj->stcomm); - $this->stcomm_id = $obj->fk_stcommcontact; // id statut commercial - $this->statut_commercial = $libelle; // libelle statut commercial - $this->stcomm_picto = $obj->stcomm_picto; // Picto statut commercial + $transcode = $langs->trans('StatusProspect'.$obj->fk_stcommcontact); + $libelle = ($transcode != 'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm); + $this->stcomm_id = $obj->fk_stcommcontact; // id statut commercial + $this->statut_commercial = $libelle; // libelle statut commercial + $this->stcomm_picto = $obj->stcomm_picto; // Picto statut commercial $this->phone_pro = trim($obj->phone); $this->fax = trim($obj->fax); @@ -1049,7 +1049,7 @@ class Contact extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load number of elements the contact is used as a link for * ref_facturation @@ -1057,11 +1057,11 @@ class Contact extends CommonObject * ref_commande (for order and/or shipments) * ref_propale * - * @return int <0 if KO, >=0 if OK + * @return int <0 if KO, >=0 if OK */ public function load_ref_elements() { - // phpcs:enable + // phpcs:enable // Compte les elements pour lesquels il est contact $sql = "SELECT tc.element, count(ec.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc"; @@ -1187,18 +1187,18 @@ class Contact extends CommonObject } // Removed extrafields - if (!$error) { - // For avoid conflicts if trigger used + if (!$error) { + // For avoid conflicts if trigger used $result = $this->deleteExtraFields(); if ($result < 0) $error++; } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTACT_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) @@ -1291,7 +1291,7 @@ class Contact extends CommonObject * @param string $option Where the link point to * @param int $maxlen Max length of * @param string $moreparam Add more param into URL - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip 1=Disable tooltip * @return string String with URL */ @@ -1309,40 +1309,40 @@ class Contact extends CommonObject } $label .= img_picto('', $this->picto).' '.$langs->trans("Contact").''; - $label .= '
'.$langs->trans("Name").': '.$this->getFullName($langs); - //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code - if (!empty($this->poste)) $label .= '
'.$langs->trans("Poste").': '.$this->poste; - $label .= '
'.$langs->trans("EMail").': '.$this->email; - $phonelist = array(); - if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); - if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); - if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); - $label .= '
'.$langs->trans("Phone").': '.implode(' ', $phonelist); - $label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); + $label .= '
'.$langs->trans("Name").': '.$this->getFullName($langs); + //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code + if (!empty($this->poste)) $label .= '
'.$langs->trans("Poste").': '.$this->poste; + $label .= '
'.$langs->trans("EMail").': '.$this->email; + $phonelist = array(); + if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); + if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); + if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); + $label .= '
'.$langs->trans("Phone").': '.implode(' ', $phonelist); + $label .= '
'.$langs->trans("Address").': '.dol_format_address($this, 1, ' ', $langs); - $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; - if ($option !== 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - } + if ($option !== 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + } - $url .= $moreparam; + $url .= $moreparam; - $linkclose = ""; + $linkclose = ""; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowContact"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowContact"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; - /* + /* $hookmanager->initHooks(array('contactdao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -1402,7 +1402,7 @@ class Contact extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1412,7 +1412,7 @@ class Contact extends CommonObject */ public function LibStatut($status, $mode) { - // phpcs:enable + // phpcs:enable global $langs; $labelStatus = array( @@ -1438,7 +1438,7 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label of Public or Private * @@ -1447,7 +1447,7 @@ class Contact extends CommonObject */ public function LibPubPriv($status) { - // phpcs:enable + // phpcs:enable global $langs; if ($status == '1') return $langs->trans('ContactPrivate'); else return $langs->trans('ContactPublic'); @@ -1455,11 +1455,11 @@ class Contact extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return int >0 if ok + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return int >0 if ok */ public function initAsSpecimen() { @@ -1528,10 +1528,10 @@ class Contact extends CommonObject dol_syslog(get_class($this)."::setstatus", LOG_DEBUG); if ($result) { - // Call trigger - $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTACT_ENABLEDISABLE', $user); + if ($result < 0) { $error++; } + // End call triggers } if ($error) @@ -1552,7 +1552,7 @@ class Contact extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ public function setCategories($categories) { @@ -1765,15 +1765,15 @@ class Contact extends CommonObject { global $langs; - $sql = "SELECT id, code, libelle as label, picto FROM " . MAIN_DB_PREFIX . "c_stcommcontact"; - if ($active >= 0) $sql .= " WHERE active = " . $active; + $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcommcontact"; + if ($active >= 0) $sql .= " WHERE active = ".$active; $resql = $this->db->query($sql); $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_" . strtoupper($obj->code)) == "ST_" . strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_" . strtoupper($obj->code)), 'picto' => $obj->picto); + $this->cacheprospectstatus[$obj->id] = array('id' => $obj->id, 'code' => $obj->code, 'label' => ($langs->trans("ST_".strtoupper($obj->code)) == "ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans("ST_".strtoupper($obj->code)), 'picto' => $obj->picto); $i++; } return 1; @@ -1799,9 +1799,9 @@ class Contact extends CommonObject { global $langs; - $lib = $langs->trans("ProspectLevel" . $fk_prospectlevel); + $lib = $langs->trans("ProspectLevel".$fk_prospectlevel); // If lib not found in language file, we get label from cache/databse - if ($lib == $langs->trans("ProspectLevel" . $fk_prospectlevel)) + if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel)) { $lib = $langs->getLabelFromKey($this->db, $fk_prospectlevel, 'c_prospectlevel', 'code', 'label'); } @@ -1853,13 +1853,13 @@ class Contact extends CommonObject if ($mode == 2) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto) . ' ' . $langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto) . ' ' . $langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto) . ' ' . $langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto) . ' ' . $langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto) . ' ' . $langs->trans("StatusProspect3"); + if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto) . ' ' . (($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } if ($mode == 3) @@ -1870,18 +1870,18 @@ class Contact extends CommonObject elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto); elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto); } } if ($mode == 4) { - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto) . ' ' . $langs->trans("StatusProspect-1"); - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto) . ' ' . $langs->trans("StatusProspect0"); - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto) . ' ' . $langs->trans("StatusProspect1"); - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto) . ' ' . $langs->trans("StatusProspect2"); - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto) . ' ' . $langs->trans("StatusProspect3"); + if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"), -1, $picto).' '.$langs->trans("StatusProspect-1"); + elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0, $picto).' '.$langs->trans("StatusProspect0"); + elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1, $picto).' '.$langs->trans("StatusProspect1"); + elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2, $picto).' '.$langs->trans("StatusProspect2"); + elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3, $picto).' '.$langs->trans("StatusProspect3"); else { - return img_action(($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label, 0, $picto) . ' ' . (($langs->trans("StatusProspect" . $statut) != "StatusProspect" . $statut) ? $langs->trans("StatusProspect" . $statut) : $label); + return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0, $picto).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); } } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index d3992296aec..da00374cc2a 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -62,10 +62,10 @@ $year = GETPOST('year', 'int'); // Clean up on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $sref = ''; - $sprod_fulldescr = ''; - $year = ''; - $month = ''; + $sref = ''; + $sprod_fulldescr = ''; + $year = ''; + $month = ''; } // Customer or supplier selected in drop box $thirdTypeSelect = GETPOST("third_select_id"); @@ -113,11 +113,11 @@ $linkback = ''; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { - $objsoc->fetch($socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + $objsoc->fetch($socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1, 'contact'); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); } $morehtmlref .= ''; @@ -148,7 +148,7 @@ if ($object->thirdparty->fournisseur) { $thirdTypeArray['supplier'] = $langs->trans("supplier"); if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']= $langs->transnoentitiesnoconv('SuppliersOrders'); + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); // There no contact type for supplier proposals // if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); @@ -172,9 +172,9 @@ if ($type_element == 'fichinter') $documentstatic = new Fichinter($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'fichinterdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'fichinter as f ON d.fk_fichinter=f.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='fichinter' and tc.source='external' and tc.active=1)"; $where = ' WHERE f.entity IN ('.getEntity('ficheinter').')'; $dateprint = 'f.datec'; $doc_number = 'f.ref'; @@ -184,10 +184,10 @@ if ($type_element == 'fichinter') $documentstatic = new Facture($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'facturedet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON d.fk_facture=f.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='facture' and tc.source='external' and tc.active=1)"; $where = " WHERE f.entity IN (".getEntity('invoice').")"; $dateprint = 'f.datef'; $doc_number = 'f.ref'; @@ -198,10 +198,10 @@ if ($type_element == 'fichinter') $documentstatic = new Propal($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'propaldet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propal as c ON d.fk_propal=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('propal').')'; $datePrint = 'c.datep'; $doc_number = 'c.ref'; @@ -212,10 +212,10 @@ if ($type_element == 'fichinter') $documentstatic = new Commande($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'commandedet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON d.fk_commande=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='commande' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('order').')'; $dateprint = 'c.date_commande'; $doc_number = 'c.ref'; @@ -226,10 +226,10 @@ if ($type_element == 'fichinter') $documentstatic = new FactureFournisseur($db); $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'facture_fourn_det d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn as f ON d.fk_facture_fourn=f.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=f.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='invoice_supplier' and tc.source='external' and tc.active=1)"; $where = ' WHERE f.entity IN ('.getEntity($documentstatic->element).')'; $dateprint = 'f.datef'; $doc_number = 'f.ref'; @@ -254,10 +254,10 @@ elseif ($type_element == 'supplier_order') $documentstatic = new CommandeFournisseur($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'commande_fournisseurdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur as c ON d.fk_commande=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='order_supplier' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity($documentstatic->element).')'; $dateprint = 'c.date_valid'; $doc_number = 'c.ref'; @@ -269,10 +269,10 @@ elseif ($type_element == 'supplier_order') $documentstaticline = new ContratLigne($db); $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, tc.libelle as type_contact_label, '; $tables_from = MAIN_DB_PREFIX.'contratdet d'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; - $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; - $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'contrat as c ON d.fk_contrat=c.rowid'; + $tables_from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON d.fk_product=p.rowid'; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople='.$object->id; + $tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='contrat' and tc.source='external' and tc.active=1)"; $where = ' WHERE c.entity IN ('.getEntity('contrat').')'; $dateprint = 'c.date_valid'; $doc_number = 'c.ref'; @@ -293,16 +293,16 @@ if (!empty($sql_select)) $sql .= " "; if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label"; $sql .= " FROM "/*.MAIN_DB_PREFIX."societe as s, "*/.$tables_from; - // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; + // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; $sql .= $where; $sql .= dolSqlDateFilter($dateprint, 0, $month, $year); if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; if ($sprod_fulldescr) { - $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; - if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; - if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; - $sql .= ")"; + $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; + $sql .= ")"; } $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); @@ -314,8 +314,8 @@ if (!empty($sql_select)) $disabled = 0; $showempty = 2; if (empty($elementTypeArray) && !$object->thirdparty->client && !$object->thirdparty->fournisseur) { - $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); - $disabled = 1; + $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); + $disabled = 1; } // Define type of elements @@ -340,7 +340,7 @@ if ($sql_select) $num = $db->num_rows($resql); $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element); - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); if ($sref) $param .= "&sref=".urlencode($sref); @@ -348,48 +348,48 @@ if ($sql_select) if ($year) $param .= "&year=".urlencode($year); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; - // Filters - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // Filters + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - // Titles with sort buttons - print ''; - print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('ContactType', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - print "\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('ContactType', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + print "\n"; $i = 0; @@ -478,7 +478,7 @@ if ($sql_select) elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid"); //else $txt=$langs->trans("Discount"); print $txt; - print ''; + print ''; if ($objp->description) { if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) @@ -576,7 +576,7 @@ if ($sql_select) print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -588,25 +588,25 @@ if ($sql_select) } $db->free($resql); } elseif (empty($type_element) || $type_element == -1) { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - print '
'; - print ''; - print ''; // date - print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); - print ''; - print ''; - print ''; - print ''; // TODO: Add filters ! - print ''; - print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; + print ''; + print ''; // date + print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); + print ''; + print ''; + print ''; + print ''; // TODO: Add filters ! + print ''; + print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'.$langs->trans('Total').''.$total_qty.''.price($total_ht).''.price($total_ht / (empty($total_qty) ? 1 : $total_qty)).'
'."\n"; - // Titles with sort buttons - print ''; - print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); - print "\n"; + print '
'."\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); + print "\n"; print ''; print "
'.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).'
"; } else { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - print ''."\n"; + print '
'."\n"; print ''; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 8a70ec6e2df..2065ab772e6 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -45,9 +45,9 @@ $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); - $objcanvas->getCanvas('contact', 'contactcard', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('contact', 'contactcard', $canvas); } // Security check @@ -96,43 +96,43 @@ llxHeader('', $title, $helpurl); if ($object->id) { - $head = contact_prepare_head($object); + $head = contact_prepare_head($object); $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - print dol_get_fiche_head($head, 'documents', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'documents', $title, -1, 'contact'); - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) - { - $totalsize += $file['size']; - } + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) + { + $totalsize += $file['size']; + } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
'; + print '
'; - print '
'; - print '
'.$langs->trans("FeatureNotYetAvailable").'
'; + print '
'; + print '
'; - // Company - /* + // Company + /* if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if ($object->socid > 0) @@ -151,26 +151,26 @@ if ($object->id) } }*/ - // Civility - print ''; + // Civility + print ''; - print ''; - print ''; - print '
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - $modulepart = 'contact'; - $permission = $user->rights->societe->contact->creer; - $permtoedit = $user->rights->societe->contact->creer; - $param = '&id='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'contact'; + $permission = $user->rights->societe->contact->creer; + $permtoedit = $user->rights->societe->contact->creer; + $param = '&id='.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { - print $langs->trans("ErrorUnknown"); + print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 68d810967ad..78934c5857e 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -174,7 +174,7 @@ if ($result > 0) //var_dump($records); // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { if (!is_array($records)) { diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 478288046e1..ae32ef5c95e 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -67,46 +67,46 @@ llxHeader('', $title, $help_url); if ($id > 0) { - /* + /* * Affichage onglets */ - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); - $head = contact_prepare_head($object); + $head = contact_prepare_head($object); - print dol_get_fiche_head($head, 'note', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'note', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - $cssclass = 'titlefield'; - //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; - //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; + $cssclass = 'titlefield'; + //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; + //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; - print '
'; - print '
'; + print '
'; + print '
'; print ''; - // Civility - print ''; + // Civility + print ''; - print "
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
"; + print ""; $cssclass = "titlefield"; @@ -114,7 +114,7 @@ if ($id > 0) print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); } llxFooter(); diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index bbaf013efa1..d8d7b709736 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -66,7 +66,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- if ($file_OK) { 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/lib/images.lib.php'; if (GETPOST('deletephoto')) { $fileimg = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/'.$object->photo; @@ -86,8 +86,8 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact- { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { - // Create thumbs - $object->addThumbs($newfile); + // Create thumbs + $object->addThumbs($newfile); } } } else { @@ -130,119 +130,119 @@ $head = contact_prepare_head($object); if ($action == 'edit') { - /* + /* * Fiche en mode edition */ - print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print dol_get_fiche_head($head, 'perso', $title, 0, 'contact'); + print dol_get_fiche_head($head, 'perso', $title, 0, 'contact'); - print ''; + print '
'; - // Ref - print ''; + // Ref + print ''; - // Photo - print ''; + print ''; + print ''; + print '
'.$langs->trans("Ref").''; - print $object->id; - print '
'.$langs->trans("Ref").''; + print $object->id; + print ''; - print $form->showphoto('contact', $object)."\n"; - if ($object->photo) print "
\n"; + // Photo + print '
'; + print $form->showphoto('contact', $object)."\n"; + if ($object->photo) print "
\n"; - print ''; + print '
'; - if ($object->photo) print ''; - print ''; - print ''; - print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; + if ($object->photo) print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; - print ''; + print ''; - // Name - print ''.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''; - print ''.$langs->trans("Firstname").''.$object->firstname.''; + // Name + print ''.$langs->trans("Lastname").' / '.$langs->trans("Label").''.$object->lastname.''; + print ''.$langs->trans("Firstname").''.$object->firstname.''; - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - if ($object->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); + // Company + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + if ($object->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); - print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; - } else { - print ''.$langs->trans("ThirdParty").''; - print $langs->trans("ContactNotLinkedToCompany"); - print ''; - } - } + print ''.$langs->trans("ThirdParty").''.$objsoc->getNomUrl(1).''; + } else { + print ''.$langs->trans("ThirdParty").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } + } - // Civility - print ''.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print ''; + // Civility + print ''.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print ''; - // Date To Birth - print ''.$langs->trans("DateOfBirth").''; - $form = new Form($db); - print $form->selectDate($object->birthday, 'birthday', 0, 0, 1, "perso", 1, 0); - print ''; + // Date To Birth + print ''.$langs->trans("DateOfBirth").''; + $form = new Form($db); + print $form->selectDate($object->birthday, 'birthday', 0, 0, 1, "perso", 1, 0); + print ''; - print ''.$langs->trans("Alert").': '; - if (!empty($object->birthday_alert)) - { - print ''; - } else { - print ''; - } - print ''; + print ''.$langs->trans("Alert").': '; + if (!empty($object->birthday_alert)) + { + print ''; + } else { + print ''; + } + print ''; - print ""; + print ""; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; - print "
"; + print ""; } else { - // View mode + // View mode - print dol_get_fiche_head($head, 'perso', $title, -1, 'contact'); + print dol_get_fiche_head($head, 'perso', $title, -1, 'contact'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - $objsoc = new Societe($db); - $objsoc->fetch($object->socid); - // Thirdparty - $morehtmlref .= $langs->trans('ThirdParty').' : '; - if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); - else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); - } - $morehtmlref .= '
'; + $morehtmlref = '
'; + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $objsoc = new Societe($db); + $objsoc->fetch($object->socid); + // Thirdparty + $morehtmlref .= $langs->trans('ThirdParty').' : '; + if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1); + else $morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - print '
'; + print '
'; - print '
'; - print ''; + print '
'; + print '
'; - // Company - /* + // Company + /* if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if ($object->socid > 0) @@ -261,59 +261,59 @@ if ($action == 'edit') } }*/ - // Civility - print ''; + // Civility + print ''; - // Date To Birth - print ''; - if (!empty($object->birthday)) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + // Date To Birth + print ''; + if (!empty($object->birthday)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - print ''; - } else { - print ''; - } - print ""; + print '   -   '; + if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); + else print $langs->trans("BirthdayAlertOff"); + print ''; + } else { + print ''; + } + print ""; - print "
'.$langs->trans("UserTitle").''; - print $object->getCivilityLabel(); - print '
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("DateOfBirth").''.dol_print_date($object->birthday, "day"); + print ''.$langs->trans("DateOfBirth").''.dol_print_date($object->birthday, "day"); - print '   '; - //var_dump($birthdatearray); - $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970; - $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1; - if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; - elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; - else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; + print '   '; + //var_dump($birthdatearray); + $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970; + $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1; + if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')'; + elseif ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')'; + else print '('.$agemonth.' '.$langs->trans("DurationMonth").')'; - print '   -   '; - if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn"); - else print $langs->trans("BirthdayAlertOff"); - print ''.$langs->trans("DateOfBirth").'
'.$langs->trans("DateOfBirth").'
"; + print ""; - print '
'; + print '
'; - print dol_get_fiche_end(); + print dol_get_fiche_end(); } if ($action != 'edit') { - // Barre d'actions - if ($user->socid == 0) - { - print '
'; + // Barre d'actions + if ($user->socid == 0) + { + print '
'; - if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans('Modify').''; - } + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans('Modify').''; + } - print "
"; - } + print "
"; + } } diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index ee325317033..05426db19a6 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -66,7 +66,7 @@ $v->setPhoneNumber($contact->phone_pro, "TYPE=WORK;VOICE"); $v->setPhoneNumber($contact->phone_mobile, "TYPE=CELL;VOICE"); $v->setPhoneNumber($contact->fax, "TYPE=WORK;FAX"); -$country = $contact->country_code ? $contact->country : '' ; +$country = $contact->country_code ? $contact->country : ''; $v->setAddress("", "", $contact->address, $contact->town, $contact->state, $contact->zip, $country, "TYPE=WORK;POSTAL"); $v->setLabel("", "", $contact->address, $contact->town, $contact->state, $contact->zip, $country, "TYPE=WORK"); @@ -79,9 +79,9 @@ $v->setTitle($contact->poste); if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (! $contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + if (!$contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + if (!$contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + if (!$contact->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); // when company e-mail is empty, use only contact e-mail if (empty(trim($company->email))) @@ -124,7 +124,7 @@ $db->close(); $output = $v->getVCard(); -$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" +$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); //$filename = dol_sanitizeFileName($filename); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 1187571d2d0..be97a83115a 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -409,13 +409,13 @@ if (empty($reshook)) $error++; } - $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) - { - setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); - $error++; - } + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) + { + setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); + $error++; + } // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -684,9 +684,9 @@ if (empty($reshook)) $objectline->pa_ht = $pa_ht; if ($fk_unit > 0) { - $objectline->fk_unit = GETPOST('unit'); + $objectline->fk_unit = GETPOST('unit'); } else { - $objectline->fk_unit = null; + $objectline->fk_unit = null; } // Extrafields @@ -877,11 +877,11 @@ if (empty($reshook)) $old_ref = $object->ref; - $result = $object->setValueFrom('ref', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'editref'; - } else { + $result = $object->setValueFrom('ref', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'editref'; + } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $old_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($old_ref); $new_filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref); @@ -896,13 +896,13 @@ if (empty($reshook)) } } - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - } else { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; - } + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + } else { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } } elseif ($action == 'setdate_contrat') { $cancelbutton = GETPOST('cancel', 'alpha'); @@ -1233,8 +1233,8 @@ if ($action == 'create') $result = $object->fetch_lines(); // This also init $this->nbofserviceswait, $this->nbofservicesopened, $this->nbofservicesexpired=, $this->nbofservicesclosed if ($result < 0) { - dol_print_error($db, $object->error); - } + dol_print_error($db, $object->error); + } $nbofservices = count($object->lines); @@ -1249,55 +1249,55 @@ if ($action == 'create') $head = contract_prepare_head($object); - $hselected = 0; - $formconfirm = ''; + $hselected = 0; + $formconfirm = ''; - print dol_get_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, $hselected, $langs->trans("Contract"), -1, 'contract'); - if ($action == 'delete') { - //Confirmation de la suppression du contrat - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAContract"), $langs->trans("ConfirmDeleteAContract"), "confirm_delete", '', 0, 1); - } elseif ($action == 'valid') { - //Confirmation de la validation - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { - $numref = $object->getNextNumRef($object->thirdparty); - } else { - $numref = $object->ref; - } - $text = $langs->trans('ConfirmValidateContract', $numref); - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ValidateAContract"), $text, "confirm_valid", '', 0, 1); - } elseif ($action == 'close') { - // Confirmation de la fermeture - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); - } elseif ($action == 'activate') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); - } elseif ($action == 'clone') { - // Clone confirmation - $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } + if ($action == 'delete') { + //Confirmation de la suppression du contrat + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("DeleteAContract"), $langs->trans("ConfirmDeleteAContract"), "confirm_delete", '', 0, 1); + } elseif ($action == 'valid') { + //Confirmation de la validation + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { + $numref = $object->getNextNumRef($object->thirdparty); + } else { + $numref = $object->ref; + } + $text = $langs->trans('ConfirmValidateContract', $numref); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ValidateAContract"), $text, "confirm_valid", '', 0, 1); + } elseif ($action == 'close') { + // Confirmation de la fermeture + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); + } elseif ($action == 'activate') { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); + } elseif ($action == 'clone') { + // Clone confirmation + $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneContract', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - // Call Hook formConfirm - $parameters = array( - 'formConfirm' => $formconfirm, - 'id' => $id, - //'lineid' => $lineid, - ); - // Note that $action and $object may have been modified by hook - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + // Call Hook formConfirm + $parameters = array( + 'formConfirm' => $formconfirm, + 'id' => $id, + //'lineid' => $lineid, + ); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - // Print form confirm - print $formconfirm; + // Print form confirm + print $formconfirm; - /* + /* * Contrat */ if (!empty($object->brouillon) && $user->rights->contrat->creer) @@ -1489,7 +1489,7 @@ if ($action == 'create') if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) { $moreparam = ''; - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; print ''; // Label if ($objp->fk_product > 0) @@ -1622,7 +1622,7 @@ if ($action == 'create') $line = new ContratLigne($db); $line->id = $objp->rowid; $line->fetch_optionals(); - print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven','style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); + print $line->showOptionals($extrafields, 'view', array('class'=>'oddeven', 'style'=>$moreparam, 'colspan'=>$colspan), '', '', 1); } } // Line in mode update @@ -1734,7 +1734,7 @@ if ($action == 'create') if ($object->statut > 0) { $moreparam = ''; - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline-1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') $moreparam = 'style="display: none;"'; print ''; print '
'; print "\n"; @@ -1850,12 +1850,12 @@ if ($action == 'create') // Si active et en cours if ($objp->date_debut_reelle && !$objp->date_fin_reelle) { print $langs->trans("DateStartReal").': '; - print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); } // Si desactive if ($objp->date_debut_reelle && $objp->date_fin_reelle) { print $langs->trans("DateStartReal").': '; - print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); + print dol_print_date($db->jdate($objp->date_debut_reelle), 'day'); print '  -  '; print $langs->trans("DateEndReal").': '; print dol_print_date($db->jdate($objp->date_fin_reelle), 'day'); @@ -2092,7 +2092,7 @@ if ($action == 'create') //} } - if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) + if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0) { if ($action == 'showclosedlines') print ''; else print ''; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f31901c5ccd..acc4c8323dd 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -62,27 +62,27 @@ class Contrat extends CommonObject */ public $fk_element = 'fk_contrat'; - /** + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'contract'; - /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int - */ - public $ismultientitymanaged = 1; + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + public $ismultientitymanaged = 1; - /** - * @var int Does object support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; - /** - * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user - * @var integer - */ - public $restrictiononfksoc = 1; + /** + * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user + * @var integer + */ + public $restrictiononfksoc = 1; /** * {@inheritdoc} @@ -101,11 +101,11 @@ class Contrat extends CommonObject */ public $ref_supplier; - /** - * Entity of the contract - * @var int - */ - public $entity; + /** + * Entity of the contract + * @var int + */ + public $entity; /** * Client id linked to the contract @@ -310,7 +310,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -323,7 +323,7 @@ class Contrat extends CommonObject */ public function active_line($user, $line_id, $date, $date_end = '', $comment = '') { - // phpcs:enable + // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); if ($result < 0) { @@ -334,7 +334,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -346,7 +346,7 @@ class Contrat extends CommonObject */ public function close_line($user, $line_id, $date_end, $comment = '') { - // phpcs:enable + // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); if ($result < 0) { @@ -362,8 +362,8 @@ class Contrat extends CommonObject * * @param User $user Object User making action * @param int|string $date_start Date start (now if empty) - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @param string $comment Comment + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK * @see () */ @@ -416,8 +416,8 @@ class Contrat extends CommonObject * Close all lines of a contract * * @param User $user Object User making action - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @param string $comment Comment + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK * @see activateAll() */ @@ -436,7 +436,7 @@ class Contrat extends CommonObject { // Close lines not already closed if ($contratline->statut != ContratLigne::STATUS_CLOSED) - { + { $contratline->date_cloture = $now; $contratline->fk_user_cloture = $user->id; $contratline->statut = ContratLigne::STATUS_CLOSED; @@ -448,7 +448,7 @@ class Contrat extends CommonObject $this->errors = $contratline->errors; break; } - } + } } if (!$error && $this->statut == 0) @@ -457,14 +457,14 @@ class Contrat extends CommonObject if ($result < 0) $error++; } - if (!$error) - { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } + if (!$error) + { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } } /** @@ -472,7 +472,7 @@ class Contrat extends CommonObject * * @param User $user Objet User * @param string $force_number Reference to force on contract (not implemented yet) - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ public function validate(User $user, $force_number = '', $notrigger = 0) @@ -506,7 +506,7 @@ class Contrat extends CommonObject } else { $num = $this->ref; } - $this->newref = dol_sanitizeFileName($num); + $this->newref = dol_sanitizeFileName($num); if ($num) { @@ -526,15 +526,15 @@ class Contrat extends CommonObject // Trigger calls if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('CONTRACT_VALIDATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_VALIDATE', $user); + if ($result < 0) { $error++; } + // End call triggers } if (!$error) { - $this->oldref = $this->ref; + $this->oldref = $this->ref; // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) @@ -557,16 +557,16 @@ class Contrat extends CommonObject if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) - { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) + { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } } } } @@ -598,7 +598,7 @@ class Contrat extends CommonObject * Unvalidate a contract * * @param User $user Object User - * @param int $notrigger 1=Does not execute triggers, 0=execute triggers + * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, >0 if OK */ public function reopen($user, $notrigger = 0) @@ -671,7 +671,7 @@ class Contrat extends CommonObject $sql = "SELECT rowid, statut, ref, fk_soc,"; $sql .= " ref_supplier, ref_customer,"; $sql .= " ref_ext,"; - $sql .= " entity,"; + $sql .= " entity,"; $sql .= " date_contrat as datecontrat,"; $sql .= " fk_user_author,"; $sql .= " fk_projet as fk_project,"; @@ -713,7 +713,7 @@ class Contrat extends CommonObject $this->ref_customer = $obj->ref_customer; $this->ref_supplier = $obj->ref_supplier; $this->ref_ext = $obj->ref_ext; - $this->entity = $obj->entity; + $this->entity = $obj->entity; $this->statut = $obj->statut; $this->date_contrat = $this->db->jdate($obj->datecontrat); @@ -765,7 +765,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines array into this->lines. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed @@ -801,7 +801,7 @@ class Contrat extends CommonObject $extrafields->fetch_name_optionals_label($line->table_element, true); $this->lines = array(); - $pos = 0; + $pos = 0; // Selects contract lines related to a product $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref, p.fk_product_type as product_type,"; @@ -858,7 +858,7 @@ class Contrat extends CommonObject $line->total_ttc = $objp->total_ttc; $line->fk_product = (($objp->fk_product > 0) ? $objp->fk_product : 0); $line->info_bits = $objp->info_bits; - $line->type = $objp->type; + $line->type = $objp->type; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); @@ -871,8 +871,8 @@ class Contrat extends CommonObject $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; // Product Ref - $line->product_type = $objp->product_type; // Product Type - $line->product_desc = $objp->product_desc; // Product Description + $line->product_type = $objp->product_type; // Product Type + $line->product_desc = $objp->product_desc; // Product Description $line->product_label = $objp->product_label; // Product Label $line->description = $objp->description; @@ -896,11 +896,11 @@ class Contrat extends CommonObject $line->fetch_optionals(); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); - } + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); + } $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; @@ -914,8 +914,8 @@ class Contrat extends CommonObject if ($line->statut == ContratLigne::STATUS_CLOSED) $this->nbofservicesclosed++; $total_ttc += $objp->total_ttc; // TODO Not saved into database - $total_vat += $objp->total_tva; - $total_ht += $objp->total_ht; + $total_vat += $objp->total_tva; + $total_ht += $objp->total_ht; $i++; $pos++; @@ -927,9 +927,9 @@ class Contrat extends CommonObject } $this->nbofservices = count($this->lines); - $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_tva = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_tva = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products return $this->lines; } @@ -1027,15 +1027,15 @@ class Contrat extends CommonObject // Insert business contacts ('SALESREPSIGN','contrat') if (!$error) { - $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); - if ($result < 0) $error++; + $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); + if ($result < 0) $error++; } // Insert business contacts ('SALESREPFOLL','contrat') if (!$error) { - $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); - if ($result < 0) $error++; + $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); + if ($result < 0) $error++; } if (!$error) @@ -1046,78 +1046,78 @@ class Contrat extends CommonObject } // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } - } + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + { + foreach ($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach ($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } + } + } - if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object - { - $originforcontact = $this->origin; - $originidforcontact = $this->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order - { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - $exp = new Expedition($this->db); - $exp->fetch($this->origin_id); - $exp->fetchObjectLinked(); - if (count($exp->linkedObjectsIds['commande']) > 0) - { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) - { - $originforcontact = 'commande'; - $originidforcontact = $value->id; - break; // We take first one - } - } - } + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object + { + $originforcontact = $this->origin; + $originidforcontact = $this->origin_id; + if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order + { + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + $exp = new Expedition($this->db); + $exp->fetch($this->origin_id); + $exp->fetchObjectLinked(); + if (count($exp->linkedObjectsIds['commande']) > 0) + { + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) + { + $originforcontact = 'commande'; + $originidforcontact = $value->id; + break; // We take first one + } + } + } - $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; - $resqlcontact = $this->db->query($sqlcontact); - if ($resqlcontact) - { - while ($objcontact = $this->db->fetch_object($resqlcontact)) - { - if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously + $resqlcontact = $this->db->query($sqlcontact); + if ($resqlcontact) + { + while ($objcontact = $this->db->fetch_object($resqlcontact)) + { + if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously - //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object - } - } else dol_print_error($resqlcontact); - } + //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + } + } else dol_print_error($resqlcontact); + } } if (!$error) { - // Call trigger - $result = $this->call_trigger('CONTRACT_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers if (!$error) { @@ -1158,10 +1158,10 @@ class Contrat extends CommonObject $this->db->begin(); - // Call trigger - $result = $this->call_trigger('CONTRACT_DELETE', $user); - if ($result < 0) { $error++; } - // End call triggers + // Call trigger + $result = $this->call_trigger('CONTRACT_DELETE', $user); + if ($result < 0) { $error++; } + // End call triggers if (!$error) { @@ -1225,7 +1225,7 @@ class Contrat extends CommonObject } if (!$error) - { + { // Delete contratdet extrafields $main = MAIN_DB_PREFIX.'contratdet'; $ef = $main."_extrafields"; @@ -1346,7 +1346,7 @@ class Contrat extends CommonObject // Put here code to add a control on parameters values // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; $sql .= " ref_supplier=".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "null").","; @@ -1468,7 +1468,7 @@ class Contrat extends CommonObject if (empty($pu_ttc)) $pu_ttc = 0; if (empty($txtva) || !is_numeric($txtva)) $txtva = 0; if (empty($txlocaltax1) || !is_numeric($txlocaltax1)) $txlocaltax1 = 0; - if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; + if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; if ($price_base_type == 'HT') { @@ -1515,7 +1515,7 @@ class Contrat extends CommonObject $price = $pu_ht - $remise; } - if (empty($pa_ht)) $pa_ht = 0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin @@ -1582,13 +1582,13 @@ class Contrat extends CommonObject } if (empty($error)) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_INSERT', $user); - if ($result < 0) - { - $error++; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_INSERT', $user); + if ($result < 0) + { + $error++; + } + // End call triggers } if ($error) @@ -1694,11 +1694,11 @@ class Contrat extends CommonObject $price = price2num(round($pu, 2)); if (dol_strlen($remise_percent) > 0) { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; + $remise = round(($pu * $remise_percent / 100), 2); + $price = $pu - $remise; } - if (empty($pa_ht)) $pa_ht = 0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -1763,14 +1763,14 @@ class Contrat extends CommonObject } if (empty($error)) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -3; - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -3; + } + // End call triggers $this->db->commit(); return 1; @@ -1803,14 +1803,14 @@ class Contrat extends CommonObject if ($this->statut >= 0) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_DELETE', $user); - if ($result < 0) return -1; - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_DELETE', $user); + if ($result < 0) return -1; + // End call triggers - $this->db->begin(); + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE rowid=".$idline; dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); @@ -1848,7 +1848,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update statut of contract according to services * @@ -1858,7 +1858,7 @@ class Contrat extends CommonObject */ public function update_statut($user) { - // phpcs:enable + // phpcs:enable dol_syslog(__METHOD__." is deprecated", LOG_WARNING); // If draft, we keep it (should not happen) @@ -1867,11 +1867,11 @@ class Contrat extends CommonObject // Load $this->lines array // $this->fetch_lines(); - // $newstatut=1; - // foreach($this->lines as $key => $contractline) - // { - // // if ($contractline) // Loop on each service - // } + // $newstatut=1; + // foreach($this->lines as $key => $contractline) + // { + // // if ($contractline) // Loop on each service + // } return 1; } @@ -1888,7 +1888,7 @@ class Contrat extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi label of a given contrat status * @@ -1898,7 +1898,7 @@ class Contrat extends CommonObject */ public function LibStatut($status, $mode) { - // phpcs:enable + // phpcs:enable global $langs; if (empty($this->labelStatus) || empty($this->labelStatusShort)) @@ -1947,11 +1947,11 @@ class Contrat extends CommonObject * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlength Max length of ref - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user, $hookmanager; @@ -1967,35 +1967,35 @@ class Contrat extends CommonObject if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} - $label = ''; + $label = ''; - if ($user->rights->contrat->lire) { - $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; - $label .= '
'.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); - $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); - $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - } + if ($user->rights->contrat->lire) { + $label = img_picto('', $this->picto).' '.$langs->trans("Contract").''; + $label .= '
'.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); + $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); + $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; + if (!empty($this->total_ht)) { + $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + } - $linkclose = ''; - if (empty($notooltip) && $user->rights->contrat->lire) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label = $langs->trans("ShowOrder"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; - } + $linkclose = ''; + if (empty($notooltip) && $user->rights->contrat->lire) + { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label = $langs->trans("ShowOrder"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; + } $linkstart = ''; @@ -2059,7 +2059,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of line rowid * @@ -2068,7 +2068,7 @@ class Contrat extends CommonObject */ public function array_detail($status = -1) { - // phpcs:enable + // phpcs:enable $tab = array(); $sql = "SELECT cd.rowid"; @@ -2132,17 +2132,17 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load indicators for dashboard (this->nbtodo and this->nbtodolate) - * - * @param User $user Objet user - * @param string $mode "inactive" pour services a activer, "expired" pour services expires - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * Load indicators for dashboard (this->nbtodo and this->nbtodolate) + * + * @param User $user Objet user + * @param string $mode "inactive" pour services a activer, "expired" pour services expires + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board($user, $mode) + public function load_board($user, $mode) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; @@ -2167,13 +2167,13 @@ class Contrat extends CommonObject $sql .= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; } elseif ($mode == 'active') { - $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; - $sql .= $this->from; - $sql .= " WHERE c.statut = 1"; - $sql .= " AND c.rowid = cd.fk_contrat"; - $sql .= " AND cd.statut = 4"; - //$datetouse = dol_now(); - //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'"; + $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 4"; + //$datetouse = dol_now(); + //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'"; } $sql .= " AND c.fk_soc = s.rowid"; $sql .= " AND c.entity = ".$conf->entity; @@ -2192,10 +2192,10 @@ class Contrat extends CommonObject $labelShort = $langs->trans("BoardNotActivatedServicesShort"); $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc'; } elseif ($mode == 'expired') { - $warning_delay = $conf->contrat->services->expires->warning_delay; - $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; - $label = $langs->trans("BoardExpiredServices"); - $labelShort = $langs->trans("BoardExpiredServicesShort"); + $warning_delay = $conf->contrat->services->expires->warning_delay; + $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; + $label = $langs->trans("BoardExpiredServices"); + $labelShort = $langs->trans("BoardExpiredServicesShort"); } else { $warning_delay = $conf->contrat->services->expires->warning_delay; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&sortfield=cd.date_fin_validite&sortorder=asc'; @@ -2229,7 +2229,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @@ -2237,7 +2237,7 @@ class Contrat extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable global $conf, $user; $this->nb = array(); @@ -2261,7 +2261,7 @@ class Contrat extends CommonObject { $this->nb["contracts"] = $obj->nb; } - $this->db->free($resql); + $this->db->free($resql); return 1; } else { dol_print_error($this->db); @@ -2295,17 +2295,17 @@ class Contrat extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() - { + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { global $user, $langs, $conf; - // Load array of products prodids + // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; @@ -2362,10 +2362,10 @@ class Contrat extends CommonObject $line->date_end = dol_now() + 500000; $line->date_end_real = dol_now() - 100000; if ($num_prods > 0) - { + { $prodid = mt_rand(1, $num_prods); $line->fk_product = $prodids[$prodid]; - } + } $this->lines[$xnbp] = $line; $xnbp++; } @@ -2390,7 +2390,7 @@ class Contrat extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -2440,8 +2440,8 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int New id of clone */ - public function createFromClone(User $user, $socid = 0, $notrigger = 0) - { + public function createFromClone(User $user, $socid = 0, $notrigger = 0) + { global $db, $langs, $conf, $hookmanager, $extrafields; dol_include_once('/projet/class/project.class.php'); @@ -2452,7 +2452,7 @@ class Contrat extends CommonObject // Load dest object $clonedObj = clone $this; - $clonedObj->socid = $socid; + $clonedObj->socid = $socid; $this->db->begin(); @@ -2503,13 +2503,13 @@ class Contrat extends CommonObject $this->error = $clonedObj->error; $this->errors[] = $clonedObj->error; } else { - // copy external contacts if same company - if ($this->socid == $clonedObj->socid) { - if ($clonedObj->copy_linked_contact($this, 'external') < 0) { - $error++; - } - } - } + // copy external contacts if same company + if ($this->socid == $clonedObj->socid) { + if ($clonedObj->copy_linked_contact($this, 'external') < 0) { + $error++; + } + } + } if (!$error) { foreach ($this->lines as $line) { @@ -2555,12 +2555,12 @@ class Contrat extends CommonObject */ class ContratLigne extends CommonObjectLine { - /** + /** * @var string ID to identify managed object */ public $element = 'contratdet'; - /** + /** * @var string Name of table without prefix where object is stored */ public $table_element = 'contratdet'; @@ -2578,13 +2578,13 @@ class ContratLigne extends CommonObjectLine public $tms; /** - * @var int ID - */ + * @var int ID + */ public $fk_contrat; /** - * @var int ID - */ + * @var int ID + */ public $fk_product; public $statut; // 0 inactive, 4 active, 5 closed @@ -2607,7 +2607,7 @@ class ContratLigne extends CommonObjectLine */ public $description; - public $product_type; // 0 for product, 1 for service + public $product_type; // 0 for product, 1 for service public $product_ref; public $product_label; @@ -2632,8 +2632,8 @@ class ContratLigne extends CommonObjectLine public $remise; /** - * @var int ID - */ + * @var int ID + */ public $fk_remise_except; public $subprice; // Unit price HT @@ -2654,8 +2654,8 @@ class ContratLigne extends CommonObjectLine public $total_ttc; /** - * @var int ID - */ + * @var int ID + */ public $fk_fournprice; public $pa_ht; @@ -2663,18 +2663,18 @@ class ContratLigne extends CommonObjectLine public $info_bits; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_ouverture; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_cloture; public $commentaire; @@ -2686,9 +2686,9 @@ class ContratLigne extends CommonObjectLine /** - * Constructor - * - * @param DoliDb $db Database handler + * Constructor + * + * @param DoliDb $db Database handler */ public function __construct($db) { @@ -2707,7 +2707,7 @@ class ContratLigne extends CommonObjectLine return $this->LibStatut($this->statut, $mode, ((!empty($this->date_fin_validite)) ? ($this->date_fin_validite < dol_now() ? 1 : 0) : -1)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a contract line status * @@ -2719,26 +2719,26 @@ class ContratLigne extends CommonObjectLine */ public static function LibStatut($status, $mode, $expired = -1, $moreatt = '') { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("contracts"); - if ($status == self::STATUS_INITIAL) { - $labelStatus = $langs->trans("ServiceStatusInitial"); - $labelStatusShort = $langs->trans("ServiceStatusInitial"); - } elseif ($status == self::STATUS_OPEN && $expired == -1) { - $labelStatus = $langs->trans("ServiceStatusRunning"); - $labelStatusShort = $langs->trans("ServiceStatusRunning"); - } elseif ($status == self::STATUS_OPEN && $expired == 0) { - $labelStatus = $langs->trans("ServiceStatusNotLate"); - $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); - } elseif ($status == self::STATUS_OPEN && $expired == 1) { - $labelStatus = $langs->trans("ServiceStatusLate"); - $labelStatusShort = $langs->trans("ServiceStatusLateShort"); - } elseif ($status == self::STATUS_CLOSED) { - $labelStatus = $langs->trans("ServiceStatusClosed"); - $labelStatusShort = $langs->trans("ServiceStatusClosed"); - } + if ($status == self::STATUS_INITIAL) { + $labelStatus = $langs->trans("ServiceStatusInitial"); + $labelStatusShort = $langs->trans("ServiceStatusInitial"); + } elseif ($status == self::STATUS_OPEN && $expired == -1) { + $labelStatus = $langs->trans("ServiceStatusRunning"); + $labelStatusShort = $langs->trans("ServiceStatusRunning"); + } elseif ($status == self::STATUS_OPEN && $expired == 0) { + $labelStatus = $langs->trans("ServiceStatusNotLate"); + $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); + } elseif ($status == self::STATUS_OPEN && $expired == 1) { + $labelStatus = $langs->trans("ServiceStatusLate"); + $labelStatusShort = $langs->trans("ServiceStatusLateShort"); + } elseif ($status == self::STATUS_CLOSED) { + $labelStatus = $langs->trans("ServiceStatusClosed"); + $labelStatusShort = $langs->trans("ServiceStatusClosed"); + } $statusType = 'status'.$status; if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status1'; @@ -2758,22 +2758,22 @@ class ContratLigne extends CommonObjectLine * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlength Max length * @return string Chaine avec URL - */ - public function getNomUrl($withpicto = 0, $maxlength = 0) + */ + public function getNomUrl($withpicto = 0, $maxlength = 0) { global $langs; $result = ''; - $label = $langs->trans("ShowContractOfService").': '.$this->label; - if (empty($label)) $label = $this->description; + $label = $langs->trans("ShowContractOfService").': '.$this->label; + if (empty($label)) $label = $this->description; - $link = ''; + $link = ''; $linkend = ''; $picto = 'service'; if ($this->type == 0) $picto = 'product'; - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result .= $link.($this->product_ref ? $this->product_ref.' ' : '').($this->label ? $this->label : $this->description).$linkend; return $result; @@ -2786,7 +2786,7 @@ class ContratLigne extends CommonObjectLine * @param string $ref Ref of contract line * @return int <0 if KO, >0 if OK */ - public function fetch($id, $ref = '') + public function fetch($id, $ref = '') { // Check parameters if (empty($id) && empty($ref)) return -1; @@ -2981,7 +2981,7 @@ class ContratLigne extends CommonObjectLine $this->total_localtax1 = $tabprice[9]; $this->total_localtax2 = $tabprice[10]; - if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->pa_ht)) $this->pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -2999,7 +2999,7 @@ class ContratLigne extends CommonObjectLine $this->oldcopy = new ContratLigne($this->db); $this->oldcopy->fetch($this->id); - $this->oldcopy->fetch_optionals(); + $this->oldcopy->fetch_optionals(); // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; @@ -3087,18 +3087,18 @@ class ContratLigne extends CommonObjectLine } if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); - if ($result < 0) { - $error++; - $this->db->rollback(); - } - // End call triggers + // Call trigger + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); + if ($result < 0) { + $error++; + $this->db->rollback(); + } + // End call triggers } if (!$error) { - $this->db->commit(); + $this->db->commit(); return 1; } else { $this->db->rollback(); @@ -3108,7 +3108,7 @@ class ContratLigne extends CommonObjectLine } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base des champs total_xxx de ligne * Used by migration process @@ -3117,7 +3117,7 @@ class ContratLigne extends CommonObjectLine */ public function update_total() { - // phpcs:enable + // phpcs:enable $this->db->begin(); // Mise a jour ligne en base @@ -3224,7 +3224,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -3236,7 +3236,7 @@ class ContratLigne extends CommonObjectLine */ public function active_line($user, $date, $date_end = '', $comment = '') { - // phpcs:enable + // phpcs:enable global $langs, $conf; $error = 0; @@ -3281,19 +3281,19 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * * @param User $user Objet User who close contract * @param int $date_end Date end * @param string $comment A comment typed by user - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ public function close_line($user, $date_end, $comment = '', $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $langs, $conf; // Update object diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 4f69d5a2c56..24b0ff54bf6 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -60,11 +60,11 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) { $result = $object->fetch($id); - if ($result > 0 && $id > 0) - { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } + } if ($result >= 0) { @@ -87,7 +87,7 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer) { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db, $object->error); } @@ -130,7 +130,7 @@ if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); - $head = contract_prepare_head($object); + $head = contract_prepare_head($object); $hselected = 1; @@ -138,13 +138,13 @@ if ($id > 0 || !empty($ref)) // Contract card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = ''; - //if (! empty($modCodeContract->code_auto)) { - $morehtmlref .= $object->ref; - /*} else { + $morehtmlref = ''; + //if (! empty($modCodeContract->code_auto)) { + $morehtmlref .= $object->ref; + /*} else { $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); }*/ @@ -158,67 +158,67 @@ if ($id > 0 || !empty($ref)) $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } - $morehtmlref .= '
'; + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->contrat->creer) { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } + $morehtmlref .= ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; print ''; - // Ligne info remises tiers - print ''; + // Ligne info remises tiers + print ''; - // Date - print ''; + // Date + print ''; print ''; - print ''; - print ''; - print "\n"; - } - if ($status == 4 && !$bool) $bool = true; - else $bool = false; + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + print "\n"; + } + if ($status == 4 && !$bool) $bool = true; + else $bool = false; } if (!empty($conf->use_javascript_ajax)) { - print ''; + print ''; } $listofstatus = array(0, 4, 4, 5); $bool = false; foreach ($listofstatus as $status) { - if (empty($conf->use_javascript_ajax)) - { - print ''; - print ''; - print ''; - if ($status == 4 && !$bool) $bool = true; - else $bool = false; - print "\n"; - } + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + if ($status == 4 && !$bool) $bool = true; + else $bool = false; + print "\n"; + } } //if ($totalinprocess != $total) //print ''; @@ -424,15 +424,15 @@ if ($resql) print ''; print ''; + print ''; print ''; print ''; + print ''; } if (!empty($arrayfields['c.ref_supplier']['checked'])) { diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index 0368340bffd..c9000c4fb0d 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -72,101 +72,101 @@ $form = new Form($db); if ($id > 0 || !empty($ref)) { - $object->fetch_thirdparty(); + $object->fetch_thirdparty(); - $head = contract_prepare_head($object); + $head = contract_prepare_head($object); - $hselected = 2; + $hselected = 2; - print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract'); + print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract'); - // Contract card + // Contract card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = ''; - //if (! empty($modCodeContract->code_auto)) { - $morehtmlref .= $object->ref; - /*} else { + $morehtmlref = ''; + //if (! empty($modCodeContract->code_auto)) { + $morehtmlref .= $object->ref; + /*} else { $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3); $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2); }*/ - $morehtmlref .= '
'; - // Ref customer - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); - // Ref supplier - $morehtmlref .= '
'; - $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); - // Thirdparty - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->contrat->creer) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } - } - } - $morehtmlref .= '
'; + $morehtmlref .= '
'; + // Ref customer + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); + // Ref supplier + $morehtmlref .= '
'; + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); + // Thirdparty + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->contrat->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) { - print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); - } else { - print $langs->trans("CompanyHasNoRelativeDiscount"); - } - $absolute_discount = $object->thirdparty->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
'.$langs->trans('Discount').''; + if ($object->thirdparty->remise_percent) { + print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); + } else { + print $langs->trans("CompanyHasNoRelativeDiscount"); + } + $absolute_discount = $object->thirdparty->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
'; print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); print ''; diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 759c2080930..b68da3170ed 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -179,20 +179,20 @@ if ($object->id) print '
'; print '
'; - print ''; - print ''; - print ''; - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''; + print ''; + print ''; + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; - print '
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - $modulepart = 'contract'; - $permission = $user->rights->contrat->creer; - $permtoedit = $user->rights->contrat->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; + $modulepart = 'contract'; + $permission = $user->rights->contrat->creer; + $permtoedit = $user->rights->contrat->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { print $langs->trans("ErrorUnknown"); } diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 7fe88d03c3d..5ea558c9689 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -80,21 +80,21 @@ print '
'; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - // Search contract - if (!empty($conf->contrat->enabled)) - { - print '
'; - print ''; + // Search contract + if (!empty($conf->contrat->enabled)) + { + print ''; + print ''; print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print "
'.$langs->trans("Search").'
'.$langs->trans("Contract").':
\n"; - print "
"; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print "
'.$langs->trans("Search").'
'.$langs->trans("Contract").':
\n"; + print "
"; + } } @@ -131,11 +131,11 @@ if ($resql) { $nb[$obj->status] = $obj->nb; if ($obj->status != 5) - { - $vals[$obj->status] = $obj->nb; - $totalinprocess += $obj->nb; - } - $total += $obj->nb; + { + $vals[$obj->status] = $obj->nb; + $totalinprocess += $obj->nb; + } + $total += $obj->nb; } $i++; } @@ -159,24 +159,24 @@ if ($resql) { $num = $db->num_rows($resql); - // 0 inactive, 4 active, 5 closed - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - $nb[$obj->status.true] = $obj->nb; - if ($obj->status != 5) - { - $vals[$obj->status.true] = $obj->nb; - $totalinprocess += $obj->nb; - } - $total += $obj->nb; - } - $i++; - } - $db->free($resql); + // 0 inactive, 4 active, 5 closed + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $nb[$obj->status.true] = $obj->nb; + if ($obj->status != 5) + { + $vals[$obj->status.true] = $obj->nb; + $totalinprocess += $obj->nb; + } + $total += $obj->nb; + } + $i++; + } + $db->free($resql); } else { dol_print_error($db); } @@ -191,51 +191,51 @@ print '
'.$langs->trans("Statistics").' - $listofstatus = array(0, 4, 4, 5); $bool = false; foreach ($listofstatus as $status) { - $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); - if ($status == ContratLigne::STATUS_INITIAL) $colorseries[$status.$bool] = '-'.$badgeStatus0; - if ($status == ContratLigne::STATUS_OPEN && !$bool) $colorseries[$status.$bool] = $badgeStatus4; - if ($status == ContratLigne::STATUS_OPEN && $bool) $colorseries[$status.$bool] = $badgeStatus1; - if ($status == ContratLigne::STATUS_CLOSED) $colorseries[$status.$bool] = $badgeStatus6; + $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); + if ($status == ContratLigne::STATUS_INITIAL) $colorseries[$status.$bool] = '-'.$badgeStatus0; + if ($status == ContratLigne::STATUS_OPEN && !$bool) $colorseries[$status.$bool] = $badgeStatus4; + if ($status == ContratLigne::STATUS_OPEN && $bool) $colorseries[$status.$bool] = $badgeStatus1; + if ($status == ContratLigne::STATUS_CLOSED) $colorseries[$status.$bool] = $badgeStatus6; - if (empty($conf->use_javascript_ajax)) - { - print '
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'; + print '
'; - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); - print '
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'.$langs->trans("Total").' ('.$langs->trans("ServicesRunning").')'.$totalinprocess.'
'; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } print ''; @@ -500,17 +500,17 @@ if ($resql) print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } - print ''; $staticcompany->id = $obj->fk_soc; $staticcompany->name = $obj->name; @@ -576,15 +576,15 @@ if ($resql) print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; - print $productstatic->getNomUrl(1, '', 20); + print $productstatic->getNomUrl(1, '', 20); } else { - print ''.img_object($langs->trans("ShowService"), "service"); - if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; - else print ' '.dol_trunc($obj->note, 20); + print ''.img_object($langs->trans("ShowService"), "service"); + if ($obj->label) print ' '.dol_trunc($obj->label, 20).''; + else print ' '.dol_trunc($obj->note, 20); } print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 04329a63145..18b47b7102a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -363,7 +363,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), - 'presend'=>$langs->trans("SendByMail"), + 'presend'=>$langs->trans("SendByMail"), ); if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -579,13 +579,13 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$ $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['c.datec']['checked'])) { - print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['c.tms']['checked'])) { - print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } if (!empty($arrayfields['lower_planned_end_date']['checked'])) { - print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['status']['checked'])) { print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); @@ -634,7 +634,7 @@ while ($i < min($num, $limit)) if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).'
'; + print '
'; - // Ligne info remises tiers - print ''; + // Ligne info remises tiers + print ''; - // Date - print ''; - print ''; - print ''; + // Date + print ''; + print ''; + print ''; print "
'.$langs->trans('Discount').''; - if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount = $object->thirdparty->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
'.$langs->trans('Discount').''; + if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount = $object->thirdparty->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
'; - print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); - print ''; - print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker'); - print '
'; + print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0); + print ''; + print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker'); + print '
"; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 7279ab98781..67b605d657f 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -245,30 +245,30 @@ if ($search_contract) $sql .= " AND c.ref LIKE '%".$db->escape($search_contract) if ($search_service) $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; if ($socid > 0) $sql .= " AND s.rowid = ".$socid; -$filter_dateouvertureprevue_start=dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); -$filter_dateouvertureprevue_end=dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +$filter_dateouvertureprevue_start = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +$filter_dateouvertureprevue_end = dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); if ($filter_dateouvertureprevue_start != '' && $filter_opouvertureprevue == -1) $filter_opouvertureprevue = ' BETWEEN '; -$filter_date1_start =dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); -$filter_date1_end =dol_mktime(23, 59, 59, $op1month, $op1day, $op1year); +$filter_date1_start = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); +$filter_date1_end = dol_mktime(23, 59, 59, $op1month, $op1day, $op1year); if ($filter_date1_start != '' && $filter_op1 == -1) $filter_op1 = ' BETWEEN '; -$filter_date2_start=dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); -$filter_date2_end=dol_mktime(23, 59, 59, $op2month, $op2day, $op2year); +$filter_date2_start = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); +$filter_date2_end = dol_mktime(23, 59, 59, $op2month, $op2day, $op2year); if ($filter_date2_start != '' && $filter_op2 == -1) $filter_op2 = ' BETWEEN '; -$filter_datecloture_start=dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); -$filter_datecloture_end=dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear); +$filter_datecloture_start = dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); +$filter_datecloture_end = dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear); if ($filter_datecloture_start != '' && $filter_opcloture == -1) $filter_opcloture = ' BETWEEN '; -if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') $sql.= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; -if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') $sql.= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; -if (! empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') $sql.= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; -if (! empty($filter_op1) && $filter_op1==' BETWEEN ') $sql.= " AND '".$db->idate($filter_date1_end)."'"; -if (! empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') $sql.= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; -if (! empty($filter_op2) && $filter_op2==' BETWEEN ') $sql.= " AND '".$db->idate($filter_date2_end)."'"; -if (! empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; -if (! empty($filter_opcloture) && $filter_opcloture==' BETWEEN ') $sql.= " AND '".$db->idate($filter_datecloture_end)."'"; +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue != ' BETWEEN ' && $filter_dateouvertureprevue_start != '') $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue_start)."'"; +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_dateouvertureprevue_end)."'"; +if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 != ' BETWEEN ' && $filter_date1_start != '') $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1_start)."'"; +if (!empty($filter_op1) && $filter_op1 == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_date1_end)."'"; +if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 != ' BETWEEN ' && $filter_date2_start != '') $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2_start)."'"; +if (!empty($filter_op2) && $filter_op2 == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_date2_end)."'"; +if (!empty($filter_opcloture) && $filter_opcloture != ' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start != '') $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture_start)."'"; +if (!empty($filter_opcloture) && $filter_opcloture == ' BETWEEN ') $sql .= " AND '".$db->idate($filter_datecloture_end)."'"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $sql .= $db->order($sortfield, $sortorder); @@ -581,7 +581,7 @@ while ($i < min($num, $limit)) print ''; print $contractstatic->getNomUrl(1, 16); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Service if (!empty($arrayfields['p.description']['checked'])) @@ -601,7 +601,7 @@ while ($i < min($num, $limit)) if ($obj->type == 1) print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24); } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.qty']['checked'])) @@ -609,39 +609,39 @@ while ($i < min($num, $limit)) print ''; print $obj->qty; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.total_ht']['checked'])) { print ''; print price($obj->total_ht); print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; - $totalarray['val']['cd.total_ht'] += $obj->total_ht; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; + $totalarray['val']['cd.total_ht'] += $obj->total_ht; + } if (!empty($arrayfields['cd.total_tva']['checked'])) { print ''; print price($obj->total_tva); print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; - $totalarray['val']['cd.total_tva'] += $obj->total_tva; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; + $totalarray['val']['cd.total_tva'] += $obj->total_tva; + } if (!empty($arrayfields['cd.tva_tx']['checked'])) { print ''; print price2num($obj->tva_tx).'%'; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.subprice']['checked'])) { print ''; print price($obj->subprice); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } @@ -651,7 +651,7 @@ while ($i < min($num, $limit)) print ''; print $companystatic->getNomUrl(1, 'customer', 28); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Start date @@ -663,12 +663,12 @@ while ($i < min($num, $limit)) print ' '.img_picto($langs->trans("Late"), "warning"); else print '    '; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['cd.date_ouverture']['checked'])) { print ''.($obj->date_ouverture ?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour') : ' ').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // End date if (!empty($arrayfields['cd.date_fin_validite']['checked'])) @@ -681,13 +681,13 @@ while ($i < min($num, $limit)) print img_warning($textlate); } else print '    '; print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Close date (real end date) if (!empty($arrayfields['cd.date_cloture']['checked'])) { print ''.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').''; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields @@ -715,16 +715,16 @@ while ($i < min($num, $limit)) // Status if (!empty($arrayfields['status']['checked'])) { - print ''; - if ($obj->cstatut == 0) - { + print ''; + if ($obj->cstatut == 0) + { // If contract is draft, we say line is also draft - print $contractstatic->LibStatut(0, 5); - } else { - print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); - } - print ''; - if (!$i) $totalarray['nbfield']++; + print $contractstatic->LibStatut(0, 5); + } else { + print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); + } + print ''; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index 57b885f24d2..339f51db22c 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -39,10 +39,10 @@ $langs->load("contracts"); $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { - $ilink++; + $ilink++; - $trclass = 'oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; ?> trans("Contract"); ?> @@ -58,7 +58,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) $totalcontrat = 0; foreach ($objectlink->lines as $linecontrat) { $totalcontrat = $totalcontrat + $linecontrat->total_ht; - $total = $total + $linecontrat->total_ht; + $total = $total + $linecontrat->total_ht; } echo price($totalcontrat); } ?> diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 20bd19625cc..4ae83829fa4 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -34,102 +34,102 @@ if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $pe // Build doc if ($action == 'builddoc' && $permissiontoadd) { - if (is_numeric(GETPOST('model', 'alpha'))) - { - $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); - } else { + if (is_numeric(GETPOST('model', 'alpha'))) + { + $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); + } else { // Reload to get all modified line records and be ready for hooks - $ret = $object->fetch($id); - $ret = $object->fetch_thirdparty(); - /*if (empty($object->id) || ! $object->id > 0) + $ret = $object->fetch($id); + $ret = $object->fetch_thirdparty(); + /*if (empty($object->id) || ! $object->id > 0) { dol_print_error('Object must have been loaded by a fetch'); exit; }*/ - // Save last template used to generate document - if (GETPOST('model', 'alpha')) - { - $object->setDocModel($user, GETPOST('model', 'alpha')); - } + // Save last template used to generate document + if (GETPOST('model', 'alpha')) + { + $object->setDocModel($user, GETPOST('model', 'alpha')); + } - // Special case to force bank account - //if (property_exists($object, 'fk_bank')) - //{ - if (GETPOST('fk_bank', 'int')) { - // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank', 'int'); - } elseif (!empty($object->fk_account)) { - $object->fk_bank = $object->fk_account; - } - //} + // Special case to force bank account + //if (property_exists($object, 'fk_bank')) + //{ + if (GETPOST('fk_bank', 'int')) { + // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank', 'int'); + } elseif (!empty($object->fk_account)) { + $object->fk_bank = $object->fk_account; + } + //} - $outputlangs = $langs; - $newlang = ''; + $outputlangs = $langs; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + // To be sure vars is defined + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } else { - if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" - { - setEventMessages($langs->trans("FileGenerated"), null); + $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } else { + if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders" + { + setEventMessages($langs->trans("FileGenerated"), null); - $urltoredirect = $_SERVER['REQUEST_URI']; - $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop + $urltoredirect = $_SERVER['REQUEST_URI']; + $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); + $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop - header('Location: '.$urltoredirect.'#builddoc'); - exit; - } - } - } + header('Location: '.$urltoredirect.'#builddoc'); + exit; + } + } + } } // Delete file in doc form if ($action == 'remove_file' && $permissiontoadd) { if (!empty($upload_dir)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (empty($object->id) || !$object->id > 0) - { - // Reload to get all modified line records and be ready for hooks - $ret = $object->fetch($id); - $ret = $object->fetch_thirdparty(); - } + if (empty($object->id) || !$object->id > 0) + { + // Reload to get all modified line records and be ready for hooks + $ret = $object->fetch($id); + $ret = $object->fetch_thirdparty(); + } - $langs->load("other"); - $filetodelete = GETPOST('file', 'alpha'); - $file = $upload_dir.'/'.$filetodelete; - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); + $langs->load("other"); + $filetodelete = GETPOST('file', 'alpha'); + $file = $upload_dir.'/'.$filetodelete; + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); - // Make a redirect to avoid to keep the remove_file into the url that create side effects - $urltoredirect = $_SERVER['REQUEST_URI']; - $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=remove_file&?/', '', $urltoredirect); + // Make a redirect to avoid to keep the remove_file into the url that create side effects + $urltoredirect = $_SERVER['REQUEST_URI']; + $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); + $urltoredirect = preg_replace('/action=remove_file&?/', '', $urltoredirect); - header('Location: '.$urltoredirect); - exit; + header('Location: '.$urltoredirect); + exit; } else { setEventMessages('BugFoundVarUploaddirnotDefined', null, 'errors'); } diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php index f4e7f01d234..4daf53891cf 100644 --- a/htdocs/core/actions_changeselectedfields.inc.php +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -30,17 +30,17 @@ // Save selection if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields') { - $tabparam = array(); + $tabparam = array(); - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); - else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; + if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields"); + else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = ''; - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result = dol_set_user_param($db, $conf, $user, $tabparam); + $result = dol_set_user_param($db, $conf, $user, $tabparam); - //$action='list'; - //var_dump($tabparam);exit; + //$action='list'; + //var_dump($tabparam);exit; } diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index 079f207b4a4..f590adee197 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -57,19 +57,19 @@ if ($action == 'addcomment') } if ($action === 'updatecomment') { - if ($comment->fetch($idcomment) >= 0) - { - $comment->description = GETPOST('comment_description', 'restricthtml'); - if ($comment->update($user) > 0) - { - setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); - header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); - exit; - } else { - setEventMessages($comment->error, $comment->errors, 'errors'); - $action = ''; - } - } + if ($comment->fetch($idcomment) >= 0) + { + $comment->description = GETPOST('comment_description', 'restricthtml'); + if ($comment->update($user) > 0) + { + setEventMessages($langs->trans("CommentAdded"), null, 'mesgs'); + header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : '')); + exit; + } else { + setEventMessages($comment->error, $comment->errors, 'errors'); + $action = ''; + } + } } if ($action == 'deletecomment') { diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 46a6a31c202..c8c4f4db5d0 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -42,7 +42,7 @@ if ($action == 'add') { if ($_POST["button"] != $langs->trans("Cancel")) { - // Check values + // Check values if (!$type) { $error++; @@ -52,156 +52,156 @@ if ($action == 'add') } if ($type == 'varchar' && $extrasize <= 0) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); - $action = 'edit'; + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $action = 'edit'; + } + if ($type == 'varchar' && $extrasize > $maxsizestring) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $action = 'create'; + } + if ($type == 'int' && $extrasize > $maxsizeint) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $action = 'create'; + } + if ($type == 'select' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $action = 'create'; + } + if ($type == 'sellist' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $action = 'create'; + } + if ($type == 'checkbox' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $action = 'create'; + } + if ($type == 'link' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForLinkType"); + $action = 'create'; + } + if ($type == 'radio' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $action = 'create'; + } + if ((($type == 'radio') || ($type == 'checkbox')) && $param) + { + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + foreach ($parameters_array as $param_ligne) + { + if (!empty($param_ligne)) { + if (preg_match_all('/,/', $param_ligne, $matches)) + { + if (count($matches[0]) > 1) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'create'; + } + } else { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'create'; + } + } + } } - if ($type == 'varchar' && $extrasize > $maxsizestring) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); - $action = 'create'; - } - if ($type == 'int' && $extrasize > $maxsizeint) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); - $action = 'create'; - } - if ($type == 'select' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); - $action = 'create'; - } - if ($type == 'sellist' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); - $action = 'create'; - } - if ($type == 'checkbox' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); - $action = 'create'; - } - if ($type == 'link' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForLinkType"); - $action = 'create'; - } - if ($type == 'radio' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); - $action = 'create'; - } - if ((($type == 'radio') || ($type == 'checkbox')) && $param) - { - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - foreach ($parameters_array as $param_ligne) - { - if (!empty($param_ligne)) { - if (preg_match_all('/,/', $param_ligne, $matches)) - { - if (count($matches[0]) > 1) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'create'; - } - } else { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'create'; - } - } - } - } - if (!$error) - { - // attrname must be alphabetical and lower case only - if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) - { - // Construct array for parameter (value of select list) - $default_value = GETPOST('default_value', 'alpha'); - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - //In sellist we have only one line and it can have come to do SQL expression - if ($type == 'sellist') { - foreach ($parameters_array as $param_ligne) - { - $params['options'] = array($parameters=>null); - } - } else { - //Esle it's separated key/value and coma list - foreach ($parameters_array as $param_ligne) - { - list($key, $value) = explode(',', $param_ligne); - $params['options'][$key] = $value; - } - } + if (!$error) + { + // attrname must be alphabetical and lower case only + if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) + { + // Construct array for parameter (value of select list) + $default_value = GETPOST('default_value', 'alpha'); + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + //In sellist we have only one line and it can have come to do SQL expression + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) + { + $params['options'] = array($parameters=>null); + } + } else { + //Esle it's separated key/value and coma list + foreach ($parameters_array as $param_ligne) + { + list($key, $value) = explode(',', $param_ligne); + $params['options'][$key] = $value; + } + } - // Visibility: -1=not visible by default in list, 1=visible, 0=hidden - $visibility = GETPOST('list', 'alpha'); + // Visibility: -1=not visible by default in list, 1=visible, 0=hidden + $visibility = GETPOST('list', 'alpha'); if ($type == 'separate') $visibility = 3; - $result = $extrafields->addExtraField( - GETPOST('attrname', 'alpha'), - GETPOST('label', 'alpha'), - $type, - GETPOST('pos', 'int'), - $extrasize, - $elementtype, - (GETPOST('unique', 'alpha') ? 1 : 0), - (GETPOST('required', 'alpha') ? 1 : 0), - $default_value, - $params, - (GETPOST('alwayseditable', 'alpha') ? 1 : 0), - (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), - $visibility, + $result = $extrafields->addExtraField( + GETPOST('attrname', 'alpha'), + GETPOST('label', 'alpha'), + $type, + GETPOST('pos', 'int'), + $extrasize, + $elementtype, + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), + $default_value, + $params, + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), + $visibility, GETPOST('help', 'alpha'), - GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), - GETPOST('langfile', 'alpha'), - 1, - (GETPOST('totalizable', 'alpha') ? 1 : 0), - GETPOST('printable', 'alpha') - ); - if ($result > 0) - { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - $error++; - $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); - } - } else { - $error++; - $langs->load("errors"); - $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); - setEventMessages($mesg, null, 'errors'); - $action = 'create'; - } - } else { - setEventMessages($mesg, null, 'errors'); - } + GETPOST('computed_value', 'alpha'), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), + GETPOST('langfile', 'alpha'), + 1, + (GETPOST('totalizable', 'alpha') ? 1 : 0), + GETPOST('printable', 'alpha') + ); + if ($result > 0) + { + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + $error++; + $mesg = $extrafields->error; + setEventMessages($mesg, null, 'errors'); + } + } else { + $error++; + $langs->load("errors"); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); + setEventMessages($mesg, null, 'errors'); + $action = 'create'; + } + } else { + setEventMessages($mesg, null, 'errors'); + } } } @@ -210,7 +210,7 @@ if ($action == 'update') { if ($_POST["button"] != $langs->trans("Cancel")) { - // Check values + // Check values if (!$type) { $error++; @@ -220,147 +220,147 @@ if ($action == 'update') } if ($type == 'varchar' && $extrasize <= 0) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); - $action = 'edit'; + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $action = 'edit'; } if ($type == 'varchar' && $extrasize > $maxsizestring) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); - $action = 'edit'; - } - if ($type == 'int' && $extrasize > $maxsizeint) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); - $action = 'edit'; - } - if ($type == 'select' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); - $action = 'edit'; - } - if ($type == 'sellist' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); - $action = 'edit'; - } - if ($type == 'checkbox' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); - $action = 'edit'; - } - if ($type == 'radio' && !$param) - { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); - $action = 'edit'; - } - if ((($type == 'radio') || ($type == 'checkbox')) && $param) - { - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - foreach ($parameters_array as $param_ligne) - { - if (!empty($param_ligne)) { - if (preg_match_all('/,/', $param_ligne, $matches)) - { - if (count($matches[0]) > 1) { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'edit'; - } - } else { - $error++; - $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); - $action = 'edit'; - } - } - } - } + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $action = 'edit'; + } + if ($type == 'int' && $extrasize > $maxsizeint) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $action = 'edit'; + } + if ($type == 'select' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $action = 'edit'; + } + if ($type == 'sellist' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $action = 'edit'; + } + if ($type == 'checkbox' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $action = 'edit'; + } + if ($type == 'radio' && !$param) + { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $action = 'edit'; + } + if ((($type == 'radio') || ($type == 'checkbox')) && $param) + { + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + foreach ($parameters_array as $param_ligne) + { + if (!empty($param_ligne)) { + if (preg_match_all('/,/', $param_ligne, $matches)) + { + if (count($matches[0]) > 1) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'edit'; + } + } else { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $action = 'edit'; + } + } + } + } - if (!$error) - { - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) - { - $pos = GETPOST('pos', 'int'); - // Construct array for parameter (value of select list) - $parameters = $param; - $parameters_array = explode("\r\n", $parameters); - //In sellist we have only one line and it can have come to do SQL expression - if ($type == 'sellist') { - foreach ($parameters_array as $param_ligne) - { - $params['options'] = array($parameters=>null); - } - } else { - //Esle it's separated key/value and coma list - foreach ($parameters_array as $param_ligne) - { - list($key, $value) = explode(',', $param_ligne); - $params['options'][$key] = $value; - } - } + if (!$error) + { + if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) + { + $pos = GETPOST('pos', 'int'); + // Construct array for parameter (value of select list) + $parameters = $param; + $parameters_array = explode("\r\n", $parameters); + //In sellist we have only one line and it can have come to do SQL expression + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) + { + $params['options'] = array($parameters=>null); + } + } else { + //Esle it's separated key/value and coma list + foreach ($parameters_array as $param_ligne) + { + list($key, $value) = explode(',', $param_ligne); + $params['options'][$key] = $value; + } + } - // Visibility: -1=not visible by default in list, 1=visible, 0=hidden - $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility = 3; + // Visibility: -1=not visible by default in list, 1=visible, 0=hidden + $visibility = GETPOST('list', 'alpha'); + if ($type == 'separate') $visibility = 3; - $result = $extrafields->update( - GETPOST('attrname', 'alpha'), - GETPOST('label', 'alpha'), - $type, - $extrasize, - $elementtype, - (GETPOST('unique', 'alpha') ? 1 : 0), - (GETPOST('required', 'alpha') ? 1 : 0), - $pos, - $params, - (GETPOST('alwayseditable', 'alpha') ? 1 : 0), - (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), - $visibility, + $result = $extrafields->update( + GETPOST('attrname', 'alpha'), + GETPOST('label', 'alpha'), + $type, + $extrasize, + $elementtype, + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), + $pos, + $params, + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), + $visibility, GETPOST('help', 'alpha'), - GETPOST('default_value', 'alpha'), - GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), - GETPOST('langfile'), - 1, - (GETPOST('totalizable', 'alpha') ? 1 : 0), - GETPOST('printable', 'alpha') - ); - if ($result > 0) - { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - $error++; - $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); - } - } else { - $error++; - $langs->load("errors"); - $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); - setEventMessages($mesg, null, 'errors'); - } - } else { - setEventMessages($mesg, null, 'errors'); - } + GETPOST('default_value', 'alpha'), + GETPOST('computed_value', 'alpha'), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), + GETPOST('langfile'), + 1, + (GETPOST('totalizable', 'alpha') ? 1 : 0), + GETPOST('printable', 'alpha') + ); + if ($result > 0) + { + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else { + $error++; + $mesg = $extrafields->error; + setEventMessages($mesg, null, 'errors'); + } + } else { + $error++; + $langs->load("errors"); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + setEventMessages($mesg, null, 'errors'); + } + } else { + setEventMessages($mesg, null, 'errors'); + } } } @@ -369,14 +369,14 @@ if ($action == 'delete') { if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) { - $result = $extrafields->delete($_GET["attrname"], $elementtype); - if ($result >= 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else $mesg = $extrafields->error; + $result = $extrafields->delete($_GET["attrname"], $elementtype); + if ($result >= 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } else $mesg = $extrafields->error; } else { - $error++; + $error++; $langs->load("errors"); $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); } diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php index d4cdbb66a21..c881b335f18 100644 --- a/htdocs/core/actions_fetchobject.inc.php +++ b/htdocs/core/actions_fetchobject.inc.php @@ -34,20 +34,20 @@ if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask' { $ret = $object->fetch($id, $ref); if ($ret > 0) - { - $object->fetch_thirdparty(); - $id = $object->id; - } else { - if (empty($object->error) && !count($object->errors)) - { - if ($ret < 0) // if $ret == 0, it means not found. - { - setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); - } - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - $action = ''; - } + { + $object->fetch_thirdparty(); + $id = $object->id; + } else { + if (empty($object->error) && !count($object->errors)) + { + if ($ret < 0) // if $ret == 0, it means not found. + { + setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + $action = ''; + } } } diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 3a8e37a6c2b..2912d772a62 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -29,7 +29,7 @@ // Submit file/link if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) { - if (!empty($_FILES)) + if (!empty($_FILES)) { if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; else $userfiles = array($_FILES['userfile']['tmp_name']); @@ -192,7 +192,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { // $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too. $publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity]; - if (! preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash.='/'; + if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/'; if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory $filenameto .= '.noexe'; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c2f0a314445..356eb36a04b 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -114,11 +114,11 @@ if (!$error && $massaction == 'confirm_presend') } } - $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; - $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; - } - } - } + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; + $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; + } + } + } // Check mandatory parameters if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) @@ -261,9 +261,9 @@ if (!$error && $massaction == 'confirm_presend') $sendto = $fuser->email; } elseif ($objectobj->element == 'holiday') { - $fuser = new User($db); - $fuser->fetch($objectobj->fk_user); - $sendto = $fuser->email; + $fuser = new User($db); + $fuser->fetch($objectobj->fk_user); + $sendto = $fuser->email; } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) { $emails_to_sends = array(); @@ -396,7 +396,7 @@ if (!$error && $massaction == 'confirm_presend') $looparray = $listofqualifiedobj; foreach ($looparray as $key => $objecttmp) { - $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object + $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object } } else { $objectforloop = new $objectclass($db); @@ -404,9 +404,9 @@ if (!$error && $massaction == 'confirm_presend') $looparray[0] = $objectforloop; } //var_dump($looparray);exit; - dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); - //var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref); - foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object + dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); + //var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref); + foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object { // Make substitution in email content if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) @@ -430,10 +430,10 @@ if (!$error && $massaction == 'confirm_presend') complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); - $subjectreplaced = make_substitutions($subject, $substitutionarray); - $messagereplaced = make_substitutions($message, $substitutionarray); + $subjectreplaced = make_substitutions($subject, $substitutionarray); + $messagereplaced = make_substitutions($message, $substitutionarray); - $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); + $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); if ($oneemailperrecipient) { // if "one email per recipient" is check we must collate $attachedfiles by thirdparty @@ -461,20 +461,20 @@ if (!$error && $massaction == 'confirm_presend') // Define the trackid when emails sent from the mass action if ($oneemailperrecipient) { - $trackid = 'thi'.$thirdparty->id; - if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; - if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; + $trackid = 'thi'.$thirdparty->id; + if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; + if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; } else { - $trackid = strtolower(get_class($objecttmp)); - if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; - if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; - if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; - if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; - if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; - if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; - if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; + $trackid = strtolower(get_class($objecttmp)); + if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; + if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; + if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; + if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; + if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; + if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; + if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; - $trackid .= $objecttmp->id; + $trackid .= $objecttmp->id; } //var_dump($filepath); //var_dump($trackid);exit; @@ -483,8 +483,8 @@ if (!$error && $massaction == 'confirm_presend') if (empty($sendcontext)) $sendcontext = 'standard'; // Send mail (substitutionarray must be done just before this) - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); if ($mailfile->error) { $resaction .= '
'.$mailfile->error.'
'; @@ -497,11 +497,11 @@ if (!$error && $massaction == 'confirm_presend') $error = 0; // Insert logs into agenda - foreach ($listofqualifiedobj as $objid2 => $objectobj2) + foreach ($listofqualifiedobj as $objid2 => $objectobj2) { - if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level - dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); + dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; if ($objectclass == 'Commande') $actiontypecode='AC_COM'; @@ -514,18 +514,18 @@ if (!$error && $massaction == 'confirm_presend') if ($message) { if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); + $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); } $actionmsg2 = ''; - // Initialisation donnees - $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend); - $objectobj2->actionmsg = $actionmsg; // Long text - $objectobj2->actionmsg2 = $actionmsg2; // Short text - $objectobj2->fk_element = $objid2; - $objectobj2->elementtype = $objectobj2->element; + // Initialisation donnees + $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend); + $objectobj2->actionmsg = $actionmsg; // Long text + $objectobj2->actionmsg2 = $actionmsg2; // Short text + $objectobj2->fk_element = $objid2; + $objectobj2->elementtype = $objectobj2->element; $triggername = strtoupper(get_class($objectobj2)).'_SENTBYMAIL'; if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL'; @@ -619,13 +619,13 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; - $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; + if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; - $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) + $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + if (empty($datefacture)) { - $datefacture = dol_now(); + $datefacture = dol_now(); } $objecttmp->date = $datefacture; @@ -676,7 +676,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders // If we build one invoice for several order, we must put the invoice of order on the line if (!empty($createbills_onebythird)) { - $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); + $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } if ($lines[$i]->subprice < 0) @@ -807,7 +807,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders // Call action to build doc $savobject = $object; - $object = $objecttmp; + $object = $objecttmp; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; $object = $savobject; } @@ -818,7 +818,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders if (!$error) { $db->commit(); - setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); + setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; @@ -1063,7 +1063,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); } else { - setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); + setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } } } @@ -1143,34 +1143,34 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) // Closed records if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissiontoclose) { - $db->begin(); + $db->begin(); - $objecttmp = new $objectclass($db); - $nbok = 0; - foreach ($toselect as $toselectid) { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) { - $result = $objecttmp->cloture($user, 3); - if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - } + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + $result = $objecttmp->cloture($user, 3); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } - if (!$error) { - if ($nbok > 1) - setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + if (!$error) { + if ($nbok > 1) + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } } //var_dump($_POST);var_dump($massaction);exit; @@ -1213,9 +1213,9 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; } else $nbok++; } else { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); @@ -1239,56 +1239,56 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' // @todo : propose model selection if (!$error && $massaction == 'generate_doc' && $permissiontoread) { - $db->begin(); + $db->begin(); - $objecttmp = new $objectclass($db); - $nbok = 0; - foreach ($toselect as $toselectid) - { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) - { - $outputlangs = $langs; - $newlang = ''; + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) + { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) + { + $outputlangs = $langs; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty - if (!empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty + if (!empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + // To be sure vars is defined + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) - { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - } + if ($result <= 0) + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } - if (!$error) - { - if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); - $db->commit(); - } else { - $db->rollback(); - } + if (!$error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } } $parameters['toselect'] = $toselect; diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index 3137c93a9c5..3838e6963ab 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -33,7 +33,7 @@ if ($action == 'print_file' && $user->rights->printing->read) { require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; $objectprint = new PrintingDriver($db); $list = $objectprint->listDrivers($db, 10); - $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); + $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); if (!empty($list)) { $errorprint = 0; $printerfound = 0; diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 05be4a31d18..1cc9a55deb2 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -38,11 +38,11 @@ if ($action == 'update' && is_array($arrayofparameters)) if (GETPOSTISSET($key)) { $result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result < 0) - { - $ok = false; - break; - } + if ($result < 0) + { + $ok = false; + break; + } } } @@ -59,58 +59,58 @@ if ($action == 'update' && is_array($arrayofparameters)) // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) if ($action == 'setModuleOptions') { - $db->begin(); + $db->begin(); - // Process common param fields - if (is_array($_POST)) - { - foreach ($_POST as $key => $val) - { - $reg = array(); - if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... - { - $param = GETPOST("param".$reg[1], 'alpha'); - $value = GETPOST("value".$reg[1], 'alpha'); - if ($param) - { - $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); - if (!$res > 0) $error++; - } - } - } - } + // Process common param fields + if (is_array($_POST)) + { + foreach ($_POST as $key => $val) + { + $reg = array(); + if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... + { + $param = GETPOST("param".$reg[1], 'alpha'); + $value = GETPOST("value".$reg[1], 'alpha'); + if ($param) + { + $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); + if (!$res > 0) $error++; + } + } + } + } - // Process upload fields - if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); - $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); - foreach ($listofdir as $key=>$tmpdir) - { - $tmpdir = trim($tmpdir); - $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (!$tmpdir) { - unset($listofdir[$key]); continue; - } - if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); - else { - $upload_dir = $tmpdir; - } - } - if ($upload_dir) - { - $result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', ''); - if ($result <= 0) $error++; - } - } + // Process upload fields + if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); + foreach ($listofdir as $key=>$tmpdir) + { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { + unset($listofdir[$key]); continue; + } + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else { + $upload_dir = $tmpdir; + } + } + if ($upload_dir) + { + $result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', ''); + if ($result <= 0) $error++; + } + } - if (!$error) - { - $db->commit(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - $db->rollback(); - if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); - } + if (!$error) + { + $db->commit(); + if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + $db->rollback(); + if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); + } } diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index f8d54f2b40b..b9dd4194268 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -33,7 +33,7 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES|ENT_HTML5, 'UTF-8', 1), '_public'); + $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES | ENT_HTML5, 'UTF-8', 1), '_public'); if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) @@ -63,6 +63,6 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', // Set public note if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done - $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES|ENT_HTML5), '_private'); + $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5), '_private'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 620643da8f2..e6fd1e000cb 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -83,10 +83,10 @@ if ($modulepart == 'ecm') // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir)) { - dol_syslog("Refused to deliver file ".$original_file); - // Do no show plain path in shown error message - dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file"))); - exit; + dol_syslog("Refused to deliver file ".$original_file); + // Do no show plain path in shown error message + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file"))); + exit; } // Check permissions @@ -120,11 +120,11 @@ if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); $current_ecmdir_id = -1; foreach ($sqltree as $keycursor => $val) { - //print $val['fullrelativename']." == ".$selecteddir; - if ($val['fullrelativename'] == $selecteddir) - { - $current_ecmdir_id = $keycursor; - } + //print $val['fullrelativename']." == ".$selecteddir; + if ($val['fullrelativename'] == $selecteddir) + { + $current_ecmdir_id = $keycursor; + } } if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 2b03eb858e1..cc27ca11844 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -58,7 +58,7 @@ if ($boxid > 0 && $zone != '' && $userid > 0) $nbboxonright = substr_count($tmp[1], ','); print $nbboxonleft.'-'.$nbboxonright; if ($nbboxonleft > $nbboxonright) $boxorder = preg_replace('/B:/', 'B:'.$boxid.',', $boxorder); // Insert id of new box into list - else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list + else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list } // Registering the location of boxes after a move @@ -70,10 +70,10 @@ if ($boxorder && $zone != '' && $userid > 0) $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); if ($result > 0) { - $langs->load("boxes"); - if (!GETPOST('closing')) - { - setEventMessages($langs->trans("BoxAdded"), null); - } + $langs->load("boxes"); + if (!GETPOST('closing')) + { + setEventMessages($langs->trans("BoxAdded"), null); + } } } diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index 60d3b1d29a7..a6134b05bdc 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -18,7 +18,7 @@ */ if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); @@ -47,7 +47,7 @@ if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); require '../../main.inc.php'; //$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late -$time=dol_now(); +$time = dol_now(); $action = GETPOST('action', 'aZ09'); $listofreminderids = GETPOST('listofreminderids', 'aZ09'); @@ -105,7 +105,7 @@ $eventfound = array(); // This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate. if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow', 'int')) { - /*$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined + /*$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined if (!empty($_SESSION['auto_check_events_not_before'])) { // We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer), @@ -124,51 +124,51 @@ if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto $_SESSION['auto_check_events_not_before'] = $time + $time_update; */ - // Force save of the session change we did. - // WARNING: Any change in sessions after that will not be saved ! - session_write_close(); + // Force save of the session change we did. + // WARNING: Any change in sessions after that will not be saved ! + session_write_close(); - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.(empty($_SESSION['auto_check_events_not_before']) ? '' : $_SESSION['auto_check_events_not_before'])); + dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.(empty($_SESSION['auto_check_events_not_before']) ? '' : $_SESSION['auto_check_events_not_before'])); - $sql = 'SELECT a.id as id_agenda, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; - $sql .= ' WHERE a.code <> "AC_OTH_AUTO"'; - $sql .= ' AND ('; - $sql .= " (ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; - $sql .= ' )'; - } else { - $sql .= ' JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; - $sql .= " AND ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; - } - $sql .= $db->order('datep', 'ASC'); - $sql .= ' LIMIT 10'; // Avoid too many notification at once + $sql = 'SELECT a.id as id_agenda, a.code, a.datep, a.label, a.location, ar.rowid as id_reminder, ar.dateremind, ar.fk_user as id_user_reminder'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + if (!empty($user->conf->MAIN_USER_WANT_ALL_EVENTS_NOTIFICATIONS)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; + $sql .= ' WHERE a.code <> "AC_OTH_AUTO"'; + $sql .= ' AND ('; + $sql .= " (ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; + $sql .= ' )'; + } else { + $sql .= ' JOIN '.MAIN_DB_PREFIX.'actioncomm_reminder as ar ON a.id = ar.fk_actioncomm AND ar.fk_user = '.$user->id; + $sql .= " AND ar.typeremind = 'browser' AND ar.dateremind < '".$db->idate(dol_now())."' AND ar.status = 0 AND ar.entity = ".$conf->entity; + } + $sql .= $db->order('datep', 'ASC'); + $sql .= ' LIMIT 10'; // Avoid too many notification at once - $resql = $db->query($sql); - if ($resql) { - while ($obj = $db->fetch_object($resql)) - { - // Message must be formated and translated to be used with javascript directly - $event = array(); - $event['type'] = 'agenda'; - $event['id_reminder'] = $obj->id_reminder; - $event['id_agenda'] = $obj->id_agenda; - $event['id_user'] = $obj->id_user_reminder; - $event['code'] = $obj->code; - $event['label'] = $obj->label; - $event['location'] = $obj->location; - $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard'); - $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard'); + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) + { + // Message must be formated and translated to be used with javascript directly + $event = array(); + $event['type'] = 'agenda'; + $event['id_reminder'] = $obj->id_reminder; + $event['id_agenda'] = $obj->id_agenda; + $event['id_user'] = $obj->id_user_reminder; + $event['code'] = $obj->code; + $event['label'] = $obj->label; + $event['location'] = $obj->location; + $event['reminder_date_formated'] = dol_print_date($db->jdate($obj->dateremind), 'standard'); + $event['event_date_start_formated'] = dol_print_date($db->jdate($obj->datep), 'standard'); - $eventfound[$obj->id_agenda] = $event; - } - } else { - dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR); - } + $eventfound[$obj->id_agenda] = $event; + } + } else { + dol_syslog("Error sql = ".$db->lasterror(), LOG_ERR); + } } print json_encode(array('pastreminders'=>$eventfound, 'nextreminder'=>'')); diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index 710759e10bb..a530bea092f 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -31,7 +31,7 @@ if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // T require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -$action = GETPOST('action', 'aZ09'); // set or del +$action = GETPOST('action', 'aZ09'); // set or del $name = GETPOST('name', 'alpha'); diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php index 6b476a8f59a..e56b8689e0d 100644 --- a/htdocs/core/ajax/contacts.php +++ b/htdocs/core/ajax/contacts.php @@ -27,7 +27,7 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../../main.inc.php'; -$id = GETPOST('id', 'int'); // id of thirdparty +$id = GETPOST('id', 'int'); // id of thirdparty $action = GETPOST('action', 'aZ09'); $htmlname = GETPOST('htmlname', 'alpha'); $showempty = GETPOST('showempty', 'int'); diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 69dd65b868e..877379b54ad 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -26,21 +26,21 @@ if (!isset($usedbyinclude) || empty($usedbyinclude)) { - if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal - if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); - if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); - if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); - if (!defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN', '1'); + if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal + if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); + if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); + if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + if (!defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN', '1'); - $res = @include '../../main.inc.php'; - if ($res == 'ERROR_NOT_LOGGED') - { - $langs->load("other"); - $arrayresult['jumptologin'] = array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>' '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); - print json_encode($arrayresult); - if (is_object($db)) $db->close(); - exit; - } + $res = @include '../../main.inc.php'; + if ($res == 'ERROR_NOT_LOGGED') + { + $langs->load("other"); + $arrayresult['jumptologin'] = array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>' '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php'); + print json_encode($arrayresult); + if (is_object($db)) $db->close(); + exit; + } } include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; @@ -110,11 +110,11 @@ if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARC { $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || ! empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if ((! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || ! empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } @@ -131,7 +131,7 @@ if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUST } // Vendor payments -if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || ! empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $arrayresult['searchintovendorpayments'] = array( 'position'=>175, @@ -189,8 +189,8 @@ if (empty($reshook)) // This pushes a search entry to the top if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { - $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; - if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -1000; + $key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE; + if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -1000; } // Sort on position @@ -199,6 +199,6 @@ $arrayresult = dol_sort_array($arrayresult, 'position'); // Print output if called by ajax or do nothing (var $arrayresult will be used) if called by an include if (!isset($usedbyinclude) || empty($usedbyinclude)) { - print json_encode($arrayresult); - if (is_object($db)) $db->close(); + print json_encode($arrayresult); + if (is_object($db)) $db->close(); } diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index 76c3fa5eb47..0a12324fab6 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -32,77 +32,77 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_accountancy_last_manual_entries extends ModeleBoxes { - public $boxcode = "accountancy_last_manual_entries"; - public $boximg = "object_invoice"; - public $boxlabel = "BoxLastManualEntries"; - public $depends = array("accounting"); + public $boxcode = "accountancy_last_manual_entries"; + public $boximg = "object_invoice"; + public $boxlabel = "BoxLastManualEntries"; + public $depends = array("accounting"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); - } + $this->hidden = !($user->rights->accounting->mouvements->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - $bookkeepingstatic = new BookKeeping($this->db); + $bookkeepingstatic = new BookKeeping($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); - if ($user->rights->accounting->mouvements->lire) - { - $sql = "SELECT DISTINCT b.piece_num"; - $sql .= ", b.doc_date as date_movement"; - $sql .= ", b.label_operation"; - $sql .= ", b.montant as amount"; - $sql .= ", b.code_journal"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " WHERE b.fk_doc = 0"; - $sql .= " AND b.entity = ".$conf->entity; - $sql .= " ORDER BY b.piece_num DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->accounting->mouvements->lire) + { + $sql = "SELECT DISTINCT b.piece_num"; + $sql .= ", b.doc_date as date_movement"; + $sql .= ", b.label_operation"; + $sql .= ", b.montant as amount"; + $sql .= ", b.code_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " WHERE b.fk_doc = 0"; + $sql .= " AND b.entity = ".$conf->entity; + $sql .= " ORDER BY b.piece_num DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_movement); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_movement); $journal = $objp->code_journal; - $label = $objp->label_operation; + $label = $objp->label_operation; $amount = $objp->amount; $bookkeepingstatic->id = $objp->id; @@ -114,11 +114,11 @@ class box_accountancy_last_manual_entries extends ModeleBoxes 'asis' => 1, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + 'asis' => 1, + ); $this->info_box_contents[$line][] = array( 'td' => 'class="center"', @@ -132,34 +132,34 @@ class box_accountancy_last_manual_entries extends ModeleBoxes 'asis' => 1, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedManualEntries") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedManualEntries") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -169,8 +169,8 @@ class box_accountancy_last_manual_entries extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 639ce1ebc23..653f49d2bd9 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -32,57 +32,57 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_accountancy_suspense_account extends ModeleBoxes { - public $boxcode = "accountancy_suspense_account"; - public $boximg = "object_invoice"; - public $boxlabel = "BoxSuspenseAccount"; - public $depends = array("accounting"); + public $boxcode = "accountancy_suspense_account"; + public $boximg = "object_invoice"; + public $boxlabel = "BoxSuspenseAccount"; + public $depends = array("accounting"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); - } + $this->hidden = !($user->rights->accounting->mouvements->lire); + } - /** - * Load data for box to show them later - * - * @return void - */ - public function loadBox() - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @return void + */ + public function loadBox() + { + global $user, $langs, $conf; - include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - //$bookkeepingstatic = new BookKeeping($this->db); + //$bookkeepingstatic = new BookKeeping($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); - if ($user->rights->accounting->mouvements->lire) - { + if ($user->rights->accounting->mouvements->lire) + { $suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; - if (!empty($suspenseAccount) && $suspenseAccount > 0) - { + if (!empty($suspenseAccount) && $suspenseAccount > 0) + { $sql = "SELECT COUNT(*) as nb_suspense_account"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql .= " WHERE b.numero_compte = ".$suspenseAccount; @@ -112,13 +112,13 @@ class box_accountancy_suspense_account extends ModeleBoxes 'text' => ''.$langs->trans("SuspenseAccountNotDefined").'' ); } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover"', - 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' - ); - } - } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' + ); + } + } /** * Method to show box @@ -128,8 +128,8 @@ class box_accountancy_suspense_account extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index eeebb520ab1..f010dc2dede 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -77,20 +77,20 @@ class box_actions extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $societestatic = new Societe($this->db); - $actionstatic = new ActionComm($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + $societestatic = new Societe($this->db); + $actionstatic = new ActionComm($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastActionsToDo", $max)); - if ($user->rights->agenda->myactions->read) { + if ($user->rights->agenda->myactions->read) { $sql = "SELECT a.id, a.label, a.datep as dp, a.percent as percentage"; - $sql .= ", ta.code"; - $sql .= ", ta.libelle as type_label"; - $sql .= ", s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; + $sql .= ", ta.code"; + $sql .= ", ta.libelle as type_label"; + $sql .= ", s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; @@ -261,5 +261,5 @@ class box_actions extends ModeleBoxes else print $out; return ''; - } + } } diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index e6d032d41f8..f0a5c8d61bb 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays extends ModeleBoxes { - public $boxcode = "birthdays"; - public $boximg = "object_user"; - public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; - public $depends = array("user"); + public $boxcode = "birthdays"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleUserBirthdaysOfMonth"; + public $depends = array("user"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -64,10 +64,10 @@ class box_birthdays extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 20) { @@ -78,9 +78,9 @@ class box_birthdays extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $userstatic = new User($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth")); if ($user->rights->user->user->lire) { @@ -103,25 +103,25 @@ class box_birthdays extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $userstatic->id = $objp->rowid; - $userstatic->firstname = $objp->firstname; - $userstatic->lastname = $objp->lastname; - $userstatic->email = $objp->email; - $dateb = $this->db->jdate($objp->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $userstatic->id = $objp->rowid; + $userstatic->firstname = $objp->firstname; + $userstatic->lastname = $objp->lastname; + $userstatic->email = $objp->email; + $dateb = $this->db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $userstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $userstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + ); - /*$this->info_box_contents[$line][] = array( + /*$this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $userstatic->LibStatut($objp->status, 3) );*/ @@ -134,15 +134,15 @@ class box_birthdays extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -155,8 +155,8 @@ class box_birthdays extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index e49d21ba387..02a315ea836 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_birthdays_members extends ModeleBoxes { - public $boxcode = "birthdays_members"; - public $boximg = "object_user"; - public $boxlabel = "BoxTitleMemberNextBirthdays"; - public $depends = array("adherent"); + public $boxcode = "birthdays_members"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleMemberNextBirthdays"; + public $depends = array("adherent"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -64,10 +64,10 @@ class box_birthdays_members extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 20) { @@ -78,9 +78,9 @@ class box_birthdays_members extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); + $memberstatic = new Adherent($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); + $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); if ($user->rights->adherent->lire) { @@ -89,8 +89,8 @@ class box_birthdays_members extends ModeleBoxes $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as u"; $sql .= " WHERE u.entity IN (".getEntity('adherent').")"; - $sql .= " AND u.statut = 1"; - $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); + $sql .= " AND u.statut = 1"; + $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); @@ -104,25 +104,25 @@ class box_birthdays_members extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $memberstatic->id = $objp->rowid; - $memberstatic->firstname = $objp->firstname; - $memberstatic->lastname = $objp->lastname; - $memberstatic->email = $objp->email; - $dateb = $this->db->jdate($objp->birth); - $age = date('Y', dol_now()) - date('Y', $dateb); + $memberstatic->id = $objp->rowid; + $memberstatic->firstname = $objp->firstname; + $memberstatic->lastname = $objp->lastname; + $memberstatic->email = $objp->email; + $dateb = $this->db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $memberstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $memberstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day").' - '.$age.' '.$langs->trans('DurationYears') + ); - /*$this->info_box_contents[$line][] = array( + /*$this->info_box_contents[$line][] = array( 'td' => 'class="right" width="18"', 'text' => $memberstatic->LibStatut($objp->status, 3) );*/ @@ -135,15 +135,15 @@ class box_birthdays_members extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -156,8 +156,8 @@ class box_birthdays_members extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index c75c4c24e8f..6a2554bcde0 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -32,147 +32,147 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_boms extends ModeleBoxes { - public $boxcode = "lastboms"; - public $boximg = "object_bom"; - public $boxlabel = "BoxTitleLatestModifiedBoms"; - public $depends = array("bom"); + public $boxcode = "lastboms"; + public $boximg = "object_bom"; + public $boxlabel = "BoxTitleLatestModifiedBoms"; + public $depends = array("bom"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bom->read); - } + $this->hidden = !($user->rights->bom->read); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $bomstatic = new Bom($this->db); - $productstatic = new Product($this->db); - $userstatic = new User($this->db); + $bomstatic = new Bom($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); - if ($user->rights->bom->read) - { - $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; - $sql .= ", c.rowid"; - $sql .= ", c.date_creation"; - $sql .= ", c.tms"; - $sql .= ", c.ref"; - $sql .= ", c.status"; - $sql .= ", c.fk_user_valid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; - $sql .= " WHERE c.fk_product = p.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " ORDER BY c.tms DESC, c.ref DESC"; - $sql .= " ".$this->db->plimit($max, 0); + if ($user->rights->bom->read) + { + $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + $sql .= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datem = $this->db->jdate($objp->tms); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem = $this->db->jdate($objp->tms); - $bomstatic->id = $objp->rowid; - $bomstatic->ref = $objp->ref; - $bomstatic->id = $objp->socid; - $bomstatic->status = $objp->status; + $bomstatic->id = $objp->rowid; + $bomstatic->ref = $objp->ref; + $bomstatic->id = $objp->socid; + $bomstatic->status = $objp->status; - $productstatic->ref = $objp->product_ref; - $productstatic->status = $objp->tobuy; - $productstatic->status_buy = $objp->tosell; + $productstatic->ref = $objp->product_ref; + $productstatic->status = $objp->tobuy; + $productstatic->status_buy = $objp->tosell; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $bomstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $bomstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $bomstatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $bomstatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -182,8 +182,8 @@ class box_boms extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index c81e226decb..795eaeccf36 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -28,20 +28,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_bookmarks extends ModeleBoxes { - public $boxcode = "bookmarks"; - public $boximg = "bookmark"; - public $boxlabel = "BoxMyLastBookmarks"; - public $depends = array("bookmark"); + public $boxcode = "bookmarks"; + public $boximg = "bookmark"; + public $boxlabel = "BoxMyLastBookmarks"; + public $depends = array("bookmark"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,18 +52,18 @@ class box_bookmarks extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bookmark->lire); + $this->hidden = !($user->rights->bookmark->lire); } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -73,10 +73,10 @@ class box_bookmarks extends ModeleBoxes $this->max = $max; $this->info_box_head = array( - 'text' => $langs->trans("BoxMyLastBookmarks", $max), - 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', - ); - if ($user->rights->bookmark->creer) { + 'text' => $langs->trans("BoxMyLastBookmarks", $max), + 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', + ); + if ($user->rights->bookmark->creer) { $this->info_box_head['subpicto'] = 'bookmark'; $this->info_box_head['subtext'] = $langs->trans("BookmarksManagement"); } else { @@ -89,7 +89,7 @@ class box_bookmarks extends ModeleBoxes $sql = "SELECT b.title, b.url, b.target, b.favicon"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; $sql .= " WHERE fk_user = ".$user->id; - $sql .= " AND b.entity = ".$conf->entity; + $sql .= " AND b.entity = ".$conf->entity; $sql .= $this->db->order("position", "ASC"); $sql .= $this->db->plimit($max, 0); @@ -100,63 +100,63 @@ class box_bookmarks extends ModeleBoxes $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'logo' => $this->boximg, - 'url' => $objp->url, - 'tooltip' => $objp->title, - 'target' => $objp->target ? 'newtab' : '', - ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $objp->title, - 'url' => $objp->url, - 'tooltip' => $objp->title, - 'target' => $objp->target ? 'newtab' : '', - ); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'logo' => $this->boximg, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target ? 'newtab' : '', + ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $objp->title, + 'url' => $objp->url, + 'tooltip' => $objp->title, + 'target' => $objp->target ? 'newtab' : '', + ); - $line++; - } + $line++; + } - if ($num == 0) { - $mytxt = $langs->trans("NoRecordedBookmarks"); - if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd"); - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center" colspan="2"', - 'tooltip' => $mytxt, - 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, - ); - } + if ($num == 0) { + $mytxt = $langs->trans("NoRecordedBookmarks"); + if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd"); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center" colspan="2"', + 'tooltip' => $mytxt, + 'url'=> DOL_URL_ROOT.'/bookmarks/list.php', 'text'=>$mytxt, + ); + } - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 00cad787e0b..816facc3ee4 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -32,27 +32,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_clients extends ModeleBoxes { - public $boxcode = "lastcustomers"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastCustomers"; - public $depends = array("societe"); + public $boxcode = "lastcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastCustomers"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -67,10 +67,10 @@ class box_clients extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -79,23 +79,23 @@ class box_clients extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.nom as name, s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.client"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.fournisseur"; - $sql .= ", s.code_compta"; - $sql .= ", s.code_compta_fournisseur"; - $sql .= ", s.logo"; - $sql .= ", s.email"; - $sql .= ", s.datec, s.tms, s.status, s.entity"; + $sql .= ", s.code_client"; + $sql .= ", s.client"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.code_compta"; + $sql .= ", s.code_compta_fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.email"; + $sql .= ", s.datec, s.tms, s.status, s.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.client IN (1, 3)"; @@ -117,33 +117,33 @@ class box_clients extends ModeleBoxes $objp = $this->db->fetch_object($result); $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); - $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->code_compta = $objp->code_compta; - $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; - $thirdpartystatic->email = $objp->email; + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta = $objp->code_compta; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->email = $objp->email; $thirdpartystatic->entity = $objp->entity; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day") - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day") + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3) - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + ); $line++; } @@ -156,15 +156,15 @@ class box_clients extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql) - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -177,8 +177,8 @@ class box_clients extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 90729b96017..c94353f1d5c 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -32,168 +32,168 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_commandes extends ModeleBoxes { - public $boxcode = "lastcustomerorders"; - public $boximg = "object_order"; - public $boxlabel = "BoxLastCustomerOrders"; - public $depends = array("commande"); + public $boxcode = "lastcustomerorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLastCustomerOrders"; + public $depends = array("commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->commande->lire); - } + $this->hidden = !($user->rights->commande->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->load('orders'); + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load('orders'); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $commandestatic = new Commande($this->db); - $societestatic = new Societe($this->db); - $userstatic = new User($this->db); + $commandestatic = new Commande($this->db); + $societestatic = new Societe($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerOrders", $max)); - if ($user->rights->commande->lire) - { - $sql = "SELECT s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.logo, s.email"; - $sql .= ", c.ref, c.tms"; - $sql .= ", c.rowid"; - $sql .= ", c.date_commande"; - $sql .= ", c.ref_client"; - $sql .= ", c.fk_statut"; - $sql .= ", c.fk_user_valid"; - $sql .= ", c.facture"; - $sql .= ", c.total_ht"; - $sql .= ", c.tva as total_tva"; - $sql .= ", c.total_ttc"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('commande').")"; - if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->commande->lire) + { + $sql = "SELECT s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", c.ref, c.tms"; + $sql .= ", c.rowid"; + $sql .= ", c.date_commande"; + $sql .= ", c.ref_client"; + $sql .= ", c.fk_statut"; + $sql .= ", c.fk_user_valid"; + $sql .= ", c.facture"; + $sql .= ", c.total_ht"; + $sql .= ", c.tva as total_tva"; + $sql .= ", c.total_ttc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); - $datem = $this->db->jdate($objp->tms); - $commandestatic->id = $objp->rowid; - $commandestatic->ref = $objp->ref; - $commandestatic->ref_client = $objp->ref_client; - $commandestatic->total_ht = $objp->total_ht; - $commandestatic->total_tva = $objp->total_tva; - $commandestatic->total_ttc = $objp->total_ttc; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); + $datem = $this->db->jdate($objp->tms); + $commandestatic->id = $objp->rowid; + $commandestatic->ref = $objp->ref; + $commandestatic->ref_client = $objp->ref_client; + $commandestatic->total_ht = $objp->total_ht; + $commandestatic->total_tva = $objp->total_tva; + $commandestatic->total_ttc = $objp->total_ttc; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $commandestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $commandestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -203,8 +203,8 @@ class box_commandes extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index b3f23817712..53be2725680 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -33,28 +33,28 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class box_comptes extends ModeleBoxes { - public $boxcode = "currentaccounts"; - public $boximg = "object_bill"; - public $boxlabel = "BoxCurrentAccounts"; - public $depends = array("banque"); // Box active if module banque active + public $boxcode = "currentaccounts"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCurrentAccounts"; + public $depends = array("banque"); // Box active if module banque active - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -73,7 +73,7 @@ class box_comptes extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -83,109 +83,109 @@ class box_comptes extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); - if ($user->rights->banque->lire) { + if ($user->rights->banque->lire) { $sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url"; $sql .= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; $sql .= ", b.domiciliation, b.proprio, b.owner_address"; $sql .= ", b.account_number, b.currency_code"; $sql .= ", b.min_allowed, b.min_desired, comment"; - $sql .= ', b.fk_accountancy_journal'; - $sql .= ', aj.code as accountancy_journal'; - $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; - $sql .= " WHERE b.entity = ".$conf->entity; + $sql .= ', b.fk_accountancy_journal'; + $sql .= ', aj.code as accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; + $sql .= " WHERE b.entity = ".$conf->entity; $sql .= " AND clos = 0"; //$sql.= " AND courant = 1"; $sql .= " ORDER BY label"; $sql .= $this->db->plimit($max, 0); - dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; - $solde_total = array(); + $line = 0; + $solde_total = array(); - $account_static = new Account($this->db); - while ($line < $num) { - $objp = $this->db->fetch_object($result); + $account_static = new Account($this->db); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $account_static->id = $objp->rowid; + $account_static->id = $objp->rowid; $account_static->ref = $objp->ref; - $account_static->label = $objp->label; - $account_static->number = $objp->number; - $account_static->account_number = $objp->account_number; - $account_static->currency_code = $objp->currency_code; - $account_static->accountancy_journal = $objp->accountancy_journal; - $solde = $account_static->solde(0); + $account_static->label = $objp->label; + $account_static->number = $objp->number; + $account_static->account_number = $objp->account_number; + $account_static->currency_code = $objp->currency_code; + $account_static->accountancy_journal = $objp->accountancy_journal; + $solde = $account_static->solde(0); - $solde_total[$objp->currency_code] += $solde; + $solde_total[$objp->currency_code] += $solde; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $account_static->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $account_static->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $objp->number, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $objp->number, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($solde, 0, $langs, 0, -1, -1, $objp->currency_code) + ); - $line++; - } + $line++; + } - // Total - foreach ($solde_total as $key=>$solde) { - $this->info_box_contents[$line][] = array( - 'tr' => 'class="liste_total"', - 'td' => 'class="liste_total left"', - 'text' => $langs->trans('Total').' '.$key, - ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="liste_total right"', - 'text' => ' ' - ); + // Total + foreach ($solde_total as $key=>$solde) { + $this->info_box_contents[$line][] = array( + 'tr' => 'class="liste_total"', + 'td' => 'class="liste_total left"', + 'text' => $langs->trans('Total').' '.$key, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => ' ' + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="liste_total right nowraponall"', - 'text' => price($solde, 0, $langs, 0, -1, -1, $key) - ); - $line++; - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right nowraponall"', + 'text' => price($solde, 0, $langs, 0, -1, -1, $key) + ); + $line++; + } - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 7141728c23d..c3756bfd86c 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -35,20 +35,20 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class box_contacts extends ModeleBoxes { - public $boxcode = "lastcontacts"; - public $boximg = "object_contact"; - public $boxlabel = "BoxLastContacts"; - public $depends = array("societe"); + public $boxcode = "lastcontacts"; + public $boximg = "object_contact"; + public $boxlabel = "BoxLastContacts"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -59,18 +59,18 @@ class box_contacts extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); + $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -121,7 +121,7 @@ class box_contacts extends ModeleBoxes $contactstatic->phone_pro = $objp->phone; $contactstatic->phone_perso = $objp->phone_perso; $contactstatic->phone_mobile = $objp->phone_mobile; - $contactstatic->email = $objp->spemail; + $contactstatic->email = $objp->spemail; $contactstatic->address = $objp->address; $contactstatic->zip = $objp->zip; $contactstatic->town = $objp->town; @@ -130,7 +130,7 @@ class box_contacts extends ModeleBoxes $societestatic->id = $objp->fk_soc; $societestatic->name = $objp->socname; - $societestatic->email = $objp->semail; + $societestatic->email = $objp->semail; $societestatic->name_alias = $objp->name_alias; $societestatic->code_client = $objp->code_client; $societestatic->code_fournisseur = $objp->code_fournisseur; diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index 75fbc207134..9350bae2da9 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -31,158 +31,158 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_contracts extends ModeleBoxes { - public $boxcode = "lastcontracts"; - public $boximg = "object_contract"; - public $boxlabel = "BoxLastContracts"; - public $depends = array("contrat"); // conf->contrat->enabled + public $boxcode = "lastcontracts"; + public $boximg = "object_contract"; + public $boxlabel = "BoxLastContracts"; + public $depends = array("contrat"); // conf->contrat->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); - } + $this->hidden = !($user->rights->contrat->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); - if ($user->rights->contrat->lire) - { - $contractstatic = new Contrat($this->db); - $thirdpartytmp = new Societe($this->db); + if ($user->rights->contrat->lire) + { + $contractstatic = new Contrat($this->db); + $thirdpartytmp = new Societe($this->db); - $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; - $sql .= ", c.ref_customer, c.ref_supplier"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); + $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; + $sql .= ", c.ref_customer, c.ref_supplier"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $now = dol_now(); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $now = dol_now(); - $line = 0; + $line = 0; - $langs->load("contracts"); + $langs->load("contracts"); - while ($line < $num) - { - $objp = $this->db->fetch_object($resql); + while ($line < $num) + { + $objp = $this->db->fetch_object($resql); - $datec = $this->db->jdate($objp->datec); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - $late = ''; + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $late = ''; - $contractstatic->statut = $objp->fk_statut; - $contractstatic->id = $objp->rowid; - $contractstatic->ref = $objp->ref; - $contractstatic->ref_customer = $objp->ref_customer; - $contractstatic->ref_supplier = $objp->ref_supplier; - $result = $contractstatic->fetch_lines(); + $contractstatic->statut = $objp->fk_statut; + $contractstatic->id = $objp->rowid; + $contractstatic->ref = $objp->ref; + $contractstatic->ref_customer = $objp->ref_customer; + $contractstatic->ref_supplier = $objp->ref_supplier; + $result = $contractstatic->fetch_lines(); - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->client = $objp->client; - $thirdpartytmp->fournisseur = $objp->fournisseur; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->code_compta = $objp->code_compta; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - // fin_validite is no more on contract but on services - // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } + // fin_validite is no more on contract but on services + // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contractstatic->getNomUrl(1), - 'text2'=> $late, - 'asis'=>1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contractstatic->getNomUrl(1), + 'text2'=> $late, + 'asis'=>1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1), - 'asis'=>1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1), + 'asis'=>1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => $contractstatic->getLibStatut(7), - 'asis'=>1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => $contractstatic->getLibStatut(7), + 'asis'=>1, + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedContracts"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedContracts"), + ); - $this->db->free($resql); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($resql); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -192,8 +192,8 @@ class box_contracts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index d5cc859eaa7..949f6ac1382 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -34,45 +34,45 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_external_rss extends ModeleBoxes { - public $boxcode = "lastrssinfos"; - public $boximg = "object_rss"; - public $boxlabel = "BoxLastRssInfos"; - public $depends = array("externalrss"); + public $boxcode = "lastrssinfos"; + public $boximg = "object_rss"; + public $boxlabel = "BoxLastRssInfos"; + public $depends = array("externalrss"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $paramdef; // Params of box definition (not user params) + public $paramdef; // Params of box definition (not user params) - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { $this->db = $db; $this->paramdef = $param; - } + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @param int $cachedelay Delay we accept for cache file - * @return void - */ - public function loadBox($max = 5, $cachedelay = 3600) - { - global $user, $langs, $conf; - $langs->load("boxes"); + * @param int $cachedelay Delay we accept for cache file + * @return void + */ + public function loadBox($max = 5, $cachedelay = 3600) + { + global $user, $langs, $conf; + $langs->load("boxes"); $this->max = $max; @@ -90,42 +90,42 @@ class box_external_rss extends ModeleBoxes // Get RSS feed $url = $conf->global->$keyforparamurl; - $rssparser = new RssParser($this->db); + $rssparser = new RssParser($this->db); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); // INFO on channel $description = $rssparser->getDescription(); $link = $rssparser->getLink(); - $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); - if ($result < 0 || !empty($rssparser->error)) - { - // Show warning - $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); - if ($rssparser->error) $errormessage .= " - ".$rssparser->error; - $title .= " ".img_error($errormessage); - $this->info_box_head = array('text' => $title, 'limit' => 0); - } else { - $this->info_box_head = array( - 'text' => $title, - 'sublink' => $link, - 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), - 'subpicto'=>'globe', - 'target'=>'_blank', - ); + $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); + if ($result < 0 || !empty($rssparser->error)) + { + // Show warning + $errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown"))); + if ($rssparser->error) $errormessage .= " - ".$rssparser->error; + $title .= " ".img_error($errormessage); + $this->info_box_head = array('text' => $title, 'limit' => 0); + } else { + $this->info_box_head = array( + 'text' => $title, + 'sublink' => $link, + 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), + 'subpicto'=>'globe', + 'target'=>'_blank', + ); } // INFO on items $items = $rssparser->getItems(); - //print '
'.print_r($items,true).'
'; + //print '
'.print_r($items,true).'
'; $nbitems = count($items); - for ($line = 0; $line < $max && $line < $nbitems; $line++) - { - $item = $items[$line]; + for ($line = 0; $line < $max && $line < $nbitems; $line++) + { + $item = $items[$line]; // Feed common fields - $href = $item['link']; - $title = urldecode($item['title']); + $href = $item['link']; + $title = urldecode($item['title']); $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed if ($rssparser->getFormat() == 'rss') // If RSS { @@ -145,46 +145,46 @@ class box_external_rss extends ModeleBoxes if (is_numeric($date)) $date = dol_print_date($date, "dayhour"); $isutf8 = utf8_check($title); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); - $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 - $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut - $this->info_box_contents["$href"] = "$title"; + $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 + $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut + $this->info_box_contents["$href"] = "$title"; - $tooltip = $title; - $description = !empty($item['description']) ? $item['description'] : ''; - $isutf8 = utf8_check($description); - if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); - $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); - $description = preg_replace("/^\s+/", "", $description); - $description = str_replace("\r\n", "", $description); - $tooltip .= '
'.$description; + $tooltip = $title; + $description = !empty($item['description']) ? $item['description'] : ''; + $isutf8 = utf8_check($description); + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); + $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); + $description = preg_replace("/^\s+/", "", $description); + $description = str_replace("\r\n", "", $description); + $tooltip .= '
'.$description; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="left" width="16"', - 'logo' => $this->boximg, - 'url' => $href, - 'tooltip' => $tooltip, - 'target' => 'newrss', - ); + $this->info_box_contents[$line][0] = array( + 'td' => 'class="left" width="16"', + 'logo' => $this->boximg, + 'url' => $href, + 'tooltip' => $tooltip, + 'target' => 'newrss', + ); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $title, - 'url' => $href, - 'tooltip' => $tooltip, - 'maxlength' => 64, - 'target' => 'newrss', - ); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $title, + 'url' => $href, + 'tooltip' => $tooltip, + 'maxlength' => 64, + 'target' => 'newrss', + ); - $this->info_box_contents[$line][2] = array( - 'td' => 'class="right nowrap"', - 'text' => $date, - ); - } - } + $this->info_box_contents[$line][2] = array( + 'td' => 'class="right nowrap"', + 'text' => $date, + ); + } + } /** @@ -195,8 +195,8 @@ class box_external_rss extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index ebaff31268d..6a824849212 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures extends ModeleBoxes { - public $boxcode = "lastcustomerbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxLastCustomerBills"; - public $depends = array("facture"); + public $boxcode = "lastcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastCustomerBills"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,18 +54,18 @@ class box_factures extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -73,13 +73,13 @@ class box_factures extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic = new Facture($this->db); - $societestatic = new Societe($this->db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); - $langs->load("bills"); + $langs->load("bills"); $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerBills", $max); $this->info_box_head = array( @@ -87,14 +87,14 @@ class box_factures extends ModeleBoxes 'limit'=> dol_strlen($text) ); - if ($user->rights->facture->lire) { - $sql = "SELECT f.rowid as facid"; - $sql .= ", f.ref, f.type, f.total as total_ht"; - $sql .= ", f.tva as total_tva"; - $sql .= ", f.total_ttc"; - $sql .= ", f.datef as df"; + if ($user->rights->facture->lire) { + $sql = "SELECT f.rowid as facid"; + $sql .= ", f.ref, f.type, f.total as total_ht"; + $sql .= ", f.tva as total_tva"; + $sql .= ", f.total_ttc"; + $sql .= ", f.datef as df"; $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; - $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; + $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; $sql .= ", f.date_lim_reglement as datelimite"; $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -103,8 +103,8 @@ class box_factures extends ModeleBoxes $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -116,90 +116,90 @@ class box_factures extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datelimite = $this->db->jdate($objp->datelimite); - $date = $this->db->jdate($objp->df); - $datem = $this->db->jdate($objp->tms); + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datelimite = $this->db->jdate($objp->datelimite); + $date = $this->db->jdate($objp->df); + $datem = $this->db->jdate($objp->tms); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->type = $objp->type; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->statut = $objp->fk_statut; - $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->statut = $objp->fk_statut; + $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->code_client = $objp->code_client; - $societestatic->tva_intra = $objp->tva_intra; - $societestatic->email = $objp->email; - $societestatic->idprof1 = $objp->idprof1; - $societestatic->idprof2 = $objp->idprof2; - $societestatic->idprof3 = $objp->idprof3; - $societestatic->idprof4 = $objp->idprof4; - $societestatic->idprof5 = $objp->idprof5; - $societestatic->idprof6 = $objp->idprof6; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + $societestatic->tva_intra = $objp->tva_intra; + $societestatic->email = $objp->email; + $societestatic->idprof1 = $objp->idprof1; + $societestatic->idprof2 = $objp->idprof2; + $societestatic->idprof3 = $objp->idprof3; + $societestatic->idprof4 = $objp->idprof4; + $societestatic->idprof5 = $objp->idprof5; + $societestatic->idprof6 = $objp->idprof6; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax200"', - 'text' => $societestatic->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax200"', + 'text' => $societestatic->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedInvoices"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -209,8 +209,8 @@ class box_factures extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 30f3cd503c2..7053acb9e97 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn extends ModeleBoxes { - public $boxcode = "lastsupplierbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxLastSupplierBills"; - public $depends = array("facture", "fournisseur"); + public $boxcode = "lastsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxLastSupplierBills"; + public $depends = array("facture", "fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,18 +55,18 @@ class box_factures_fourn extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -75,10 +75,10 @@ class box_factures_fourn extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $facturestatic = new FactureFournisseur($this->db); - $thirdpartytmp = new Fournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); + $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array( 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierBills", $max) @@ -87,12 +87,12 @@ class box_factures_fourn extends ModeleBoxes if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql .= " s.code_fournisseur, s.email,"; - $sql .= " s.logo,"; + $sql .= " s.code_fournisseur, s.email,"; + $sql .= " s.logo,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; - $sql .= " f.total_ht,"; - $sql .= " f.total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total_ht,"; + $sql .= " f.total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut,"; $sql .= ' f.datef as df,'; $sql .= ' f.datec as datec,'; @@ -104,8 +104,8 @@ class box_factures_fourn extends ModeleBoxes $sql .= " AND f.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; - else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); @@ -116,96 +116,96 @@ class box_factures_fourn extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - while ($line < $num) { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->datelimite); $date = $this->db->jdate($objp->df); $datem = $this->db->jdate($objp->tms); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; - $facturestatic->date_echeance = $datelimite; - $facturestatic->statut = $objp->fk_statut; - $facturestatic->ref_supplier = $objp->ref_supplier; + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->date_echeance = $datelimite; + $facturestatic->statut = $objp->fk_statut; + $facturestatic->ref_supplier = $objp->ref_supplier; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->fournisseur = 1; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150"', - 'text' => $objp->ref_supplier, - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, - 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150"', + 'text' => $objp->ref_supplier, + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, + 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150"', - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $fac = new FactureFournisseur($this->db); - $fac->fetch($objp->facid); - $alreadypaid = $fac->getSommePaiement(); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), - ); + $fac = new FactureFournisseur($this->db); + $fac->fetch($objp->facid); + $alreadypaid = $fac->getSommePaiement(); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoModifiedSupplierBills"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoModifiedSupplierBills"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->transnoentities("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->transnoentities("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -215,8 +215,8 @@ class box_factures_fourn extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index c2b5e7c705e..938505caab4 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn_imp extends ModeleBoxes { - public $boxcode = "oldestunpaidsupplierbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxOldestUnpaidSupplierBills"; - public $depends = array("facture", "fournisseur"); + public $boxcode = "oldestunpaidsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidSupplierBills"; + public $depends = array("facture", "fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,18 +54,18 @@ class box_factures_fourn_imp extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -85,9 +85,9 @@ class box_factures_fourn_imp extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; $sql .= " f.datef as df,"; - $sql .= " f.total_ht as total_ht,"; - $sql .= " f.tva as total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total_ht as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut, f.type"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ",".MAIN_DB_PREFIX."facture_fourn as f"; @@ -109,7 +109,7 @@ class box_factures_fourn_imp extends ModeleBoxes $line = 0; $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; - $facturestatic = new FactureFournisseur($this->db); + $facturestatic = new FactureFournisseur($this->db); while ($line < $num) { @@ -127,71 +127,71 @@ class box_factures_fourn_imp extends ModeleBoxes $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->fournisseur = 1; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); - } + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); + } - $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier; + $tooltip = $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'
'.$langs->trans('RefSupplier').': '.$objp->ref_supplier; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datelimite, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datelimite, 'day'), + ); $fac = new FactureFournisseur($this->db); $fac->fetch($objp->facid); $alreadypaid = $fac->getSommePaiement(); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoUnpaidSupplierBills"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoUnpaidSupplierBills"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -201,8 +201,8 @@ class box_factures_fourn_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index f5fe3e76dde..e1b6a39b529 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -33,20 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; */ class box_factures_imp extends ModeleBoxes { - public $boxcode = "oldestunpaidcustomerbills"; - public $boximg = "object_bill"; - public $boxlabel = "BoxOldestUnpaidCustomerBills"; - public $depends = array("facture"); + public $boxcode = "oldestunpaidcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidCustomerBills"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,18 +57,18 @@ class box_factures_imp extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -77,10 +77,10 @@ class box_factures_imp extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $facturestatic = new Facture($this->db); - $societestatic = new Societe($this->db); + $facturestatic = new Facture($this->db); + $societestatic = new Societe($this->db); $langs->load("bills"); @@ -89,14 +89,14 @@ class box_factures_imp extends ModeleBoxes if ($user->rights->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; - $sql .= " s.code_client,"; - $sql .= " s.logo,"; + $sql .= " s.code_client,"; + $sql .= " s.logo,"; $sql .= " f.ref, f.date_lim_reglement as datelimite,"; - $sql .= " f.type,"; + $sql .= " f.type,"; $sql .= " f.datef as df,"; - $sql .= " f.total as total_ht,"; - $sql .= " f.tva as total_tva,"; - $sql .= " f.total_ttc,"; + $sql .= " f.total as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut, f.rowid as facid"; $sql .= ", sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -128,54 +128,54 @@ class box_factures_imp extends ModeleBoxes { $objp = $this->db->fetch_object($result); $datelimite = $this->db->jdate($objp->datelimite); - $facturestatic->id = $objp->facid; - $facturestatic->ref = $objp->ref; - $facturestatic->type = $objp->type; - $facturestatic->total_ht = $objp->total_ht; - $facturestatic->total_tva = $objp->total_tva; - $facturestatic->total_ttc = $objp->total_ttc; + $facturestatic->id = $objp->facid; + $facturestatic->ref = $objp->ref; + $facturestatic->type = $objp->type; + $facturestatic->total_ht = $objp->total_ht; + $facturestatic->total_tva = $objp->total_tva; + $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->fk_statut; $facturestatic->date_lim_reglement = $this->db->jdate($objp->datelimite); - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->client = 1; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->client = 1; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $facturestatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $facturestatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1, '', 44), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1, '', 44), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall right"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall right"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datelimite, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datelimite, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), + ); $line++; } @@ -187,17 +187,17 @@ class box_factures_imp extends ModeleBoxes $this->db->free($result); } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -209,8 +209,8 @@ class box_factures_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 2c104bea729..fc9fcc9fc17 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_ficheinter extends ModeleBoxes { - public $boxcode = "ficheinter"; - public $boximg = "object_intervention"; - public $boxlabel = "BoxFicheInter"; - public $depends = array("ficheinter"); // conf->contrat->enabled + public $boxcode = "ficheinter"; + public $boximg = "object_intervention"; + public $boxlabel = "BoxFicheInter"; + public $depends = array("ficheinter"); // conf->contrat->enabled /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,11 +55,11 @@ class box_ficheinter extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->ficheinter->lire); + $this->hidden = !($user->rights->ficheinter->lire); } /** @@ -67,7 +67,7 @@ class box_ficheinter extends ModeleBoxes * * @param int $max Maximum number of records to load * @return void - */ + */ public function loadBox($max = 10) { global $user, $langs, $conf; @@ -120,26 +120,26 @@ class box_ficheinter extends ModeleBoxes $companystatic->email = $objp->semail; $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $ficheinterstatic->getNomUrl(1), - 'asis' => 1, + 'td' => 'class="nowraponall"', + 'text' => $ficheinterstatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $companystatic->getNomUrl(1), - 'asis' => 1, - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $companystatic->getNomUrl(1), + 'asis' => 1, + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'day'), - ); + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'day'), + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowrap right"', - 'text' => $ficheinterstatic->getLibStatut(3), - 'asis' => 1, + 'td' => 'class="nowrap right"', + 'text' => $ficheinterstatic->getLibStatut(3), + 'asis' => 1, ); $i++; @@ -153,15 +153,15 @@ class box_ficheinter extends ModeleBoxes $this->db->free($resql); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -174,8 +174,8 @@ class box_ficheinter extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 44dd891bfb8..4be895f769c 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -32,129 +32,129 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_fournisseurs extends ModeleBoxes { - public $boxcode = "lastsuppliers"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastSuppliers"; - public $depends = array("fournisseur"); + public $boxcode = "lastsuppliers"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastSuppliers"; + public $depends = array("fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->societe->lire && empty($user->socid)); - } + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - $langs->load("boxes"); + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->load("boxes"); $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max)); - if ($user->rights->societe->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; - $sql .= " s.code_fournisseur, s.email as semail,"; - $sql .= " s.logo, s.code_compta_fournisseur, s.entity"; - $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('societe').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " ORDER BY s.tms DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->societe->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid, s.datec, s.tms, s.status,"; + $sql .= " s.code_fournisseur, s.email as semail,"; + $sql .= " s.logo, s.code_compta_fournisseur, s.entity"; + $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('societe').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " ORDER BY s.tms DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) - { - $objp = $this->db->fetch_object($result); - $datec = $this->db->jdate($objp->datec); - $datem = $this->db->jdate($objp->tms); + $line = 0; + while ($line < $num) + { + $objp = $this->db->fetch_object($result); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->email = $objp->semail; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->logo = $objp->logo; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdpartytmp->entity = $objp->entity; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->semail; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->logo = $objp->logo; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->entity = $objp->entity; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartytmp->getNomUrl(1, '', 40), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartytmp->getNomUrl(1, '', 40), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedSuppliers"), - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedSuppliers"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -164,8 +164,8 @@ class box_fournisseurs extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 66497c2e94f..7efecc4001c 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -33,27 +33,27 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_goodcustomers extends ModeleBoxes { - public $boxcode = "goodcustomers"; - public $boximg = "object_company"; - public $boxlabel = "BoxGoodCustomers"; - public $depends = array("societe"); + public $boxcode = "goodcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxGoodCustomers"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -69,10 +69,10 @@ class box_goodcustomers extends ModeleBoxes } /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void */ public function loadBox($max = 5) { @@ -81,10 +81,10 @@ class box_goodcustomers extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); if ($user->rights->societe->lire) { @@ -119,24 +119,24 @@ class box_goodcustomers extends ModeleBoxes $nbimpaye = $objp->nbfact - $objp->nbfactpaye; $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day") + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day") ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') + 'td' => 'class="right"', + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) ); $line++; @@ -150,14 +150,14 @@ class box_goodcustomers extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', + 'td' => 'class="nohover opacitymedium left"', 'text' => $langs->trans("ReadPermissionNotAllowed") ); } @@ -171,8 +171,8 @@ class box_goodcustomers extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 9d5aeda7b36..d1fb6dd4114 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_permonth extends ModeleBoxes { - public $boxcode = "invoicespermonth"; - public $boximg = "object_bill"; - public $boxlabel = "BoxCustomersInvoicesPerMonth"; - public $depends = array("facture"); + public $boxcode = "invoicespermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCustomersInvoicesPerMonth"; + public $depends = array("facture"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -141,9 +141,9 @@ class box_graph_invoices_permonth extends ModeleBoxes $mesg = $px1->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); - $px1->SetData($data1); + $px1->SetData($data1); unset($data1); $i = $startyear; $legend = array(); while ($i <= $endyear) @@ -186,7 +186,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $mesg = $px2->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); $px2->SetData($data2); unset($data2); @@ -269,8 +269,8 @@ class box_graph_invoices_permonth extends ModeleBoxes } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -283,8 +283,8 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index b9fde24b759..1490f5ea6e9 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_supplier_permonth extends ModeleBoxes { - public $boxcode = "invoicessupplierpermonth"; - public $boximg = "object_bill"; - public $boxlabel = "BoxSuppliersInvoicesPerMonth"; - public $depends = array("fournisseur"); + public $boxcode = "invoicessupplierpermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxSuppliersInvoicesPerMonth"; + public $depends = array("fournisseur"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -130,7 +130,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$year.'.png'; @@ -138,12 +138,12 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $mesg = $px1->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); - $px1->SetData($data1); + $px1->SetData($data1); unset($data1); $i = $startyear; - $legend = array(); + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -183,7 +183,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $mesg = $px2->isGraphKo(); if (!$mesg) { - $langs->load("bills"); + $langs->load("bills"); $px2->SetData($data2); unset($data2); @@ -263,16 +263,16 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -285,8 +285,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 2ff1a579798..d9c26620553 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_permonth extends ModeleBoxes { - public $boxcode = "orderspermonth"; - public $boximg = "object_order"; - public $boxlabel = "BoxCustomersOrdersPerMonth"; - public $depends = array("commande"); + public $boxcode = "orderspermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxCustomersOrdersPerMonth"; + public $depends = array("commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_orders_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -97,9 +97,9 @@ class box_graph_orders_permonth extends ModeleBoxes if ($user->rights->commande->lire) { - $langs->load("orders"); + $langs->load("orders"); - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -133,7 +133,7 @@ class box_graph_orders_permonth extends ModeleBoxes $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-'.$endyear.'.png'; @@ -144,7 +144,7 @@ class box_graph_orders_permonth extends ModeleBoxes $px1->SetData($data1); unset($data1); $i = $startyear; - $legend = array(); + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) @@ -176,7 +176,7 @@ class box_graph_orders_permonth extends ModeleBoxes $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; - // default value for customer mode + // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$endyear.'.png'; if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-'.$endyear.'.png'; @@ -260,22 +260,22 @@ class box_graph_orders_permonth extends ModeleBoxes $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -288,8 +288,8 @@ class box_graph_orders_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index fb40ee1f68f..765c6324516 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_supplier_permonth extends ModeleBoxes { - public $boxcode = "orderssupplierpermonth"; - public $boximg = "object_order"; - public $boxlabel = "BoxSuppliersOrdersPerMonth"; - public $depends = array("fournisseur"); + public $boxcode = "orderssupplierpermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxSuppliersOrdersPerMonth"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -96,9 +96,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if ($user->rights->fournisseur->commande->lire) { - $langs->load("orders"); + $langs->load("orders"); - $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; @@ -259,22 +259,22 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength'=>500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -287,8 +287,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 957277005e7..407c66177b5 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -29,20 +29,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; */ class box_graph_product_distribution extends ModeleBoxes { - public $boxcode = "productdistribution"; - public $boximg = "object_product"; - public $boxlabel = "BoxProductDistribution"; - public $depends = array("product|service", "facture|propal|commande"); + public $boxcode = "productdistribution"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductDistribution"; + public $depends = array("product|service", "facture|propal|commande"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -58,7 +58,7 @@ class box_graph_product_distribution extends ModeleBoxes $this->db = $db; $this->hidden = !( - (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) ); @@ -68,7 +68,7 @@ class box_graph_product_distribution extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -138,7 +138,7 @@ class box_graph_product_distribution extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) { - $langs->load("propal"); + $langs->load("propal"); include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; $showpointvalue = 1; $nocolor = 0; @@ -197,7 +197,7 @@ class box_graph_product_distribution extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) { - $langs->load("orders"); + $langs->load("orders"); include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; $showpointvalue = 1; $nocolor = 0; @@ -315,8 +315,8 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($nbofgraph)) { - $langs->load("errors"); - $mesg = $langs->trans("ReadPermissionNotAllowed"); + $langs->load("errors"); + $mesg = $langs->trans("ReadPermissionNotAllowed"); } if (empty($conf->use_javascript_ajax)) { @@ -388,13 +388,13 @@ class box_graph_product_distribution extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', + 'td' => 'class="nohover opacitymedium left"', 'maxlength'=>500, 'text' => $mesg ); @@ -409,8 +409,8 @@ class box_graph_product_distribution extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 4231638948a..de1a1f8de83 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_propales_permonth extends ModeleBoxes { - public $boxcode = "propalpermonth"; - public $boximg = "object_propal"; - public $boxlabel = "BoxProposalsPerMonth"; - public $depends = array("propal"); + public $boxcode = "propalpermonth"; + public $boximg = "object_propal"; + public $boxlabel = "BoxProposalsPerMonth"; + public $depends = array("propal"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -61,7 +61,7 @@ class box_graph_propales_permonth extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -191,7 +191,7 @@ class box_graph_propales_permonth extends ModeleBoxes { if ($startmonth != 1) { - $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { $legend[] = $i; } @@ -260,22 +260,22 @@ class box_graph_propales_permonth extends ModeleBoxes $stringtoshow .= ''; } $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover center"', - 'textnoformat'=>$stringtoshow, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover center"', + 'textnoformat'=>$stringtoshow, + ); } else { $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength' => 500, - 'text' => $mesg, - ); + 'tr'=>'class="oddeven nohover"', + 'td' => 'class="nohover left"', + 'maxlength' => 500, + 'text' => $mesg, + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -288,8 +288,8 @@ class box_graph_propales_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index f6bbbb76854..2950eb9cfd8 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -31,179 +31,179 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_last_modified_ticket extends ModeleBoxes { - public $boxcode = "box_last_modified_ticket"; - public $boximg = "ticket"; - public $boxlabel; - public $depends = array("ticket"); + public $boxcode = "box_last_modified_ticket"; + public $boximg = "ticket"; + public $boxlabel; + public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $langs; + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; $langs->load("boxes"); $this->db = $db; - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedTicket"); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; - $text = $langs->trans("BoxLastModifiedTicketDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) - ); + $text = $langs->trans("BoxLastModifiedTicketDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text) + ); - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("BoxLastModifiedTicketContent"), - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastModifiedTicketContent"), + ); - if ($user->rights->ticket->read) { - $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + if ($user->rights->ticket->read) { + $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; + $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; + $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql .= " WHERE t.entity = ".$conf->entity; - // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) { - $sql .= " AND t.fk_soc= ".$user->socid; - } + $sql .= " WHERE t.entity = ".$conf->entity; + // $sql.= " AND e.rowid = er.fk_event"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= ".$user->socid; + } - $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; - $sql .= $this->db->plimit($max, 0); + $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - while ($i < $num) { - $objp = $this->db->fetch_object($resql); - $datec = $this->db->jdate($objp->datec); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - $late = ''; + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $late = ''; - $ticket = new Ticket($this->db); - $ticket->id = $objp->id; - $ticket->track_id = $objp->track_id; - $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; - $ticket->subject = $objp->subject; - if ($objp->fk_soc > 0) { - $thirdparty = new Societe($this->db); - $thirdparty->id = $objp->fk_soc; - $thirdparty->email = $objp->socemail; - $thirdparty->client = $objp->client; - $thirdparty->fournisseur = $objp->fournisseur; - $thirdparty->name = $objp->company_name; - $link = $thirdparty->getNomUrl(1); - } else { - $link = dol_print_email($objp->origin_email); - } + $ticket = new Ticket($this->db); + $ticket->id = $objp->id; + $ticket->track_id = $objp->track_id; + $ticket->ref = $objp->ref; + $ticket->fk_statut = $objp->fk_statut; + $ticket->subject = $objp->subject; + if ($objp->fk_soc > 0) { + $thirdparty = new Societe($this->db); + $thirdparty->id = $objp->fk_soc; + $thirdparty->email = $objp->socemail; + $thirdparty->client = $objp->client; + $thirdparty->fournisseur = $objp->fournisseur; + $thirdparty->name = $objp->company_name; + $link = $thirdparty->getNomUrl(1); + } else { + $link = dol_print_email($objp->origin_email); + } - $r = 0; + $r = 0; - // Ticket - $this->info_box_contents[$i][0] = array( - 'td' => 'class="nowraponall"', - 'text' => $ticket->getNomUrl(1), - 'asis' => 1, - ); - $r++; + // Ticket + $this->info_box_contents[$i][0] = array( + 'td' => 'class="nowraponall"', + 'text' => $ticket->getNomUrl(1), + 'asis' => 1, + ); + $r++; - // Subject - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="nowrap"', - 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, - ); - $r++; + // Subject + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowrap"', + 'text' => $objp->subject, // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + ); + $r++; - // Customer - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="tdoverflowmax150 maxwidth300onsmartphone"', - 'text' => $link, - 'asis' => 1, - ); - $r++; + // Customer + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="tdoverflowmax150 maxwidth300onsmartphone"', + 'text' => $link, + 'asis' => 1, + ); + $r++; - // Date creation - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'dayhour') - ); - $r++; + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'dayhour') + ); + $r++; - // Statut - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right nowraponall"', - 'text' => $ticket->getLibStatut(3) - ); - $r++; + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $ticket->getLibStatut(3) + ); + $r++; - $i++; - } + $i++; + } - if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); - } - } else { - dol_print_error($this->db); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed"), - ); - } - } + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); + } + } else { + dol_print_error($this->db); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed"), + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 252141db9eb..9ada300901c 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -31,177 +31,177 @@ require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; class box_last_ticket extends ModeleBoxes { - public $boxcode = "box_last_ticket"; - public $boximg = "ticket"; - public $boxlabel; - public $depends = array("ticket"); + public $boxcode = "box_last_ticket"; + public $boximg = "ticket"; + public $boxlabel; + public $depends = array("ticket"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $langs; - $langs->load("boxes"); - $this->db = $db; + /** + * Constructor + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $langs; + $langs->load("boxes"); + $this->db = $db; - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("BoxLastTicket"); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; + require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; - $text = $langs->trans("BoxLastTicketDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text), - ); + $text = $langs->trans("BoxLastTicketDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text), + ); - $this->info_box_contents[0][0] = array( - 'td' => 'class="left"', - 'text' => $langs->trans("BoxLastTicketContent"), - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="left"', + 'text' => $langs->trans("BoxLastTicketContent"), + ); - if ($user->rights->ticket->read) { - $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + if ($user->rights->ticket->read) { + $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; + $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; + $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql .= " WHERE t.entity = ".$conf->entity; - // $sql.= " AND e.rowid = er.fk_event"; - //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) { - $sql .= " AND t.fk_soc= ".$user->socid; - } + $sql .= " WHERE t.entity = ".$conf->entity; + // $sql.= " AND e.rowid = er.fk_event"; + //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($user->socid) { + $sql .= " AND t.fk_soc= ".$user->socid; + } - //$sql.= " AND t.fk_statut > 9"; + //$sql.= " AND t.fk_statut > 9"; - $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; - $sql .= $this->db->plimit($max, 0); + $sql .= " ORDER BY t.datec DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - while ($i < $num) { - $objp = $this->db->fetch_object($resql); - $datec = $this->db->jdate($objp->datec); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - $late = ''; + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $late = ''; - $ticket = new Ticket($this->db); - $ticket->id = $objp->id; - $ticket->track_id = $objp->track_id; - $ticket->ref = $objp->ref; - $ticket->fk_statut = $objp->fk_statut; - $ticket->subject = $objp->subject; - if ($objp->fk_soc > 0) { - $thirdparty = new Societe($this->db); - $thirdparty->id = $objp->fk_soc; - $thirdparty->email = $objp->socemail; - $thirdparty->client = $objp->client; - $thirdparty->fournisseur = $objp->fournisseur; - $thirdparty->name = $objp->company_name; - $link = $thirdparty->getNomUrl(1); - } else { - $link = dol_print_email($objp->origin_email); - } + $ticket = new Ticket($this->db); + $ticket->id = $objp->id; + $ticket->track_id = $objp->track_id; + $ticket->ref = $objp->ref; + $ticket->fk_statut = $objp->fk_statut; + $ticket->subject = $objp->subject; + if ($objp->fk_soc > 0) { + $thirdparty = new Societe($this->db); + $thirdparty->id = $objp->fk_soc; + $thirdparty->email = $objp->socemail; + $thirdparty->client = $objp->client; + $thirdparty->fournisseur = $objp->fournisseur; + $thirdparty->name = $objp->company_name; + $link = $thirdparty->getNomUrl(1); + } else { + $link = dol_print_email($objp->origin_email); + } - $r = 0; + $r = 0; - // Ticket - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="nowraponall"', - 'text' => $ticket->getNomUrl(1), - 'asis' => 1 - ); - $r++; + // Ticket + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="nowraponall"', + 'text' => $ticket->getNomUrl(1), + 'asis' => 1 + ); + $r++; - // Subject - $this->info_box_contents[$i][$r] = array( - 'td' => '', - 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, - ); - $r++; + // Subject + $this->info_box_contents[$i][$r] = array( + 'td' => '', + 'text' => $objp->subject, // Some event have no ref + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, + ); + $r++; - // Customer - $this->info_box_contents[$i][$r] = array( - 'td' => '', - 'text' => $link, - 'asis' => 1, - ); - $r++; + // Customer + $this->info_box_contents[$i][$r] = array( + 'td' => '', + 'text' => $link, + 'asis' => 1, + ); + $r++; - // Date creation - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datec, 'dayhour'), - ); - $r++; + // Date creation + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datec, 'dayhour'), + ); + $r++; - // Statut - $this->info_box_contents[$i][$r] = array( - 'td' => 'class="right nowraponall"', - 'text' => $ticket->getLibStatut(3), - ); - $r++; + // Statut + $this->info_box_contents[$i][$r] = array( + 'td' => 'class="right nowraponall"', + 'text' => $ticket->getLibStatut(3), + ); + $r++; - $i++; - } + $i++; + } - if ($num == 0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); - } - } else { - dol_print_error($this->db); - } - } else { - $this->info_box_contents[0][0] = array('td' => 'class="left"', - 'text' => $langs->trans("ReadPermissionNotAllowed")); - } - } + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text' => $langs->trans("BoxLastTicketNoRecordedTickets")); + } + } else { + dol_print_error($this->db); + } + } else { + $this->info_box_contents[0][0] = array('td' => 'class="left"', + 'text' => $langs->trans("ReadPermissionNotAllowed")); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 6af4468c669..b45986387a8 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -30,75 +30,75 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_lastlogin extends ModeleBoxes { - public $boxcode = "lastlogin"; - public $boximg = "object_user"; - public $boxlabel = 'BoxLoginInformation'; - public $depends = array("user"); + public $boxcode = "lastlogin"; + public $boximg = "object_user"; + public $boxlabel = 'BoxLoginInformation'; + public $depends = array("user"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $conf; - $this->db = $db; - } + $this->db = $db; + } - /** - * Charge les donnees en memoire pour affichage ulterieur - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Charge les donnees en memoire pour affichage ulterieur + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $textHead = $langs->trans("BoxLoginInformation"); - $this->info_box_head = array( - 'text' => $textHead, - 'limit'=> dol_strlen($textHead), - ); + $textHead = $langs->trans("BoxLoginInformation"); + $this->info_box_head = array( + 'text' => $textHead, + 'limit'=> dol_strlen($textHead), + ); - $line = 0; - $this->info_box_contents[$line][0] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $langs->trans("User"), - ); - $this->info_box_contents[$line][1] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $user->getNomUrl(-1), - 'asis' => 1 - ); + $line = 0; + $this->info_box_contents[$line][0] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $langs->trans("User"), + ); + $this->info_box_contents[$line][1] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $user->getNomUrl(-1), + 'asis' => 1 + ); - $line = 1; - $this->info_box_contents[$line][0] = array( - 'td' => '', - 'text' => $langs->trans("PreviousConnexion"), - ); - if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - else $tmp = $langs->trans("Unknown"); - $this->info_box_contents[$line][1] = array( - 'td' => '', - 'text' => $tmp, - ); - } + $line = 1; + $this->info_box_contents[$line][0] = array( + 'td' => '', + 'text' => $langs->trans("PreviousConnexion"), + ); + if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + else $tmp = $langs->trans("Unknown"); + $this->info_box_contents[$line][1] = array( + 'td' => '', + 'text' => $tmp, + ); + } /** @@ -109,8 +109,8 @@ class box_lastlogin extends ModeleBoxes * @param int $nooutput No print, only return string * @return void */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 2ca1fb3ae25..72bc088ae6c 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -32,28 +32,28 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_members extends ModeleBoxes { - public $boxcode = "lastmembers"; - public $boximg = "object_user"; - public $boxlabel = "BoxLastMembers"; - public $depends = array("adherent"); + public $boxcode = "lastmembers"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastMembers"; + public $depends = array("adherent"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; + public $param; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -72,7 +72,7 @@ class box_members extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -81,8 +81,8 @@ class box_members extends ModeleBoxes $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $memberstatic = new Adherent($this->db); + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $memberstatic = new Adherent($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); @@ -110,12 +110,12 @@ class box_members extends ModeleBoxes $memberstatic->lastname = $objp->lastname; $memberstatic->firstname = $objp->firstname; $memberstatic->id = $objp->rowid; - $memberstatic->ref = $objp->rowid; - $memberstatic->photo = $objp->photo; - $memberstatic->gender = $objp->gender; - $memberstatic->email = $objp->email; - $memberstatic->morphy = $objp->morphy; - $memberstatic->company = $objp->company; + $memberstatic->ref = $objp->rowid; + $memberstatic->photo = $objp->photo; + $memberstatic->gender = $objp->gender; + $memberstatic->email = $objp->email; + $memberstatic->morphy = $objp->morphy; + $memberstatic->company = $objp->company; if (!empty($objp->fk_soc)) { $memberstatic->socid = $objp->fk_soc; @@ -125,52 +125,52 @@ class box_members extends ModeleBoxes $memberstatic->name = $objp->company; } - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->getNomUrl(-1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->getNomUrl(-1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $memberstatic->company, - 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->company, + 'url' => DOL_URL_ROOT."/adherents/card.php?rowid=".$objp->rowid, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedCustomers"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedCustomers"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -180,8 +180,8 @@ class box_members extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index ec21d5d00cf..dde8294f80b 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -32,143 +32,143 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_mos extends ModeleBoxes { - public $boxcode = "lastmos"; - public $boximg = "object_mrp"; - public $boxlabel = "BoxTitleLatestModifiedMos"; - public $depends = array("mrp"); + public $boxcode = "lastmos"; + public $boximg = "object_mrp"; + public $boxlabel = "BoxTitleLatestModifiedMos"; + public $depends = array("mrp"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->bom->read); - } + $this->hidden = !($user->rights->bom->read); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; - include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $mostatic = new Mo($this->db); - $productstatic = new Product($this->db); - $userstatic = new User($this->db); + $mostatic = new Mo($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); - if ($user->rights->mrp->read) - { - $sql = "SELECT p.ref as product_ref"; - $sql .= ", c.rowid"; - $sql .= ", c.date_creation"; - $sql .= ", c.tms"; - $sql .= ", c.ref"; - $sql .= ", c.status"; - //$sql.= ", c.fk_user_valid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; - $sql .= " WHERE c.fk_product = p.rowid"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " ORDER BY c.tms DESC, c.ref DESC"; - $sql .= " ".$this->db->plimit($max, 0); + if ($user->rights->mrp->read) + { + $sql = "SELECT p.ref as product_ref"; + $sql .= ", c.rowid"; + $sql .= ", c.date_creation"; + $sql .= ", c.tms"; + $sql .= ", c.ref"; + $sql .= ", c.status"; + //$sql.= ", c.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= " WHERE c.fk_product = p.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " ORDER BY c.tms DESC, c.ref DESC"; + $sql .= " ".$this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $datem = $this->db->jdate($objp->tms); - $mostatic->id = $objp->rowid; - $mostatic->ref = $objp->ref; - $mostatic->id = $objp->socid; - $mostatic->status = $objp->status; - $productstatic->ref = $objp->product_ref; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem = $this->db->jdate($objp->tms); + $mostatic->id = $objp->rowid; + $mostatic->ref = $objp->ref; + $mostatic->id = $objp->socid; + $mostatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $mostatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $mostatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { - if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), - 'asis' => 1, - ); - } + if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''), + 'asis' => 1, + ); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $mostatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $mostatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedOrders") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedOrders") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -178,8 +178,8 @@ class box_mos extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 52591fa5292..06808ab2518 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -33,20 +33,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits extends ModeleBoxes { - public $boxcode = "lastproducts"; - public $boximg = "object_product"; - public $boxlabel = "BoxLastProducts"; - public $depends = array("produit"); + public $boxcode = "lastproducts"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProducts"; + public $depends = array("produit"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,21 +57,21 @@ class box_produits extends ModeleBoxes */ public function __construct($db, $param) { - global $conf, $user; + global $conf, $user; - $this->db = $db; + $this->db = $db; - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); - $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden = ($showmode != 1); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $this->hidden = ($showmode != 1); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -94,9 +94,9 @@ class box_produits extends ModeleBoxes // Add where from hooks if (is_object($hookmanager)) { - $parameters = array('boxproductlist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; + $parameters = array('boxproductlist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; } $sql .= $this->db->order('p.datec', 'DESC'); $sql .= $this->db->plimit($max, 0); @@ -128,33 +128,33 @@ class box_produits extends ModeleBoxes $objp->label = $objtp->label; } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->type = $objp->fk_product_type; - $productstatic->label = $objp->label; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $objp->label, - ); - $price = ''; - $price_base_type = ''; - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { - $price_base_type = $langs->trans($objp->price_base_type); - $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $objp->label, + ); + $price = ''; + $price_base_type = ''; + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) { + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); + } else //Parse the dynamic price + { $productstatic->fetch($objp->rowid, '', '', 1); - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($productstatic); - if ($price_result >= 0) { + $priceparser = new PriceParser($this->db); + $price_result = $priceparser->parseProduct($productstatic); + if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); @@ -163,69 +163,69 @@ class box_produits extends ModeleBoxes $price_base_type = $langs->trans("TTC"); } $price = price($price_result); - } - } + } + } $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $price, - ); + 'td' => 'class="right"', + 'text' => $price, + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="nowrap"', - 'text' => $price_base_type, - ); + 'td' => 'class="nowrap"', + 'text' => $price_base_type, + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, 'day'), - ); + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', - 'asis' => 1 - ); + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 1).'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 1).'', + 'asis' => 1 + ); - $line++; - } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProducts"), - ); + $line++; + } + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProducts"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 6845cb2db5f..893bb2273ab 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -35,20 +35,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits_alerte_stock extends ModeleBoxes { - public $boxcode = "productsalertstock"; - public $boximg = "object_product"; - public $boxlabel = "BoxProductsAlertStock"; - public $depends = array("produit"); + public $boxcode = "productsalertstock"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductsAlertStock"; + public $depends = array("produit"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -59,21 +59,21 @@ class box_produits_alerte_stock extends ModeleBoxes */ public function __construct($db, $param = '') { - global $conf, $user; + global $conf, $user; - $this->db = $db; + $this->db = $db; - $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); - $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); - $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); - $this->hidden = ($showmode != 1); + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>($user->rights->stock->lire), 'module'=>'product|service|stock'); + $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); + $this->hidden = ($showmode != 1); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -99,16 +99,16 @@ class box_produits_alerte_stock extends ModeleBoxes if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1'; // Add where from hooks - if (is_object($hookmanager)) - { - $parameters = array('boxproductalertstocklist'=>1); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; - } - $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,"; - $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; - $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; - $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; + if (is_object($hookmanager)) + { + $parameters = array('boxproductalertstocklist'=>1); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + } + $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,"; + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export"; + $sql .= " HAVING SUM(".$this->db->ifsql("s.reel IS NULL", "0", "s.reel").") < p.seuil_stock_alerte"; $sql .= $this->db->order('p.seuil_stock_alerte', 'DESC'); $sql .= $this->db->plimit($max, 0); @@ -118,11 +118,11 @@ class box_produits_alerte_stock extends ModeleBoxes $langs->load("stocks"); $num = $this->db->num_rows($result); $line = 0; - while ($line < $num) { + while ($line < $num) { $objp = $this->db->fetch_object($result); $datem = $this->db->jdate($objp->tms); - $price = ''; - $price_base_type = ''; + $price = ''; + $price_base_type = ''; // Multilangs if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active @@ -141,10 +141,10 @@ class box_produits_alerte_stock extends ModeleBoxes $objp->label = $objtp->label; } } - $productstatic->id = $objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->type = $objp->fk_product_type; - $productstatic->label = $objp->label; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->type = $objp->fk_product_type; + $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; $productstatic->barcode = $objp->barcode; $productstatic->status = $objp->tosell; @@ -156,27 +156,27 @@ class box_produits_alerte_stock extends ModeleBoxes $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra; $productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $productstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $objp->label, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $objp->label, + ); - if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) - { - $price_base_type = $langs->trans($objp->price_base_type); - $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); - } else //Parse the dynamic price - { + if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) + { + $price_base_type = $langs->trans($objp->price_base_type); + $price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc); + } else //Parse the dynamic price + { $productstatic->fetch($objp->rowid, '', '', 1); - $priceparser = new PriceParser($this->db); - $price_result = $priceparser->parseProduct($productstatic); - if ($price_result >= 0) { + $priceparser = new PriceParser($this->db); + $price_result = $priceparser->parseProduct($productstatic); + if ($price_result >= 0) { if ($objp->price_base_type == 'HT') { $price_base_type = $langs->trans("HT"); @@ -185,58 +185,58 @@ class box_produits_alerte_stock extends ModeleBoxes $price_base_type = $langs->trans("TTC"); } $price = price($price_result); - } - } - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => $price, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => $price_base_type, - ); + } + } $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, - 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', - 'asis' => 1 + 'td' => 'class="right nowraponall"', + 'text' => $price, ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 0).'', - 'asis' => 1 - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $price_base_type, + ); - $line++; - } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoTooLowStockProducts"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $objp->total_stock.' / '.$objp->seuil_stock_alerte, + 'text2'=>img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit", $objp->seuil_stock_alerte)), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tosell, 3, 0).'', + 'asis' => 1 + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => ''.$productstatic->LibStatut($objp->tobuy, 3, 0).'', + 'asis' => 1 + ); + + $line++; + } + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoTooLowStockProducts"), + ); $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -248,8 +248,8 @@ class box_produits_alerte_stock extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index e8b056322da..1afbdfc6837 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -31,174 +31,174 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_project extends ModeleBoxes { - public $boxcode = "project"; - public $boximg = "object_projectpub"; - public $boxlabel; - //var $depends = array("projet"); + public $boxcode = "project"; + public $boximg = "object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $user, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->db = $db; - $this->boxlabel = "OpenedProjects"; + $this->db = $db; + $this->boxlabel = "OpenedProjects"; - $this->hidden = !($user->rights->projet->lire); - } + $this->hidden = !($user->rights->projet->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max = $max; + $this->max = $max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask = 0; + $totalMnt = 0; + $totalnb = 0; + $totalnbTask = 0; - $textHead = $langs->trans("OpenedProjects"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $textHead = $langs->trans("OpenedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - // list the summary of the orders - if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); - $socid = 0; - //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + $socid = 0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId = ''; - if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId = ''; + if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok $sql .= " AND p.fk_statut = 1"; // Only open projects - if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users + if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users - $sql .= " ORDER BY p.datec DESC"; - //$sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY p.datec DESC"; + //$sql.= $this->db->plimit($max, 0); - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < min($num, $max)) { - $objp = $this->db->fetch_object($result); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < min($num, $max)) { + $objp = $this->db->fetch_object($result); - $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; - $projectstatic->title = $objp->title; - $projectstatic->public = $objp->public; - $projectstatic->statut = $objp->status; + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; + $projectstatic->title = $objp->title; + $projectstatic->public = $objp->public; + $projectstatic->statut = $objp->status; - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $objp->title, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $objp->title, + ); - $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql .= " WHERE p.entity IN (".getEntity('project').')'; - $sql .= " AND p.rowid = ".$objp->rowid; - $resultTask = $this->db->query($sql); - if ($resultTask) { - $objTask = $this->db->fetch_object($resultTask); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objTask->nb." ".$langs->trans("Tasks"), - ); - if ($objTask->nb > 0) - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", - ); - else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - $totalnbTask += $objTask->nb; - } else { - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - } - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); + $sql = "SELECT count(*) as nb, sum(progress) as totprogress"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql .= " WHERE p.entity IN (".getEntity('project').')'; + $sql .= " AND p.rowid = ".$objp->rowid; + $resultTask = $this->db->query($sql); + if ($resultTask) { + $objTask = $this->db->fetch_object($resultTask); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objTask->nb." ".$langs->trans("Tasks"), + ); + if ($objTask->nb > 0) + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => round($objTask->totprogress / $objTask->nb, 0)."%", + ); + else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + $totalnbTask += $objTask->nb; + } else { + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + } + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => $projectstatic->getLibStatut(3)); - $i++; - } - if ($max < $num) - { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); - $i++; - } - } - } + $i++; + } + if ($max < $num) + { + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $i++; + } + } + } - // Add the sum à the bottom of the boxes - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => round($num, 0)." ".$langs->trans("Projects"), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right liste_total" ', - 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="liste_total"', - 'text' => " ", - ); - } + // Add the sum à the bottom of the boxes + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total")." ".$textHead, + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => round($num, 0)." ".$langs->trans("Projects"), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right liste_total" ', + 'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))), + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="liste_total"', + 'text' => " ", + ); + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 331ff54cb8d..bbfa2f6fb19 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -33,155 +33,155 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_propales extends ModeleBoxes { - public $boxcode = "lastpropals"; - public $boximg = "object_propal"; - public $boxlabel = "BoxLastProposals"; - public $depends = array("propal"); // conf->propal->enabled + public $boxcode = "lastpropals"; + public $boximg = "object_propal"; + public $boxlabel = "BoxLastProposals"; + public $depends = array("propal"); // conf->propal->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->propale->lire); - } + $this->hidden = !($user->rights->propale->lire); + } - /** + /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $propalstatic = new Propal($this->db); - $societestatic = new Societe($this->db); + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $propalstatic = new Propal($this->db); + $societestatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."Propals", $max)); - if ($user->rights->propale->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; - $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."propal as p"; - if (!$user->rights->societe->client->voir && !$user->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->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; - else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->propale->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo, s.entity, s.email,"; + $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$user->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->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY p.datep DESC, p.ref DESC "; + else $sql .= " ORDER BY p.tms DESC, p.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $now = dol_now(); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $now = dol_now(); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->dp); - $datec = $this->db->jdate($objp->datec); - $datem = $this->db->jdate($objp->tms); - $dateterm = $this->db->jdate($objp->fin_validite); - $dateclose = $this->db->jdate($objp->date_cloture); - $propalstatic->id = $objp->rowid; - $propalstatic->ref = $objp->ref; - $propalstatic->total_ht = $objp->total_ht; - $propalstatic->total_tva = $objp->total_tva; - $propalstatic->total_ttc = $objp->total_ttc; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; - $societestatic->email = $objp->email; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->dp); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); + $propalstatic->id = $objp->rowid; + $propalstatic->ref = $objp->ref; + $propalstatic->total_ht = $objp->total_ht; + $propalstatic->total_tva = $objp->total_tva; + $propalstatic->total_ttc = $objp->total_ttc; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; + $societestatic->email = $objp->email; $societestatic->entity = $objp->entity; - $late = ''; - if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { - $late = img_warning($langs->trans("Late")); - } + $late = ''; + if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) { + $late = img_warning($langs->trans("Late")); + } - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $propalstatic->getNomUrl(1), - 'text2'=> $late, - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $propalstatic->getNomUrl(1), + 'text2'=> $late, + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $propalstatic->LibStatut($objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedProposals"), - ); + if ($num == 0) + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProposals"), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -191,8 +191,8 @@ class box_propales extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 1024ef1d4ec..10a8698aaf9 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -34,27 +34,27 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; */ class box_prospect extends ModeleBoxes { - public $boxcode = "lastprospects"; - public $boximg = "object_company"; - public $boxlabel = "BoxLastProspects"; - public $depends = array("societe"); + public $boxcode = "lastprospects"; + public $boximg = "object_company"; + public $boxlabel = "BoxLastProspects"; + public $depends = array("societe"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $enabled = 1; + public $enabled = 1; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -72,7 +72,7 @@ class box_prospect extends ModeleBoxes * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -88,10 +88,10 @@ class box_prospect extends ModeleBoxes { $sql = "SELECT s.nom as name, s.rowid as socid"; $sql .= ", s.code_client"; - $sql .= ", s.client, s.email"; - $sql .= ", s.code_fournisseur"; - $sql .= ", s.fournisseur"; - $sql .= ", s.logo"; + $sql .= ", s.client, s.email"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.logo"; $sql .= ", s.fk_stcomm, s.datec, s.tms, s.status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -115,58 +115,58 @@ class box_prospect extends ModeleBoxes $datec = $this->db->jdate($objp->datec); $datem = $this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->socid; - $thirdpartystatic->name = $objp->name; - $thirdpartystatic->email = $objp->email; - $thirdpartystatic->code_client = $objp->code_client; - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; - $thirdpartystatic->client = $objp->client; - $thirdpartystatic->fournisseur = $objp->fournisseur; - $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $thirdpartystatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => str_replace('img ', 'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => str_replace('img ', 'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $thirdpartystatic->LibStatut($objp->status, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) { - $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=> $langs->trans("NoRecordedProspects"), - ); - } + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=> $langs->trans("NoRecordedProspects"), + ); + } - $this->db->free($resql); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength' => 500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); + $this->db->free($resql); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); } } @@ -178,8 +178,8 @@ class box_prospect extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { + public function showBox($head = null, $contents = null, $nooutput = 0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index a5a1c4bea8a..c4a713a03b5 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_services_contracts extends ModeleBoxes { - public $boxcode = "lastproductsincontract"; - public $boximg = "object_product"; - public $boxlabel = "BoxLastProductsInContract"; - public $depends = array("service", "contrat"); + public $boxcode = "lastproductsincontract"; + public $boximg = "object_product"; + public $boxlabel = "BoxLastProductsInContract"; + public $depends = array("service", "contrat"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,18 +56,18 @@ class box_services_contracts extends ModeleBoxes */ public function __construct($db, $param) { - global $user; + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); + $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); } /** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load - * @return void + * @return void */ public function loadBox($max = 5) { @@ -83,10 +83,10 @@ class box_services_contracts extends ModeleBoxes if ($user->rights->service->lire && $user->rights->contrat->lire) { - $contractstatic = new Contrat($this->db); - $contractlinestatic = new ContratLigne($this->db); - $thirdpartytmp = new Societe($this->db); - $productstatic = new Product($this->db); + $contractstatic = new Contrat($this->db); + $contractlinestatic = new ContratLigne($this->db); + $thirdpartytmp = new Societe($this->db); + $productstatic = new Product($this->db); $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; @@ -182,31 +182,31 @@ class box_services_contracts extends ModeleBoxes $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $s, - 'asis' => 1 - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $s, + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contractstatic->getNomUrl(1), - 'asis' => 1 - ); + 'td' => 'class="nowraponall"', + 'text' => $contractstatic->getNomUrl(1), + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1), - 'asis' => 1 - ); + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1), + 'asis' => 1 + ); $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => dol_print_date($datem, 'day'), + 'td' => '', + 'text' => dol_print_date($datem, 'day'), 'text2'=> $late, - ); + ); $this->info_box_contents[$i][] = array( - 'td' => 'class="right" width="18"', + 'td' => 'class="right" width="18"', 'text' => $contractlinestatic->getLibStatut(3) ); @@ -220,15 +220,15 @@ class box_services_contracts extends ModeleBoxes $this->db->free($result); } else { $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength' => 500, - 'text' => ($this->db->error().' sql='.$sql), - ); + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error().' sql='.$sql), + ); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") ); } } @@ -241,8 +241,8 @@ class box_services_contracts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index d7b3433f6d2..7a65fd0a9d2 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -30,160 +30,160 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_services_expired extends ModeleBoxes { - public $boxcode = "expiredservices"; // id of box - public $boximg = "object_contract"; - public $boxlabel = "BoxOldestExpiredServices"; - public $depends = array("contrat"); // conf->propal->enabled + public $boxcode = "expiredservices"; // id of box + public $boximg = "object_contract"; + public $boxlabel = "BoxOldestExpiredServices"; + public $depends = array("contrat"); // conf->propal->enabled - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); - } + $this->hidden = !($user->rights->contrat->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $now = dol_now(); + $now = dol_now(); - $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); - if ($user->rights->contrat->lire) - { - // Select contracts with at least one expired service + if ($user->rights->contrat->lire) + { + // Select contracts with at least one expired service $sql = "SELECT "; - $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; $sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; - $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; - if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; - $sql .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; - $sql .= " ORDER BY date_line ASC"; - $sql .= $this->db->plimit($max, 0); + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; + if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; + $sql .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= " ORDER BY date_line ASC"; + $sql .= $this->db->plimit($max, 0); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); - $i = 0; + $i = 0; - $thirdpartytmp = new Societe($this->db); - $contract = new Contrat($this->db); + $thirdpartytmp = new Societe($this->db); + $contract = new Contrat($this->db); - while ($i < $num) - { - $late = ''; + while ($i < $num) + { + $late = ''; - $objp = $this->db->fetch_object($resql); + $objp = $this->db->fetch_object($resql); - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->client = $objp->client; - $thirdpartytmp->fournisseur = $objp->fournisseur; - $thirdpartytmp->code_client = $objp->code_client; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->code_compta = $objp->code_compta; - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->id = $objp->socid; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->client = $objp->client; + $thirdpartytmp->fournisseur = $objp->fournisseur; + $thirdpartytmp->code_client = $objp->code_client; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->code_compta = $objp->code_compta; + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; - $contract->id = $objp->rowid; - $contract->ref = $objp->ref; - $contract->statut = $objp->fk_statut; - $contract->ref_customer = $objp->ref_customer; - $contract->ref_supplier = $objp->ref_supplier; + $contract->id = $objp->rowid; + $contract->ref = $objp->ref; + $contract->statut = $objp->fk_statut; + $contract->ref_customer = $objp->ref_customer; + $contract->ref_supplier = $objp->ref_supplier; $dateline = $this->db->jdate($objp->date_line); if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $contract->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $contract->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone left"', - 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone left"', + 'text' => $thirdpartytmp->getNomUrl(1, 'customer'), + 'asis' => 1 + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateline, 'day'), - 'text2'=> $late, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center nowraponall"', + 'text' => dol_print_date($dateline, 'day'), + 'text2'=> $late, + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="right"', - 'text' => $objp->nb_services, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="right"', + 'text' => $objp->nb_services, + ); - $i++; - } + $i++; + } - if ($num == 0) - { - $langs->load("contracts"); - $this->info_box_contents[$i][] = array( - 'td' => 'class="nohover opacitymedium center"', - 'text' => $langs->trans("NoExpiredServices"), - ); - } + if ($num == 0) + { + $langs->load("contracts"); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nohover opacitymedium center"', + 'text' => $langs->trans("NoExpiredServices"), + ); + } $this->db->free($resql); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -193,8 +193,8 @@ class box_services_expired extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 8574b7ce01b..1b3c865f5a1 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -32,152 +32,152 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_shipments extends ModeleBoxes { - public $boxcode = "lastcustomershipments"; - public $boximg = "sending"; - public $boxlabel = "BoxLastCustomerShipments"; - public $depends = array("expedition"); + public $boxcode = "lastcustomershipments"; + public $boximg = "sending"; + public $boxlabel = "BoxLastCustomerShipments"; + public $depends = array("expedition"); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->expedition->lire); - } + $this->hidden = !($user->rights->expedition->lire); + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $user, $langs, $conf; - $langs->loadLangs(array('orders', 'sendings')); + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->loadLangs(array('orders', 'sendings')); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $shipmentstatic = new Expedition($this->db); - $orderstatic = new Commande($this->db); - $societestatic = new Societe($this->db); + $shipmentstatic = new Expedition($this->db); + $orderstatic = new Commande($this->db); + $societestatic = new Societe($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); - if ($user->rights->expedition->lire) - { - $sql = "SELECT s.nom as name"; - $sql .= ", s.rowid as socid"; - $sql .= ", s.code_client"; - $sql .= ", s.logo, s.email"; - $sql .= ", e.ref, e.tms"; - $sql .= ", e.rowid"; - $sql .= ", e.ref_customer"; - $sql .= ", e.fk_statut"; - $sql .= ", e.fk_user_valid"; - $sql .= ", c.ref as commande_ref"; - $sql .= ", c.rowid as commande_id"; - $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; - if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; - else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->expedition->lire) + { + $sql = "SELECT s.nom as name"; + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", e.ref, e.tms"; + $sql .= ", e.rowid"; + $sql .= ", e.ref_customer"; + $sql .= ", e.fk_statut"; + $sql .= ", e.fk_user_valid"; + $sql .= ", c.ref as commande_ref"; + $sql .= ", c.rowid as commande_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; + else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); - $line = 0; + $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); + while ($line < $num) { + $objp = $this->db->fetch_object($result); - $shipmentstatic->id = $objp->rowid; - $shipmentstatic->ref = $objp->ref; - $shipmentstatic->ref_customer = $objp->ref_customer; + $shipmentstatic->id = $objp->rowid; + $shipmentstatic->ref = $objp->ref; + $shipmentstatic->ref_customer = $objp->ref_customer; - $orderstatic->id = $objp->commande_id; - $orderstatic->ref = $objp->commande_ref; + $orderstatic->id = $objp->commande_id; + $orderstatic->ref = $objp->commande_ref; - $societestatic->id = $objp->socid; - $societestatic->name = $objp->name; - $societestatic->email = $objp->email; - $societestatic->code_client = $objp->code_client; - $societestatic->logo = $objp->logo; + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $shipmentstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $shipmentstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $orderstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowraponall"', + 'text' => $orderstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), + ); - $line++; - } + $line++; + } - if ($num == 0) $this->info_box_contents[$line][0] = array( - 'td' => 'class="center opacitymedium"', - 'text'=>$langs->trans("NoRecordedShipments") - ); + if ($num == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedShipments") + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box @@ -187,8 +187,8 @@ class box_shipments extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index cdc1dd51440..6c5dd4379d3 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -31,160 +31,160 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_supplier_orders extends ModeleBoxes { - public $boxcode = "latestsupplierorders"; - public $boximg = "object_order"; - public $boxlabel = "BoxLatestSupplierOrders"; - public $depends = array("fournisseur"); + public $boxcode = "latestsupplierorders"; + public $boximg = "object_order"; + public $boxlabel = "BoxLatestSupplierOrders"; + public $depends = array("fournisseur"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param) - { - global $user; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; - $this->db = $db; + $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); - } + $this->hidden = !($user->rights->fournisseur->commande->lire); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; - $langs->load("boxes"); + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; + $langs->load("boxes"); - $this->max = $max; + $this->max = $max; - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $supplierorderstatic = new CommandeFournisseur($this->db); - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $thirdpartytmp = new Fournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + $supplierorderstatic = new CommandeFournisseur($this->db); + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; + $thirdpartytmp = new Fournisseur($this->db); - $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierOrders", $max)); - if ($user->rights->fournisseur->commande->lire) - { - $sql = "SELECT s.nom as name, s.rowid as socid,"; - $sql .= " s.code_client, s.code_fournisseur,"; - $sql .= " s.logo, s.email,"; - $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; - $sql .= " c.total_ht,"; - $sql .= " c.tva as total_tva,"; - $sql .= " c.total_ttc,"; - $sql .= " c.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE c.fk_soc = s.rowid"; - $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; - else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; - $sql .= $this->db->plimit($max, 0); + if ($user->rights->fournisseur->commande->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid,"; + $sql .= " s.code_client, s.code_fournisseur,"; + $sql .= " s.logo, s.email,"; + $sql .= " c.rowid, c.ref, c.tms, c.date_commande,"; + $sql .= " c.total_ht,"; + $sql .= " c.tva as total_tva,"; + $sql .= " c.total_ttc,"; + $sql .= " c.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('supplier_order').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC "; + else $sql .= " ORDER BY c.tms DESC, c.ref DESC "; + $sql .= $this->db->plimit($max, 0); - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); - $line = 0; - while ($line < $num) { - $objp = $this->db->fetch_object($result); - $date = $this->db->jdate($objp->date_commande); + $line = 0; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_commande); $datem = $this->db->jdate($objp->tms); $supplierorderstatic->id = $objp->rowid; $supplierorderstatic->ref = $objp->ref; $thirdpartytmp->id = $objp->socid; - $thirdpartytmp->name = $objp->name; - $thirdpartytmp->email = $objp->email; - $thirdpartytmp->fournisseur = 1; - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; - $thirdpartytmp->logo = $objp->logo; - - $this->info_box_contents[$line][] = array( - 'td' => 'class="nowraponall"', - 'text' => $supplierorderstatic->getNomUrl(1), - 'asis' => 1 - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), - 'asis' => 1, - ); - - $this->info_box_contents[$line][] = array( - 'td' => 'class="right nowraponall"', - 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), - ); + $thirdpartytmp->name = $objp->name; + $thirdpartytmp->email = $objp->email; + $thirdpartytmp->fournisseur = 1; + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; + $thirdpartytmp->logo = $objp->logo; $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($date, 'day'), - ); + 'td' => 'class="nowraponall"', + 'text' => $supplierorderstatic->getNomUrl(1), + 'asis' => 1 + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right" width="18"', - 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), + 'asis' => 1, + ); - $line++; - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right nowraponall"', + 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency), + ); - if ($num == 0) - $this->info_box_contents[$line][] = array( - 'td' => 'class="center"', - 'text' => $langs->trans("NoSupplierOrder"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + ); - $this->db->free($result); - } else { - $this->info_box_contents[0][] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($this->db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - } + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $supplierorderstatic->LibStatut($objp->fk_statut, 3), + ); - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + $line++; + } + + if ($num == 0) + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoSupplierOrder"), + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 8701c67d711..7abe2369a68 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -31,41 +31,41 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; */ class box_task extends ModeleBoxes { - public $boxcode = "projettask"; - public $boximg = "object_projecttask"; - public $boxlabel; - public $depends = array("projet"); + public $boxcode = "projettask"; + public $boximg = "object_projecttask"; + public $boxlabel; + public $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; - public $enabled = 1; // enable because fixed ;-). + public $param; + public $enabled = 1; // enable because fixed ;-). - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $conf, $user, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->boxlabel = "Tasks"; - $this->db = $db; + $this->boxlabel = "Tasks"; + $this->db = $db; - $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); - } + $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); + } /** * Load data for box to show them later @@ -94,7 +94,7 @@ class box_task extends ModeleBoxes if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { $filterValue = GETPOST($cookie_name); } elseif (!empty($_COOKIE[$cookie_name])) { - $filterValue = preg_replace('/[^a-z_]/', '', $_COOKIE[$cookie_name]); // Clean cookie from evil data + $filterValue = preg_replace('/[^a-z_]/', '', $_COOKIE[$cookie_name]); // Clean cookie from evil data } if ($filterValue == 'im_task_contact') { @@ -175,33 +175,33 @@ class box_task extends ModeleBoxes $i = 1; if ($result) { $num = $this->db->num_rows($result); - while ($objp = $this->db->fetch_object($result)) { - $taskstatic->id = $objp->rowid; - $taskstatic->ref = $objp->ref; - $taskstatic->label = $objp->label; - $taskstatic->progress = $objp->progress; - $taskstatic->fk_statut = $objp->fk_statut; - $taskstatic->date_end = $this->db->jdate($objp->datee); - $taskstatic->planned_workload = $objp->planned_workload; - $taskstatic->duration_effective = $objp->duration_effective; + while ($objp = $this->db->fetch_object($result)) { + $taskstatic->id = $objp->rowid; + $taskstatic->ref = $objp->ref; + $taskstatic->label = $objp->label; + $taskstatic->progress = $objp->progress; + $taskstatic->fk_statut = $objp->fk_statut; + $taskstatic->date_end = $this->db->jdate($objp->datee); + $taskstatic->planned_workload = $objp->planned_workload; + $taskstatic->duration_effective = $objp->duration_effective; - $projectstatic->id = $objp->project_id; - $projectstatic->ref = $objp->project_ref; - $projectstatic->title = $objp->project_title; + $projectstatic->id = $objp->project_id; + $projectstatic->ref = $objp->project_ref; + $projectstatic->title = $objp->project_title; - $label = $projectstatic->getNomUrl(1).'   '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); + $label = $projectstatic->getNomUrl(1).'   '.$taskstatic->getNomUrl(1).' '.dol_htmlentities($taskstatic->label); - $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); + $boxcontent = getTaskProgressView($taskstatic, $label, true, false, false); - $this->info_box_contents[$i][] = array( - 'td' => '', - 'text' => $boxcontent, - ); + $this->info_box_contents[$i][] = array( + 'td' => '', + 'text' => $boxcontent, + ); $i++; } } else { - dol_print_error($this->db); - } + dol_print_error($this->db); + } } } diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index b4eddf5f18d..87f0664ecb9 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -31,95 +31,95 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_validated_projects extends ModeleBoxes { - public $boxcode="validated_project"; - public $boximg="object_projectpub"; - public $boxlabel; - //var $depends = array("projet"); + public $boxcode="validated_project"; + public $boximg="object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - public $param; + public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); - public $enabled = 1; + public $enabled = 1; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $param More parameters - */ - public function __construct($db, $param = '') - { - global $conf, $user, $langs; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user, $langs; - // Load translation files required by the page - $langs->loadLangs(array('boxes', 'projects')); + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); - $this->db = $db; - $this->boxlabel = "ProjectsWithTask"; + $this->db = $db; + $this->boxlabel = "ProjectsWithTask"; - $this->hidden = ! ($user->rights->projet->lire); + $this->hidden = ! ($user->rights->projet->lire); if ($conf->global->MAIN_FEATURES_LEVEL < 2) $this->enabled = 0; - } + } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs; - $this->max=$max; + $this->max=$max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask=0; + $totalMnt = 0; + $totalnb = 0; + $totalnbTask=0; - $textHead = $langs->trans("ProjectTasksWithoutTimeSpent"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $textHead = $langs->trans("ProjectTasksWithoutTimeSpent"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - // list the summary of the orders - if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); + // list the summary of the orders + if ($user->rights->projet->lire) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); - $socid=0; - //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. + $socid=0; + //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. - // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId=''; - if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + // Get list of project id allowed to user (in a string list separated by coma) + $projectsListId=''; + if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - // I tried to solve sql error and performance problem, rewriting sql request but it is not clear what we want. - // Count of tasks without time spent for tasks we are assigned too or - // Count of tasks without time spent for all tasks of projects we are allowed to read (what it does) ? - $sql = "SELECT p.rowid, p.ref, p.fk_soc, p.dateo as startdate,"; - $sql.= " COUNT(DISTINCT t.rowid) as tasknumber"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; - // TODO Replace -1, -2, -3 with ID used for type of contat project_task into llx_c_type_contact. Once done, we can switch widget as stable. - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid AND fk_c_type_contact IN (-1, -2, -3)"; - $sql.= " WHERE p.fk_statut = 1"; // Only open projects - if ($projectsListId) $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed + // I tried to solve sql error and performance problem, rewriting sql request but it is not clear what we want. + // Count of tasks without time spent for tasks we are assigned too or + // Count of tasks without time spent for all tasks of projects we are allowed to read (what it does) ? + $sql = "SELECT p.rowid, p.ref, p.fk_soc, p.dateo as startdate,"; + $sql.= " COUNT(DISTINCT t.rowid) as tasknumber"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet AS p"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task AS t ON p.rowid = t.fk_projet"; + // TODO Replace -1, -2, -3 with ID used for type of contat project_task into llx_c_type_contact. Once done, we can switch widget as stable. + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid AND fk_c_type_contact IN (-1, -2, -3)"; + $sql.= " WHERE p.fk_statut = 1"; // Only open projects + if ($projectsListId) $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed $sql.= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")"; $sql.= " GROUP BY p.rowid, p.ref, p.fk_soc, p.dateo"; - $sql.= " ORDER BY p.dateo ASC"; + $sql.= " ORDER BY p.dateo ASC"; - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', 'text' => "Reference projet", @@ -138,67 +138,67 @@ class box_validated_projects extends ModeleBoxes ); $i++; - while ($i < min($num+1, $max+1)) { - $objp = $this->db->fetch_object($result); + while ($i < min($num+1, $max+1)) { + $objp = $this->db->fetch_object($result); - $projectstatic->id = $objp->rowid; - $projectstatic->ref = $objp->ref; + $projectstatic->id = $objp->rowid; + $projectstatic->ref = $objp->ref; - $this->info_box_contents[$i][] = array( - 'td' => 'class="nowraponall"', - 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="nowraponall"', + 'text' => $projectstatic->getNomUrl(1), + 'asis' => 1 + ); - if ($objp->fk_soc > 0) { - $sql = 'SELECT rowid, nom as name FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->fk_soc; - $resql = $this->db->query($sql); - //$socstatic = new Societe($this->db); - $obj2 = $this->db->fetch_object($resql); - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => $obj2->name, - 'asis' => 1, - 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj2->rowid - ); - } - else { - $this->info_box_contents[$i][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', - 'text' => '', - 'asis' => 1, - 'url' => '' - ); - } + if ($objp->fk_soc > 0) { + $sql = 'SELECT rowid, nom as name FROM '.MAIN_DB_PREFIX.'societe WHERE rowid ='.$objp->fk_soc; + $resql = $this->db->query($sql); + //$socstatic = new Societe($this->db); + $obj2 = $this->db->fetch_object($resql); + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => $obj2->name, + 'asis' => 1, + 'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj2->rowid + ); + } + else { + $this->info_box_contents[$i][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"', + 'text' => '', + 'asis' => 1, + 'url' => '' + ); + } - $this->info_box_contents[$i][] = array( - 'td' => 'class="center"', - 'text' => $objp->startDate, - ); + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => $objp->startDate, + ); - $this->info_box_contents[$i][] = array( - 'td' => 'class="center"', - 'text' => $objp->tasknumber." ".$langs->trans("Tasks"), + $this->info_box_contents[$i][] = array( + 'td' => 'class="center"', + 'text' => $objp->tasknumber." ".$langs->trans("Tasks"), 'asis' => 1, - ); - $i++; - } - }else { - dol_print_error($this->db); + ); + $i++; + } + }else { + dol_print_error($this->db); } - } - } + } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/intracommreport_box.php b/htdocs/core/boxes/intracommreport_box.php index 1df09500173..d7c383138b6 100644 --- a/htdocs/core/boxes/intracommreport_box.php +++ b/htdocs/core/boxes/intracommreport_box.php @@ -22,7 +22,7 @@ * \brief This file is a sample box definition file * Put some comments here */ -include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; +include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box @@ -30,59 +30,59 @@ include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; class intracommreportbox extends ModeleBoxes { - public $boxcode = "mybox"; - public $boximg = "intracommreport"; - public $boxlabel; - public $depends = array("intracommreport"); - public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); + public $boxcode = "mybox"; + public $boximg = "intracommreport"; + public $boxlabel; + public $depends = array("intracommreport"); + public $db; + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); - /** - * Constructor - */ - public function __construct() - { - global $langs; - $langs->load("boxes"); + /** + * Constructor + */ + public function __construct() + { + global $langs; + $langs->load("boxes"); - $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); - } + $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); + } - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs, $db; + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs, $db; - $this->max = $max; + $this->max = $max; - //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; + //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; - $text = $langs->trans("MyBoxDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) - ); + $text = $langs->trans("MyBoxDescription", $max); + $this->info_box_head = array( + 'text' => $text, + 'limit' => dol_strlen($text) + ); - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->trans("MyBoxContent")); - } + $this->info_box_contents[0][0] = array('td' => 'align="left"', + 'text' => $langs->trans("MyBoxContent")); + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @return void - */ - public function showBox($head = null, $contents = null) - { - parent::showBox($this->info_box_head, $this->info_box_contents); - } + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @return void + */ + public function showBox($head = null, $contents = null) + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } } diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index d68d8b4dc3b..a4d9aca57fd 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -113,7 +113,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * Constructor * * @param DoliDB $db Database handler - * @param string $param More parameters + * @param string $param More parameters */ public function __construct($db, $param = '') { @@ -156,7 +156,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box if ($obj) { $this->id = $obj->id; - $this->rowid = $obj->id; // For backward compatibility + $this->rowid = $obj->id; // For backward compatibility $this->box_id = $obj->box_id; $this->position = $obj->position; $this->box_order = $obj->box_order; @@ -184,180 +184,180 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box if (!empty($this->hidden)) return '\n\n'; // Nothing done if hidden (for example when user has no permission) - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $MAXLENGTHBOX = 60; // Mettre 0 pour pas de limite - $cachetime = 900; // 900 : 15mn - $cachedir = DOL_DATA_ROOT.'/boxes/temp'; - $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; - $filename = '/box-'.$fileid; - $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); - $out = ''; + $cachetime = 900; // 900 : 15mn + $cachedir = DOL_DATA_ROOT.'/boxes/temp'; + $fileid = get_class($this).'id-'.$this->box_id.'-e'.$conf->entity.'-u'.$user->id.'-s'.$user->socid.'.cache'; + $filename = '/box-'.$fileid; + $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $out = ''; - if ($refresh) { - dol_syslog(get_class($this).'::showBox'); + if ($refresh) { + dol_syslog(get_class($this).'::showBox'); - // Define nbcol and nblines of the box to show - $nbcol = 0; - if (isset($contents[0])) $nbcol = count($contents[0]); - $nblines = count($contents); + // Define nbcol and nblines of the box to show + $nbcol = 0; + if (isset($contents[0])) $nbcol = count($contents[0]); + $nblines = count($contents); - $out .= "\n\n"; + $out .= "\n\n"; - $out .= '
'."\n"; + $out .= '
'."\n"; - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) - { - $out .= ''."\n"; - } + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) + { + $out .= '
'."\n"; + } - // Show box title - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) - { - $out .= ''; - $out .= ' 0) { $out .= ' colspan="'.$nbcol.'"'; } - $out .= '>'; - if (!empty($conf->use_javascript_ajax)) - { - //$out.= '
'; + // Show box title + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) + { + $out .= ''; + $out .= ' 0) { $out .= ' colspan="'.$nbcol.'"'; } + $out .= '>'; + if (!empty($conf->use_javascript_ajax)) + { + //$out.= '
'; - $out .= '
'; - } - if (!empty($head['text'])) - { - $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); - $out .= $s; - } - if (!empty($conf->use_javascript_ajax)) - { - $out .= '
'; - } - //$out.= '
'; - if (!empty($conf->use_javascript_ajax)) - { - $sublink = ''; - if (!empty($head['sublink'])) $sublink .= ''; - if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); - if (!empty($head['sublink'])) $sublink .= ''; + if (!empty($conf->use_javascript_ajax)) + { + $sublink = ''; + if (!empty($head['sublink'])) $sublink .= ''; + if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"'); + if (!empty($head['sublink'])) $sublink .= ''; - //$out.= '
'; + $out .= '
'; + } + if (!empty($head['text'])) + { + $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); + $out .= $s; + } + if (!empty($conf->use_javascript_ajax)) + { + $out .= '
'; + } + //$out.= '
'; - $out .= '
'; - $out .= $sublink; - // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object - $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"'); - $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"'); - $label = $head['text']; - //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; - if (!empty($head['graph'])) $label .= ' '; - $out .= ''; - //$out.= '
'; - $out .= '
'; - } + //$out.= ''; + $out .= '
'; + $out .= $sublink; + // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object + $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"'); + $out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"'); + $label = $head['text']; + //if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')'; + if (!empty($head['graph'])) $label .= ' '; + $out .= ''; + //$out.= ''; + $out .= '
'; + } - $out .= ""; - $out .= "\n"; - } + $out .= ""; + $out .= "\n"; + } - // Show box lines - if ($nblines) - { - // Loop on each record - for ($i = 0, $n = $nblines; $i < $n; $i++) - { - if (isset($contents[$i])) - { - // TR - if (isset($contents[$i][0]['tr'])) $out .= ''; - else $out .= ''; + // Show box lines + if ($nblines) + { + // Loop on each record + for ($i = 0, $n = $nblines; $i < $n; $i++) + { + if (isset($contents[$i])) + { + // TR + if (isset($contents[$i][0]['tr'])) $out .= ''; + else $out .= ''; - // Loop on each TD - $nbcolthisline = count($contents[$i]); - for ($j = 0; $j < $nbcolthisline; $j++) { - // Define tdparam - $tdparam = ''; - if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; + // Loop on each TD + $nbcolthisline = count($contents[$i]); + for ($j = 0; $j < $nbcolthisline; $j++) { + // Define tdparam + $tdparam = ''; + if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; - $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; - $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); - $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; - $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); + $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; + $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); + $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; + $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); - $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; - //$out.= "xxx $textwithnotags y"; - if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = ""; - $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; + $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; + //$out.= "xxx $textwithnotags y"; + if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = ""; + $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; - $out .= ''."\n"; + $out .= ''."\n"; - // Url - if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) - { - $out .= 'trans("Show").' '.$tooltip, 1).'" class="classfortooltip"'; - } - //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "" - $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : ''; - $out .= '>'; - } + // Url + if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) + { + $out .= 'trans("Show").' '.$tooltip, 1).'" class="classfortooltip"'; + } + //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "" + $out .= isset($contents[$i][$j]['target']) ? ' target="'.$contents[$i][$j]['target'].'"' : ''; + $out .= '>'; + } - // Logo - if (!empty($contents[$i][$j]['logo'])) - { - $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); - $out .= ''; - $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); - } + // Logo + if (!empty($contents[$i][$j]['logo'])) + { + $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); + $out .= ''; + $out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"'); + } - $maxlength = $MAXLENGTHBOX; - if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength']; + $maxlength = $MAXLENGTHBOX; + if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength']; - if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength); - if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning - else $out .= $textwithnotags; // show text with html cleaning + if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength); + if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning + else $out .= $textwithnotags; // show text with html cleaning - // End Url - if (!empty($contents[$i][$j]['url'])) $out .= ''; + // End Url + if (!empty($contents[$i][$j]['url'])) $out .= ''; - if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning - else $out .= $text2withnotags; // show text with html cleaning + if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning + else $out .= $text2withnotags; // show text with html cleaning - if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n"; + if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n"; - $out .= "\n"; - } + $out .= "\n"; + } - $out .= "\n"; - } - } - } + $out .= "\n"; + } + } + } - if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) - { - $out .= "\n"; - } + if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) + { + $out .= "\n"; + } - // If invisible box with no contents - if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "
\n"; + // If invisible box with no contents + if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "
\n"; - $out .= "
\n"; + $out .= "\n"; - $out .= "\n\n"; - if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - dol_filecache($cachedir, $filename, $out); - } - } else { - dol_syslog(get_class($this).'::showBoxCached'); - $out = ""; - $out .= dol_readcachefile($cachedir, $filename); - } + $out .= "\n\n"; + if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { + dol_filecache($cachedir, $filename, $out); + } + } else { + dol_syslog(get_class($this).'::showBoxCached'); + $out = ""; + $out .= dol_readcachefile($cachedir, $filename); + } - if ($nooutput) return $out; - else print $out; + if ($nooutput) return $out; + else print $out; - return ''; + return ''; } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 7f51b47d0b6..65c017e3dad 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -294,13 +294,13 @@ class CMailFile $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; } - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); - $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_' . $smtpContextKey; + $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_' . $smtpContextKey; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey; } } @@ -653,19 +653,19 @@ class CMailFile $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW'; $keyfortls = 'MAIN_MAIL_EMAIL_TLS'; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS'; - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED'; if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { - $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_' . $smtpContextKey; - $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_' . $smtpContextKey; - $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_' . $smtpContextKey; - $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_' . $smtpContextKey; - $keyfortls = 'MAIN_MAIL_EMAIL_TLS_' . $smtpContextKey; - $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_' . $smtpContextKey; - $keyforsslseflsigned ='MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_' . $smtpContextKey; + $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey; + $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey; + $keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey; + $keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey; + $keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey; + $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey; + $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey; } } diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 4f1959d2707..62257e79447 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -34,7 +34,7 @@ */ class CSMSFile { - /** + /** * @var string Error code (or message) */ public $error = ''; @@ -76,21 +76,21 @@ class CSMSFile // If ending method not defined if (empty($conf->global->MAIN_SMS_SENDMODE)) { - $this->error = 'No SMS Engine defined'; - return -1; + $this->error = 'No SMS Engine defined'; + return -1; } dol_syslog("CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".$conf->global->MAIN_SMS_SENDMODE." charset=".$conf->file->character_set_client." from=".$from.", to=".$to.", msg length=".count($msg), LOG_DEBUG); dol_syslog("CSMSFile::CSMSFile: deferred=".$deferred." priority=".$priority." class=".$class, LOG_DEBUG); // Action according to choosed sending method - $this->addr_from = $from; - $this->addr_to = $to; - $this->deferred = $deferred; - $this->priority = $priority; - $this->class = $class; - $this->message = $msg; - $this->nostop = false; + $this->addr_from = $from; + $this->addr_to = $to; + $this->deferred = $deferred; + $this->priority = $priority; + $this->class = $class; + $this->message = $msg; + $this->nostop = false; } @@ -108,17 +108,17 @@ class CSMSFile $res = false; - dol_syslog("CSMSFile::sendfile addr_to=".$this->addr_to, LOG_DEBUG); - dol_syslog("CSMSFile::sendfile message=\n".$this->message); + dol_syslog("CSMSFile::sendfile addr_to=".$this->addr_to, LOG_DEBUG); + dol_syslog("CSMSFile::sendfile message=\n".$this->message); - $this->message = stripslashes($this->message); + $this->message = stripslashes($this->message); - if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms(); + if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms(); if (empty($conf->global->MAIN_DISABLE_ALL_SMS)) { - // Action according to choosed sending method - if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated + // Action according to choosed sending method + if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated { dol_include_once('/ovh/class/ovhsms.class.php'); $sms = new OvhSms($this->db); @@ -127,14 +127,14 @@ class CSMSFile $sms->message = $this->message; $sms->deferred = $this->deferred; $sms->priority = $this->priority; - $sms->class = $this->class; - $sms->nostop = $this->nostop; + $sms->class = $this->class; + $sms->nostop = $this->nostop; - $sms->socid = $this->socid; - $sms->contact_id = $this->contact_id; - $sms->project = $this->fk_project; + $sms->socid = $this->socid; + $sms->contact_id = $this->contact_id; + $sms->project = $this->fk_project; - $res = $sms->SmsSend(); + $res = $sms->SmsSend(); if ($res <= 0) { @@ -146,42 +146,42 @@ class CSMSFile if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); } } elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module' - { - $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); - $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); - dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); - try { - $classname = ucfirst($classfile); - $sms = new $classname($this->db); - $sms->expe = $this->addr_from; - $sms->dest = $this->addr_to; - $sms->deferred = $this->deferred; - $sms->priority = $this->priority; - $sms->class = $this->class; - $sms->message = $this->message; - $sms->nostop = $this->nostop; + { + $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); + $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); + dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); + try { + $classname = ucfirst($classfile); + $sms = new $classname($this->db); + $sms->expe = $this->addr_from; + $sms->dest = $this->addr_to; + $sms->deferred = $this->deferred; + $sms->priority = $this->priority; + $sms->class = $this->class; + $sms->message = $this->message; + $sms->nostop = $this->nostop; - $sms->socid = $this->socid; - $sms->contact_id = $this->contact_id; - $sms->fk_project = $this->fk_project; + $sms->socid = $this->socid; + $sms->contact_id = $this->contact_id; + $sms->fk_project = $this->fk_project; - $res = $sms->SmsSend(); + $res = $sms->SmsSend(); - $this->error = $sms->error; - $this->errors = $sms->errors; - if ($res <= 0) - { - dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR); - } else { - dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG); - //var_dump($res); // 1973128 - if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); - } - } catch (Exception $e) - { - dol_print_error('', 'Error to get list of senders: '.$e->getMessage()); - } - } else { + $this->error = $sms->error; + $this->errors = $sms->errors; + if ($res <= 0) + { + dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR); + } else { + dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG); + //var_dump($res); // 1973128 + if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res); + } + } catch (Exception $e) + { + dol_print_error('', 'Error to get list of senders: '.$e->getMessage()); + } + } else { // Send sms method not correctly defined // -------------------------------------- @@ -198,17 +198,17 @@ class CSMSFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Write content of a SendSms request into a dump file (mode = all) - * Used for debugging. - * - * @return void - */ - public function dump_sms() - { - // phpcs:enable - global $conf, $dolibarr_main_data_root; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write content of a SendSms request into a dump file (mode = all) + * Used for debugging. + * + * @return void + */ + public function dump_sms() + { + // phpcs:enable + global $conf, $dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { @@ -229,29 +229,29 @@ class CSMSFile } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Write content of a SendSms result into a dump file (mode = all) - * Used for debugging. - * - * @param int $result Result of sms sending - * @return void - */ - public function dump_sms_result($result) - { - // phpcs:enable - global $conf, $dolibarr_main_data_root; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write content of a SendSms result into a dump file (mode = all) + * Used for debugging. + * + * @param int $result Result of sms sending + * @return void + */ + public function dump_sms_result($result) + { + // phpcs:enable + global $conf, $dolibarr_main_data_root; - if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir - { - $outputfile = $dolibarr_main_data_root."/dolibarr_sms.log"; - $fp = fopen($outputfile, "a+"); + if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir + { + $outputfile = $dolibarr_main_data_root."/dolibarr_sms.log"; + $fp = fopen($outputfile, "a+"); - fputs($fp, "\nResult id=".$result); + fputs($fp, "\nResult id=".$result); - fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } - } + fclose($fp); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); + } + } } diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index f897ae46a62..e6bd24ad016 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -45,9 +45,9 @@ class AntiVir public $output; /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * Constructor @@ -59,7 +59,7 @@ class AntiVir $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Scan a file with antivirus. * This function runs the command defined in setup. This antivirus command must return 0 if OK. @@ -70,24 +70,24 @@ class AntiVir */ public function dol_avscan_file($file) { - // phpcs:enable + // phpcs:enable global $conf; $return = 0; if (preg_match('/\.virus$/i', $file)) { - $this->errors[] = 'File has an extension saying file is a virus'; - return -97; + $this->errors[] = 'File has an extension saying file is a virus'; + return -97; } $fullcommand = $this->getCliCommand($file); //$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"'; - $fullcommand .= ' 2>&1'; // This is to get error output + $fullcommand .= ' 2>&1'; // This is to get error output $output = array(); $return_var = 0; - $safemode = ini_get("safe_mode"); + $safemode = ini_get("safe_mode"); // Create a clean fullcommand dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode ? "on" : "off")); // Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL% @@ -95,7 +95,7 @@ class AntiVir if (is_null($output)) $output = array(); - //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; + //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; /* $outputfile=$conf->admin->dir_temp.'/dol_avscan_file.out.'.session_id(); @@ -181,7 +181,7 @@ class AntiVir $ret = $command.' '.$param; //$ret=$command.' '.$param.' 2>&1'; - //print "xx".$ret."xx";exit; + //print "xx".$ret."xx";exit; return $ret; } diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 80c6ff1b7a6..91157f52ba0 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -29,9 +29,9 @@ class Canvas { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -45,16 +45,16 @@ class Canvas public $actiontype; - public $dirmodule; // Module directory - public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - public $canvas; // Name of canvas (ex: company, individual, product, service, ...) - public $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - public $template_dir; // Initialized by getCanvas with templates directory - public $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance - /** + /** * Constructor * * @param DoliDB $db Database handler @@ -75,11 +75,11 @@ class Canvas */ private function _cleanaction($action) { - $newaction = $action; - if ($newaction == 'add') $newaction = 'create'; - if ($newaction == 'update') $newaction = 'edit'; - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; - return $newaction; + $newaction = $action; + if ($newaction == 'add') $newaction = 'create'; + if ($newaction == 'update') $newaction = 'edit'; + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; + return $newaction; } @@ -96,45 +96,45 @@ class Canvas global $conf, $langs; // Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas - $this->targetmodule = $module; - $this->canvas = $canvas; - $this->card = $card; - $this->dirmodule = $module; - // Correct values if canvas is into an external module + $this->targetmodule = $module; + $this->canvas = $canvas; + $this->card = $card; + $this->dirmodule = $module; + // Correct values if canvas is into an external module if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) { - $this->canvas = $regs[1]; - $this->dirmodule = $regs[2]; + $this->canvas = $regs[1]; + $this->dirmodule = $regs[2]; } // For compatibility - if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } + if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; } - // Control file + // Control file $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { - // Include actions class (controller) - $this->control_file = $controlclassfile; - require_once $controlclassfile; + // Include actions class (controller) + $this->control_file = $controlclassfile; + require_once $controlclassfile; - // Instantiate actions class (controller) - $controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas); - $this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card); + // Instantiate actions class (controller) + $controlclassname = 'Actions'.ucfirst($this->card).ucfirst($this->canvas); + $this->control = new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card); } // Template dir $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); - if (!is_dir($this->template_dir)) - { - $this->template_dir = ''; - } + if (!is_dir($this->template_dir)) + { + $this->template_dir = ''; + } - //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; - //print ' => template_dir='.$this->template_dir.'
'; + //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
'; + //print ' => template_dir='.$this->template_dir.'
'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Shared method for canvas to assign values for templates * * @param string $action Action string @@ -144,25 +144,25 @@ class Canvas */ public function assign_values(&$action = 'view', $id = 0, $ref = '') { - // phpcs:enable + // phpcs:enable if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref); } - /** - * Return the template to display canvas (if it exists) + /** + * Return the template to display canvas (if it exists) * * @param string $action Action code - * @return int 0=Canvas template file does not exist, 1=Canvas template file exists - */ - public function displayCanvasExists($action) - { - if (empty($this->template_dir)) return 0; + * @return int 0=Canvas template file does not exist, 1=Canvas template file exists + */ + public function displayCanvasExists($action) + { + if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; - else return 0; - } + if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; + else return 0; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display a canvas page. This will include the template for output. * Variables used by templates may have been defined or loaded before into the assign_values function. @@ -172,7 +172,7 @@ class Canvas */ public function display_canvas($action) { - // phpcs:enable + // phpcs:enable global $db, $conf, $langs, $user, $canvas; global $form, $formfile; @@ -191,12 +191,12 @@ class Canvas */ public function hasActions() { - return (is_object($this->control)); + return (is_object($this->control)); } /** * Shared method for canvas to execute actions. - * @deprecated Use the doActions of hooks instead of this. + * @deprecated Use the doActions of hooks instead of this. * This function is called if you add a doActions class inside your canvas. Try to not * do that and add action code into a hook instead. * diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index cf671eb57ca..d19e6d00a36 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -33,9 +33,9 @@ class Ccountry // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -50,7 +50,7 @@ class Ccountry // extends CommonObject public $element = 'ccountry'; //!< Id that identify managed objects public $table_element = 'c_country'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -59,9 +59,9 @@ class Ccountry // extends CommonObject public $code_iso; /** - * @var string Countries label - */ - public $label; + * @var string Countries label + */ + public $label; public $active; @@ -70,27 +70,27 @@ class Ccountry // extends CommonObject ); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -102,14 +102,14 @@ class Ccountry // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_country("; $sql .= "rowid,"; $sql .= "code,"; $sql .= "code_iso,"; $sql .= "label,"; $sql .= "active"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->code_iso) ? 'NULL' : "'".$this->db->escape($this->code_iso)."'").","; @@ -120,88 +120,88 @@ class Ccountry // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @param string $code_iso Code ISO - * @return int >0 if OK, 0 if not found, <0 if KO - */ - public function fetch($id, $code = '', $code_iso = '') - { - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $code_iso Code ISO + * @return int >0 if OK, 0 if not found, <0 if KO + */ + public function fetch($id, $code = '', $code_iso = '') + { + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.code_iso,"; $sql .= " t.label,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t"; - if ($id) $sql .= " WHERE t.rowid = ".$id; - elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; - elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_country as t"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->code_iso = $obj->code_iso; $this->label = $obj->label; $this->active = $obj->active; - $this->db->free($resql); - return 1; - } else { - return 0; - } - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + $this->db->free($resql); + return 1; + } else { + return 0; + } + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -214,27 +214,27 @@ class Ccountry // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_country SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " code_iso=".(isset($this->code_iso) ? "'".$this->db->escape($this->code_iso)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -242,16 +242,16 @@ class Ccountry // extends CommonObject $this->db->commit(); return 1; } - } + } /** * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -264,15 +264,15 @@ class Ccountry // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -282,19 +282,19 @@ class Ccountry // extends CommonObject } } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $langs; - return $langs->trans($this->label); - } + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $langs; + return $langs->trans($this->label); + } } diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 39ae2eb63ef..d2c6221a598 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -44,27 +44,27 @@ class Comment extends CommonObject public $description; /** - * Date modification record (tms) - * - * @var integer - */ + * Date modification record (tms) + * + * @var integer + */ public $tms; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_author; /** - * @var int ID - */ + * @var int ID + */ public $fk_user_modif; /** diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 6015bbceece..7e8d2da34ce 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1288,7 +1288,7 @@ abstract class CommonDocGenerator if (!empty($fields)) { // Sort extrafields by rank - uasort($fields, function ($a, $b) { + uasort($fields, function($a, $b) { return ($a->rank > $b->rank) ? 1 : -1; }); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index c278eaeedb7..12759b9fbf2 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -297,7 +297,7 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiement'; $field = 'fk_facture'; $field2 = 'fk_paiement'; - $field3=', p.ref_ext'; + $field3 = ', p.ref_ext'; $sharedentity = 'facture'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { @@ -305,7 +305,7 @@ abstract class CommonInvoice extends CommonObject $table2 = 'paiementfourn'; $field = 'fk_facturefourn'; $field2 = 'fk_paiementfourn'; - $field3=''; + $field3 = ''; $sharedentity = 'facture_fourn'; } @@ -327,11 +327,11 @@ abstract class CommonInvoice extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tmp = array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); + $tmp = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); if (!empty($field3)) { $tmp['ref_ext'] = $obj->ref_ext; } - $retarray[]=$tmp; + $retarray[] = $tmp; $i++; } $this->db->free($resql); @@ -694,7 +694,7 @@ abstract class CommonInvoice extends CommonObject } else { $sql .= ' WHERE fk_facture = '.$this->id; } - $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments + $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments $sql .= ' AND traite = 0'; dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a5b6e0b84de..178ddbd05fe 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2256,12 +2256,12 @@ abstract class CommonObject return 1; } else { dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } else { dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); - $this->error='Status of the object is incompatible '.$this->statut; + $this->error = 'Status of the object is incompatible '.$this->statut; return -2; } } @@ -5361,8 +5361,8 @@ abstract class CommonObject $new_array_options[$key] = ''; } elseif ($value) { $object = new $InfoFieldList[0]($this->db); - if (is_numeric($value)) $res = $object->fetch($value); // Common case - else $res = $object->fetch('', $value); // For compatibility + if (is_numeric($value)) $res = $object->fetch($value); // Common case + else $res = $object->fetch('', $value); // For compatibility if ($res > 0) $new_array_options[$key] = $object->id; else { @@ -6821,7 +6821,7 @@ abstract class CommonObject switch ($mode) { case "view": - $value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later + $value = $this->array_options["options_".$key.$keysuffix]; // Value may be clean or formated later break; case "create": case "edit": @@ -8474,7 +8474,7 @@ abstract class CommonObject $this->db->begin(); - switch ($this->element){ + switch ($this->element) { case 'propal': $element = 'propale'; break; @@ -8482,10 +8482,10 @@ abstract class CommonObject $element = 'produit'; break; case 'order_supplier': - $element ='fournisseur/commande'; + $element = 'fournisseur/commande'; break; case 'invoice_supplier': - $element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); + $element = 'fournisseur/facture/'.get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier'); break; case 'shipping': $element = 'expedition/sending'; @@ -8495,8 +8495,8 @@ abstract class CommonObject } $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql.= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 8874175a138..e7c40d60bfd 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -89,7 +89,7 @@ abstract class CommonOrderLine extends CommonObjectLine * @deprecated * @see $subprice */ - public $price; + public $price; /** * Unit price before taxes diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index c3d6e7de299..3a8712ad67d 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -61,46 +61,46 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; */ abstract class CommonStickerGenerator { - public $code; // Code of format + public $code; // Code of format - /** - * @var array format Array with informations - */ - public $format; + /** + * @var array format Array with informations + */ + public $format; - // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore - // protected - // Nom du format de l'etiquette - protected $_Avery_Name = ''; - // Marge de gauche de l'etiquette - protected $_Margin_Left = 0; - // marge en haut de la page avant la premiere etiquette - protected $_Margin_Top = 0; - // Espace horizontal entre 2 bandes d'etiquettes - protected $_X_Space = 0; - // Espace vertical entre 2 bandes d'etiquettes - protected $_Y_Space = 0; - // NX Nombre d'etiquettes sur la largeur de la page - protected $_X_Number = 0; - // NY Nombre d'etiquettes sur la hauteur de la page - protected $_Y_Number = 0; - // Largeur de chaque etiquette - protected $_Width = 0; - // Hauteur de chaque etiquette - protected $_Height = 0; - // Hauteur des caracteres - protected $_Char_Size = 10; - // Hauteur par defaut d'une ligne - protected $_Line_Height = 10; - // Type of metric.. Will help to calculate good values - protected $_Metric = 'mm'; - // Type of metric for the doc.. - protected $_Metric_Doc = 'mm'; - protected $_COUNTX = 1; - protected $_COUNTY = 1; - protected $_First = 1; - public $Tformat; - // phpcs:enable + // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore + // protected + // Nom du format de l'etiquette + protected $_Avery_Name = ''; + // Marge de gauche de l'etiquette + protected $_Margin_Left = 0; + // marge en haut de la page avant la premiere etiquette + protected $_Margin_Top = 0; + // Espace horizontal entre 2 bandes d'etiquettes + protected $_X_Space = 0; + // Espace vertical entre 2 bandes d'etiquettes + protected $_Y_Space = 0; + // NX Nombre d'etiquettes sur la largeur de la page + protected $_X_Number = 0; + // NY Nombre d'etiquettes sur la hauteur de la page + protected $_Y_Number = 0; + // Largeur de chaque etiquette + protected $_Width = 0; + // Hauteur de chaque etiquette + protected $_Height = 0; + // Hauteur des caracteres + protected $_Char_Size = 10; + // Hauteur par defaut d'une ligne + protected $_Line_Height = 10; + // Type of metric.. Will help to calculate good values + protected $_Metric = 'mm'; + // Type of metric for the doc.. + protected $_Metric_Doc = 'mm'; + protected $_COUNTX = 1; + protected $_COUNTY = 1; + protected $_First = 1; + public $Tformat; + // phpcs:enable /** * Constructor * @@ -111,7 +111,7 @@ abstract class CommonStickerGenerator $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -122,7 +122,7 @@ abstract class CommonStickerGenerator * @return int 1=OK, 0=KO */ public abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); - // phpcs:enable + // phpcs:enable /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) @@ -134,7 +134,7 @@ abstract class CommonStickerGenerator */ public abstract function addSticker(&$pdf, $outputlangs, $param); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Methode qui permet de modifier la taille des caracteres * Cela modiera aussi l'espace entre chaque ligne @@ -145,7 +145,7 @@ abstract class CommonStickerGenerator */ public function Set_Char_Size(&$pdf, $pt) { - // phpcs:enable + // phpcs:enable if ($pt > 3) { $this->_Char_Size = $pt; $this->_Line_Height = $this->_Get_Height_Chars($pt); @@ -153,8 +153,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * protected Print dot line * @@ -167,9 +167,9 @@ abstract class CommonStickerGenerator * @param int $nbPointilles Nb pointilles * @return void */ - protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) - { - // phpcs:enable + protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) + { + // phpcs:enable $pdf->SetLineWidth($epaisseur); $length = abs($x1 - $x2); $hauteur = abs($y1 - $y2); @@ -181,23 +181,23 @@ abstract class CommonStickerGenerator for ($i = $x1; $i <= $x2; $i += $Pointilles + $Pointilles) { for ($j = $i; $j <= ($i + $Pointilles); $j++) { if ($j <= ($x2 - 1)) { - $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point - $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point + $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point + $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point } } } for ($i = $y1; $i <= $y2; $i += $Pointilles + $Pointilles) { for ($j = $i; $j <= ($i + $Pointilles); $j++) { if ($j <= ($y2 - 1)) { - $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point - $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point + $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point + $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point } } } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Function realisant une croix aux 4 coins des cartes * @@ -212,7 +212,7 @@ abstract class CommonStickerGenerator */ protected function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) { - // phpcs:enable + // phpcs:enable $pdf->SetDrawColor(192, 192, 192); $pdf->SetLineWidth($epaisseur); @@ -255,8 +255,8 @@ abstract class CommonStickerGenerator return $value; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Give the height for a char size given. * @@ -265,7 +265,7 @@ abstract class CommonStickerGenerator */ protected function _Get_Height_Chars($pt) { - // phpcs:enable + // phpcs:enable // Array for link between height of characters and space between lines $_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10); if (in_array($pt, array_keys($_Table_Hauteur_Chars))) { @@ -275,8 +275,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Set format * @@ -286,7 +286,7 @@ abstract class CommonStickerGenerator */ protected function _Set_Format(&$pdf, $format) { - // phpcs:enable + // phpcs:enable $this->_Metric = $format['metric']; $this->_Avery_Name = $format['name']; $this->_Avery_Code = $format['code']; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d87174c5636..56e8f313129 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -32,61 +32,61 @@ */ class Conf { - /** \public */ - //! To store properties found in conf file - public $file; + /** \public */ + //! To store properties found in conf file + public $file; - /** - * @var Object Associative array with some properties ->type, ->db, ... - */ - public $db; + /** + * @var Object Associative array with some properties ->type, ->db, ... + */ + public $db; - //! To store properties found into database - public $global; - //! To store browser info - public $browser; + //! To store properties found into database + public $global; + //! To store browser info + public $browser; - //! To store if javascript/ajax is enabked - public $use_javascript_ajax; - //! To store if javascript/ajax is enabked - public $disable_compute; + //! To store if javascript/ajax is enabked + public $use_javascript_ajax; + //! To store if javascript/ajax is enabked + public $disable_compute; //! Used to store current currency (ISO code like 'USD', 'EUR', ...) public $currency; //! Used to store current css (from theme) public $theme; // Contains current theme ("eldy", "auguria", ...) public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) - //! Used to store current menu handler + //! Used to store current menu handler public $standard_menu; - // List of activated modules - public $modules = array(); - public $modules_parts = array( - 'css' => array(), - 'js' => array(), - 'tabs' => array(), - 'triggers' => array(), - 'login' => array(), - 'substitutions' => array(), - 'menus' => array(), - 'theme' => array(), - 'sms' => array(), - 'tpl' => array(), - 'barcode' => array(), - 'models' => array(), - 'societe' => array(), - 'hooks' => array(), - 'dir' => array(), - 'syslog' => array(), - ); + // List of activated modules + public $modules = array(); + public $modules_parts = array( + 'css' => array(), + 'js' => array(), + 'tabs' => array(), + 'triggers' => array(), + 'login' => array(), + 'substitutions' => array(), + 'menus' => array(), + 'theme' => array(), + 'sms' => array(), + 'tpl' => array(), + 'barcode' => array(), + 'models' => array(), + 'societe' => array(), + 'hooks' => array(), + 'dir' => array(), + 'syslog' => array(), + ); - public $logbuffer = array(); + public $logbuffer = array(); - /** - * @var LogHandlerInterface[] - */ - public $loghandlers = array(); + /** + * @var LogHandlerInterface[] + */ + public $loghandlers = array(); - //! To store properties of multi-company - public $multicompany; + //! To store properties of multi-company + public $multicompany; //! Used to store running instance for multi-company (default 1) public $entity = 1; //! Used to store list of entities to use for each element @@ -212,7 +212,7 @@ class Conf elseif ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array } - // If this is a module constant (must be at end) + // If this is a module constant (must be at end) elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) { $modulename = strtolower($reg[1]); @@ -227,20 +227,20 @@ class Conf $i++; } - $db->free($resql); - } + $db->free($resql); + } - // Include other local consts.php files and fetch their values to the corresponding database constants. - if (!empty($this->global->LOCAL_CONSTS_FILES)) { - $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); - foreach ($filesList as $file) { - $file = dol_sanitizeFileName($file); - dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars. - } - } + // Include other local consts.php files and fetch their values to the corresponding database constants. + if (!empty($this->global->LOCAL_CONSTS_FILES)) { + $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); + foreach ($filesList as $file) { + $file = dol_sanitizeFileName($file); + dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars. + } + } - //var_dump($this->modules); - //var_dump($this->modules_parts['theme']); + //var_dump($this->modules); + //var_dump($this->modules_parts['theme']); // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC. // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore. @@ -296,7 +296,7 @@ class Conf // Define default dir_output and dir_temp for directories of modules foreach ($this->modules as $module) { - //var_dump($module); + //var_dump($module); // For multicompany sharings $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); $this->$module->multidir_temp = array($this->entity => $rootfortemp."/".$module."/temp"); @@ -450,7 +450,7 @@ class Conf // Set some default values //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month - $this->global->MAIN_MAIL_USE_MULTI_PART = 1; + $this->global->MAIN_MAIL_USE_MULTI_PART = 1; // societe if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard"; @@ -459,9 +459,9 @@ class Conf if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; if (empty($this->global->TICKET_ADDON)) $this->global->TICKET_ADDON = 'mod_ticket_simple'; - // Security + // Security if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator - if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask + if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask // conf->use_javascript_ajax $this->use_javascript_ajax = 1; @@ -499,16 +499,16 @@ class Conf if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) - if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' + if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' - // By default, suppliers objects can be linked to all projects - if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; + // By default, suppliers objects can be linked to all projects + if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; - // By default we enable feature to bill time spent - if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1; + // By default we enable feature to bill time spent + if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1; - // MAIN_HTML_TITLE - if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; + // MAIN_HTML_TITLE + if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT = 25; @@ -520,7 +520,7 @@ class Conf // conf->theme et $this->css if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy"; - if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; + if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; $this->theme = $this->global->MAIN_THEME; $this->css = "/theme/".$this->theme."/style.css.php"; @@ -537,20 +537,20 @@ class Conf if (!empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1; - // Format for date (used by default when not found or not searched in lang) - $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) - $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags - $this->format_hour_short = "%H:%M"; - $this->format_hour_short_duration = "%H:%M"; - $this->format_date_text_short = "%d %b %Y"; - $this->format_date_text = "%d %B %Y"; - $this->format_date_hour_short = "%d/%m/%Y %H:%M"; - $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S"; - $this->format_date_hour_text_short = "%d %b %Y %H:%M"; - $this->format_date_hour_text = "%d %B %Y %H:%M"; + // Format for date (used by default when not found or not searched in lang) + $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) + $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags + $this->format_hour_short = "%H:%M"; + $this->format_hour_short_duration = "%H:%M"; + $this->format_date_text_short = "%d %b %Y"; + $this->format_date_text = "%d %B %Y"; + $this->format_date_hour_short = "%d/%m/%Y %H:%M"; + $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S"; + $this->format_date_hour_text_short = "%d %b %Y %H:%M"; + $this->format_date_hour_text = "%d %B %Y %H:%M"; - // Duration of workday - if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400; + // Duration of workday + if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400; // Limites decimales si non definie (peuvent etre egale a 0) if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT = 5; @@ -590,76 +590,76 @@ class Conf if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2'; // Timeouts - if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; - if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; + if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; + if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; // Set default variable to calculate VAT as if option tax_mode was 0 (standard) - if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; - if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; - if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment'; - if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment'; + if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; + if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; + if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment'; + if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment'; // Delay before warnings // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx if (isset($this->agenda)) { - $this->adherent->subscription = new stdClass(); - $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400; + $this->adherent->subscription = new stdClass(); + $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 86400; } if (isset($this->agenda)) { $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400; - } + } if (isset($this->projet)) { $this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 86400; - $this->projet->task = new StdClass(); - $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400; + $this->projet->task = new StdClass(); + $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400; } - if (isset($this->commande)) { - $this->commande->client = new stdClass(); - $this->commande->fournisseur = new stdClass(); - $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400; - $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400; + if (isset($this->commande)) { + $this->commande->client = new stdClass(); + $this->commande->fournisseur = new stdClass(); + $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 86400; + $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 86400; } if (isset($this->propal)) { - $this->propal->cloture = new stdClass(); - $this->propal->facturation = new stdClass(); - $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400; - $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400; + $this->propal->cloture = new stdClass(); + $this->propal->facturation = new stdClass(); + $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 86400; + $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 86400; } if (isset($this->facture)) { - $this->facture->client = new stdClass(); - $this->facture->fournisseur = new stdClass(); - $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400; - $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400; + $this->facture->client = new stdClass(); + $this->facture->fournisseur = new stdClass(); + $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 86400; + $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 86400; } if (isset($this->contrat)) { - $this->contrat->services = new stdClass(); - $this->contrat->services->inactifs = new stdClass(); - $this->contrat->services->expires = new stdClass(); - $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400; - $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400; + $this->contrat->services = new stdClass(); + $this->contrat->services->inactifs = new stdClass(); + $this->contrat->services->expires = new stdClass(); + $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400; + $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400; } if (isset($this->commande)) { - $this->bank->rappro = new stdClass(); - $this->bank->cheque = new stdClass(); - $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400; - $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400; + $this->bank->rappro = new stdClass(); + $this->bank->cheque = new stdClass(); + $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400; + $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400; } if (isset($this->expensereport)) { - $this->expensereport->approve = new stdClass(); - $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400; - $this->expensereport->payment = new stdClass(); - $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400; + $this->expensereport->approve = new stdClass(); + $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 86400; + $this->expensereport->payment = new stdClass(); + $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 86400; + } + if (isset($this->holiday)) { + $this->holiday->approve = new stdClass(); + $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400; } - if (isset($this->holiday)) { - $this->holiday->approve = new stdClass(); - $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400; - } if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) { - $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; + $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; } // For modules that want to disable top or left menu @@ -695,13 +695,13 @@ class Conf if (isset($this->categorie)) $this->category = $this->categorie; if (isset($this->project)) $this->project = $this->projet; - // Object $mc - if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) - { - if (is_object($mc)) $mc->setValues($this); - } + // Object $mc + if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) + { + if (is_object($mc)) $mc->setValues($this); + } - if (!empty($this->syslog->enabled)) { + if (!empty($this->syslog->enabled)) { // We init log handlers if (!empty($this->global->SYSLOG_HANDLERS)) { $handlers = json_decode($this->global->SYSLOG_HANDLERS); @@ -737,6 +737,6 @@ class Conf $this->loghandlers[$handler] = $loghandlerinstance; } } - } + } } } diff --git a/htdocs/core/class/cproductnature.class.php b/htdocs/core/class/cproductnature.class.php index 9e79093b12b..801a44682c9 100644 --- a/htdocs/core/class/cproductnature.class.php +++ b/htdocs/core/class/cproductnature.class.php @@ -29,9 +29,9 @@ class CProductNature // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -48,66 +48,66 @@ class CProductNature // extends CommonObject */ public $records = array(); - /** - * @var string element - */ + /** + * @var string element + */ public $element='cproductnbature'; - /** - * @var string table element - */ + /** + * @var string table element + */ public $table_element='c_product_nature'; - /** + /** * @var int ID */ public $id; - /** - * @var int code - */ + /** + * @var int code + */ public $code; - /** - * @var string label - */ + /** + * @var string label + */ public $label; - /** - * @var int active - */ + /** + * @var int active + */ public $active; - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; $sql .= "rowid,"; $sql .= "code,"; $sql .= "label,"; $sql .= "active"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : ((int) $this->id)) .","; $sql .= " ".(!isset($this->code) ? 'NULL' : ((int) $this->code)).","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape(trim($this->label))."'").","; @@ -117,185 +117,185 @@ class CProductNature // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - // Commit or rollback - if (!$resql) { + $resql = $this->db->query($sql); + // Commit or rollback + if (!$resql) { dol_syslog(get_class($this)."::create ".$this->db->lasterror(), LOG_ERR); - $this->error = "Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } else { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id of CUnit object to fetch (rowid) - * @param string $code Code - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '') - { - global $langs; + /** + * Load object in memory from database + * + * @param int $id Id of CUnit object to fetch (rowid) + * @param string $code Code + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '') + { + global $langs; - $sql = "SELECT"; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.label,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql_where = array(); - if ($id) $sql_where[] = " t.rowid = ".$id; - if ($code>=0) $sql_where[] = " t.code = ". ((int) $code); - if (count($sql_where) > 0) { - $sql .= ' WHERE '.implode(' AND ', $sql_where); - } + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql_where = array(); + if ($id) $sql_where[] = " t.rowid = ".$id; + if ($code>=0) $sql_where[] = " t.code = ". ((int) $code); + if (count($sql_where) > 0) { + $sql .= ' WHERE '.implode(' AND ', $sql_where); + } - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->label = $obj->label; $this->active = $obj->active; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $sql = 'SELECT'; - $sql .= " t.rowid,"; - $sql .= " t.code,"; - $sql .= " t.label,"; - $sql .= " t.active"; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid' || $key == 't.active' || $key == 't.code') { - $sqlwhere[] = $key.'='.(int) $value; - } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 't.label') { - $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } + $sql = 'SELECT'; + $sql .= " t.rowid,"; + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.active"; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.code') { + $sqlwhere[] = $key.'='.(int) $value; + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 't.label') { + $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } - $resql = $this->db->query($sql); - if ($resql) { - $this->records = array(); - $num = $this->db->num_rows($resql); - if ($num > 0) { - while ($obj = $this->db->fetch_object($resql)) - { - $record = new self($this->db); + $resql = $this->db->query($sql); + if ($resql) { + $this->records = array(); + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) + { + $record = new self($this->db); - $record->id = $obj->rowid; - $record->code = $obj->code; - $record->label = $obj->label; - $this->records[$record->id] = $record; - } - } - $this->db->free($resql); + $record->id = $obj->rowid; + $record->code = $obj->code; + $record->label = $obj->label; + $this->records[$record->id] = $record; + } + } + $this->db->free($resql); - return $this->records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + return $this->records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return -1; - } - } + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql .= " code=".(isset($this->code) ? ((int) $this->code) : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape(trim($this->label))."'" : "null").","; $sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null"); - $sql .= " WHERE rowid=".(int) $this->id; + $sql .= " WHERE rowid=".(int) $this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - // Commit or rollback + $resql = $this->db->query($sql); + // Commit or rollback if (!$resql) { - dol_syslog(get_class($this)."::update Error ".$this->db->lasterror(), LOG_ERR); - $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::update Error ".$this->db->lasterror(), LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } else { $this->db->commit(); return 1; } - } + } /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -308,10 +308,10 @@ class CProductNature // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - // Commit or rollback + // Commit or rollback if (!$resql) { - dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); - $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::delete Error ".$this->db->lasterror(), LOG_ERR); + $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; } else { @@ -331,7 +331,7 @@ class CProductNature // extends CommonObject { if ($mode == 'label') { return dol_getIdFromCode($this->db, $code, $this->table_element, 'label', 'code'); - } elseif ($mode == 'code'){ + } elseif ($mode == 'code') { return dol_getIdFromCode($this->db, $code, $this->table_element, 'code', 'code'); } diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index 80c47591fbb..b778b13c512 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -27,9 +27,9 @@ class Cstate // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -44,7 +44,7 @@ class Cstate // extends CommonObject //var $element='cstate'; //!< Id that identify managed objects //var $table_element='cstate'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -68,27 +68,27 @@ class Cstate // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -99,13 +99,13 @@ class Cstate // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_departements("; $sql .= "rowid,"; $sql .= "code_departement,"; $sql .= "nom,"; $sql .= "active"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; $sql .= " ".(!isset($this->code_departement) ? 'NULL' : "'".$this->db->escape($this->code_departement)."'").","; $sql .= " ".(!isset($this->nom) ? 'NULL' : "'".$this->db->escape($this->nom)."'").","; @@ -115,84 +115,84 @@ class Cstate // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); - } + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '') - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '') + { + global $langs; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code_departement,"; $sql .= " t.nom,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t"; - if ($id) $sql .= " WHERE t.rowid = ".$id; - elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code_departement = $obj->code_departement; //deprecated $this->code = $obj->code_departement; $this->nom = $obj->nom; //deprecated $this->name = $obj->nom; $this->active = $obj->active; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -204,40 +204,40 @@ class Cstate // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_departements SET"; $sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").","; $sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").""; - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback - if ($error) { - foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); - } - $this->db->rollback(); - return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) { + foreach ($this->errors as $errmsg) { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } else { + $this->db->commit(); + return 1; + } + } /** * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -250,15 +250,15 @@ class Cstate // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 07d3563088e..fccdec72ab6 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -28,9 +28,9 @@ class Ctypent // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -45,7 +45,7 @@ class Ctypent // extends CommonObject //var $element='ctypent'; //!< Id that identify managed objects //var $table_element='ctypent'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -58,27 +58,27 @@ class Ctypent // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -94,7 +94,7 @@ class Ctypent // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_typent("; $sql .= "id,"; @@ -104,7 +104,7 @@ class Ctypent // extends CommonObject $sql .= "module"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; @@ -118,88 +118,88 @@ class Ctypent // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id object - * @param string $code Code - * @param string $label Label - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '', $label = '') - { - global $langs; - $sql = "SELECT"; + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $label Label + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '', $label = '') + { + global $langs; + $sql = "SELECT"; $sql .= " t.id,"; $sql .= " t.code,"; $sql .= " t.libelle as label,"; $sql .= " t.fk_country as country_id,"; $sql .= " t.active,"; $sql .= " t.module"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t"; - if ($id) $sql .= " WHERE t.id = ".$id; - elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; - elseif ($label) $sql .= " WHERE t.libelle = '".$this->db->escape($label)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t"; + if ($id) $sql .= " WHERE t.id = ".$id; + elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($label) $sql .= " WHERE t.libelle = '".$this->db->escape($label)."'"; - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->id; + $this->id = $obj->id; $this->code = $obj->code; $this->libelle = $obj->label; $this->country_id = $obj->country_id; $this->active = $obj->active; $this->module = $obj->module; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -212,27 +212,27 @@ class Ctypent // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_typent SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " libelle=".(isset($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null").","; $sql .= " module=".(isset($this->module) ? "'".$this->db->escape($this->module)."'" : "null").""; - $sql .= " WHERE id=".$this->id; + $sql .= " WHERE id=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -240,16 +240,16 @@ class Ctypent // extends CommonObject $this->db->commit(); return 1; } - } + } /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -262,21 +262,21 @@ class Ctypent // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback - if ($error) - { + // Commit or rollback + if ($error) + { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; - } else { - $this->db->commit(); - return 1; - } - } + } else { + $this->db->commit(); + return 1; + } + } } diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 410c3ae3f21..9d1e5c53de1 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -50,9 +50,9 @@ class Ctyperesource public $code; /** - * @var string Type resource label - */ - public $label; + * @var string Type resource label + */ + public $label; public $active; @@ -252,7 +252,7 @@ class Ctyperesource $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -482,9 +482,9 @@ class CtyperesourceLine public $code; /** - * @var string Type resource line label - */ - public $label; + * @var string Type resource line label + */ + public $label; public $active; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index ac7b07ea5a9..5e013b3d32f 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -28,9 +28,9 @@ class CUnits // extends CommonObject { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -46,7 +46,7 @@ class CUnits // extends CommonObject //var $element='ctypent'; //!< Id that identify managed objects //var $table_element='ctypent'; //!< Name of table without prefix where object is stored - /** + /** * @var int ID */ public $id; @@ -61,27 +61,27 @@ class CUnits // extends CommonObject - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Create object into database - * - * @param User $user User that create - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create($user, $notrigger = 0) - { - global $conf, $langs; + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create($user, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -97,7 +97,7 @@ class CUnits // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Insert request + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units("; $sql .= "rowid,"; $sql .= "code,"; @@ -105,7 +105,7 @@ class CUnits // extends CommonObject $sql .= "short_label,"; $sql .= "unit_type"; $sql .= "scale"; - $sql .= ") VALUES ("; + $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; @@ -117,45 +117,45 @@ class CUnits // extends CommonObject $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units"); - } + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units"); + } - // Commit or rollback - if ($error) + // Commit or rollback + if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; } else { $this->db->commit(); - return $this->id; + return $this->id; } - } + } - /** - * Load object in memory from database - * - * @param int $id Id of CUnit object to fetch (rowid) - * @param string $code Code - * @param string $short_label Short Label ('g', 'kg', ...) - * @param string $unit_type Unit type ('size', 'surface', 'volume', 'weight', ...) - * @return int <0 if KO, >0 if OK - */ - public function fetch($id, $code = '', $short_label = '', $unit_type = '') - { - global $langs; + /** + * Load object in memory from database + * + * @param int $id Id of CUnit object to fetch (rowid) + * @param string $code Code + * @param string $short_label Short Label ('g', 'kg', ...) + * @param string $unit_type Unit type ('size', 'surface', 'volume', 'weight', ...) + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $code = '', $short_label = '', $unit_type = '') + { + global $langs; - $sql = "SELECT"; + $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; $sql .= " t.label,"; @@ -164,24 +164,24 @@ class CUnits // extends CommonObject $sql .= " t.unit_type,"; $sql .= " t.scale,"; $sql .= " t.active"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; - $sql_where = array(); - if ($id) $sql_where[] = " t.rowid = ".$id; - if ($unit_type) $sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'"; - if ($code) $sql_where[] = " t.code = '".$this->db->escape($code)."'"; - if ($short_label) $sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'"; - if (count($sql_where) > 0) { - $sql .= ' WHERE '.implode(' AND ', $sql_where); - } + $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; + $sql_where = array(); + if ($id) $sql_where[] = " t.rowid = ".$id; + if ($unit_type) $sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'"; + if ($code) $sql_where[] = " t.code = '".$this->db->escape($code)."'"; + if ($short_label) $sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'"; + if (count($sql_where) > 0) { + $sql .= ' WHERE '.implode(' AND ', $sql_where); + } - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->code = $obj->code; $this->label = $obj->label; $this->short_label = $obj->short_label; @@ -189,110 +189,110 @@ class CUnits // extends CommonObject $this->unit_type = $obj->unit_type; $this->scale = $obj->scale; $this->active = $obj->active; - } - $this->db->free($resql); + } + $this->db->free($resql); - return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } else { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $sql = 'SELECT'; - $sql .= " t.rowid,"; - $sql .= " t.code,"; - $sql .= " t.label,"; - $sql .= " t.short_label,"; - $sql .= " t.unit_type,"; - $sql .= " t.scale,"; - $sql .= " t.active"; - $sql .= ' FROM '.MAIN_DB_PREFIX.'c_units as t'; - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { - $sqlwhere[] = $key.'='.(int) $value; - } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { - $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; - } else { - $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; - } + $sql = 'SELECT'; + $sql .= " t.rowid,"; + $sql .= " t.code,"; + $sql .= " t.label,"; + $sql .= " t.short_label,"; + $sql .= " t.unit_type,"; + $sql .= " t.scale,"; + $sql .= " t.active"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'c_units as t'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid' || $key == 't.active' || $key == 't.scale') { + $sqlwhere[] = $key.'='.(int) $value; + } elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 't.unit_type' || $key == 't.code' || $key == 't.short_label') { + $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= ' '.$this->db->plimit($limit, $offset); - } + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } - $resql = $this->db->query($sql); - if ($resql) { - $this->records = array(); - $num = $this->db->num_rows($resql); - if ($num > 0) { - while ($obj = $this->db->fetch_object($resql)) - { - $record = new self($this->db); + $resql = $this->db->query($sql); + if ($resql) { + $this->records = array(); + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) + { + $record = new self($this->db); - $record->id = $obj->rowid; - $record->code = $obj->code; - $record->label = $obj->label; - $record->short_label = $obj->short_label; - $record->unit_type = $obj->unit_type; - $record->scale = $obj->scale; - $record->active = $obj->active; - $this->records[$record->id] = $record; - } - } - $this->db->free($resql); + $record->id = $obj->rowid; + $record->code = $obj->code; + $record->label = $obj->label; + $record->short_label = $obj->short_label; + $record->unit_type = $obj->unit_type; + $record->scale = $obj->scale; + $record->active = $obj->active; + $this->records[$record->id] = $record; + } + } + $this->db->free($resql); - return $this->records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + return $this->records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - return -1; - } - } + return -1; + } + } - /** - * Update object into database - * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; $error = 0; // Clean parameters @@ -306,29 +306,29 @@ class CUnits // extends CommonObject // Check parameters // Put here code to add control on parameters values - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " short_label=".(isset($this->short_label) ? "'".$this->db->escape($this->short_label)."'" : "null").","; $sql .= " unit_type=".(isset($this->unit_type) ? "'".$this->db->escape($this->unit_type)."'" : "null").","; $sql .= " scale=".(isset($this->scale) ? "'".$this->db->escape($this->scale)."'" : "null").","; $sql .= " active=".(isset($this->active) ? $this->active : "null"); - $sql .= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -336,16 +336,16 @@ class CUnits // extends CommonObject $this->db->commit(); return 1; } - } + } /** - * Delete object in database - * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK - */ + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ public function delete($user, $notrigger = 0) { global $conf, $langs; @@ -358,15 +358,15 @@ class CUnits // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - // Commit or rollback + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -386,9 +386,9 @@ class CUnits // extends CommonObject public function getUnitFromCode($code, $mode = 'code') { - if ($mode == 'short_label'){ + if ($mode == 'short_label') { return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid'); - } elseif ($mode == 'code'){ + } elseif ($mode == 'code') { return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid'); } @@ -404,21 +404,21 @@ class CUnits // extends CommonObject */ public function unitConverter($value, $fk_unit, $fk_new_unit = 0) { - $value = doubleval(price2num($value)); + $value = doubleval(price2num($value)); $fk_unit = intval($fk_unit); // Calcul en unité de base $scaleUnitPow = $this->scaleOfUnitPow($fk_unit); // convert to standard unit - $value = $value * $scaleUnitPow; - if ($fk_new_unit !=0 ){ + $value = $value * $scaleUnitPow; + if ($fk_new_unit != 0) { // Calcul en unité de base $scaleUnitPow = $this->scaleOfUnitPow($fk_new_unit); if (!empty($scaleUnitPow)) { // convert to new unit - $value = $value / $scaleUnitPow; + $value = $value / $scaleUnitPow; } } return round($value, 2); diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 4cddc65d636..9f901ed3452 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -28,12 +28,12 @@ */ class DiscountAbsolute { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error; @@ -48,190 +48,190 @@ class DiscountAbsolute */ public $id; - /** + /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; - public $discount_type; // 0 => customer discount, 1 => supplier discount - public $amount_ht; // - public $amount_tva; // - public $amount_ttc; // - public $multicurrency_amount_ht; - public $multicurrency_amount_tva; - public $multicurrency_amount_ttc; - // Vat rate - public $tva_tx; - public $vat_src_code; + public $discount_type; // 0 => customer discount, 1 => supplier discount + public $amount_ht; // + public $amount_tva; // + public $amount_ttc; // + public $multicurrency_amount_ht; + public $multicurrency_amount_tva; + public $multicurrency_amount_ttc; + // Vat rate + public $tva_tx; + public $vat_src_code; - /** + /** * @var int User ID Id utilisateur qui accorde la remise */ public $fk_user; - /** + /** * @var string description */ public $description; - /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + /** + * Date creation record (datec) + * + * @var integer + */ + public $datec; - /** - * @var int ID invoice line when a discount is used into an invoice line (for absolute discounts) - */ - public $fk_facture_line; + /** + * @var int ID invoice line when a discount is used into an invoice line (for absolute discounts) + */ + public $fk_facture_line; - /** - * @var int ID invoice when a discount line is used into an invoice (for credit note) - */ - public $fk_facture; + /** + * @var int ID invoice when a discount line is used into an invoice (for credit note) + */ + public $fk_facture; - /** - * @var int ID credit note or deposit used to create the discount - */ - public $fk_facture_source; - public $ref_facture_source; // Ref credit note or deposit used to create the discount + /** + * @var int ID credit note or deposit used to create the discount + */ + public $fk_facture_source; + public $ref_facture_source; // Ref credit note or deposit used to create the discount public $type_facture_source; - public $fk_invoice_supplier_source; - public $ref_invoice_supplier_source; // Ref credit note or deposit used to create the discount - public $type_invoice_supplier_source; + public $fk_invoice_supplier_source; + public $ref_invoice_supplier_source; // Ref credit note or deposit used to create the discount + public $type_invoice_supplier_source; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Load object from database into memory - * - * @param int $rowid id discount to load - * @param int $fk_facture_source fk_facture_source - * @param int $fk_invoice_supplier_source fk_invoice_supplier_source - * @return int <0 if KO, =0 if not found, >0 if OK - */ - public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) - { - global $conf; + /** + * Load object from database into memory + * + * @param int $rowid id discount to load + * @param int $fk_facture_source fk_facture_source + * @param int $fk_invoice_supplier_source fk_invoice_supplier_source + * @return int <0 if KO, =0 if not found, >0 if OK + */ + public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) + { + global $conf; - // Check parameters - if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) - { - $this->error = 'ErrorBadParameters'; - return -1; - } + // Check parameters + if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) + { + $this->error = 'ErrorBadParameters'; + return -1; + } - $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,"; - $sql .= " sr.fk_user,"; - $sql .= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx, sr.vat_src_code,"; - $sql .= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; - $sql .= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; - $sql .= " sr.datec,"; - $sql .= " f.ref as ref_facture_source, f.type as type_facture_source,"; - $sql .= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; - $sql .= " WHERE sr.entity IN (".getEntity('invoice').")"; - if ($rowid) $sql .= " AND sr.rowid=".$rowid; - if ($fk_facture_source) $sql .= " AND sr.fk_facture_source=".$fk_facture_source; - if ($fk_invoice_supplier_source) $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; + $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,"; + $sql .= " sr.fk_user,"; + $sql .= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx, sr.vat_src_code,"; + $sql .= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; + $sql .= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; + $sql .= " sr.datec,"; + $sql .= " f.ref as ref_facture_source, f.type as type_facture_source,"; + $sql .= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; + $sql .= " WHERE sr.entity IN (".getEntity('invoice').")"; + if ($rowid) $sql .= " AND sr.rowid=".$rowid; + if ($fk_facture_source) $sql .= " AND sr.fk_facture_source=".$fk_facture_source; + if ($fk_invoice_supplier_source) $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->fk_soc = $obj->fk_soc; - $this->discount_type = $obj->discount_type; + $this->id = $obj->rowid; + $this->fk_soc = $obj->fk_soc; + $this->discount_type = $obj->discount_type; - $this->amount_ht = $obj->amount_ht; - $this->amount_tva = $obj->amount_tva; - $this->amount_ttc = $obj->amount_ttc; + $this->amount_ht = $obj->amount_ht; + $this->amount_tva = $obj->amount_tva; + $this->amount_ttc = $obj->amount_ttc; - $this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht; - $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; - $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; + $this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht; + $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; + $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; - $this->tva_tx = $obj->tva_tx; - $this->vat_src_code = $obj->vat_src_code; + $this->tva_tx = $obj->tva_tx; + $this->vat_src_code = $obj->vat_src_code; - $this->fk_user = $obj->fk_user; - $this->fk_facture_line = $obj->fk_facture_line; - $this->fk_facture = $obj->fk_facture; - $this->fk_facture_source = $obj->fk_facture_source; // Id credit note or deposit source - $this->ref_facture_source = $obj->ref_facture_source; // Ref credit note or deposit source - $this->type_facture_source = $obj->type_facture_source; // Type credit note or deposit source - $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line; - $this->fk_invoice_supplier = $obj->fk_invoice_supplier; - $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id credit note or deposit source - $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref credit note or deposit source - $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source; // Type credit note or deposit source - $this->description = $obj->description; - $this->datec = $this->db->jdate($obj->datec); + $this->fk_user = $obj->fk_user; + $this->fk_facture_line = $obj->fk_facture_line; + $this->fk_facture = $obj->fk_facture; + $this->fk_facture_source = $obj->fk_facture_source; // Id credit note or deposit source + $this->ref_facture_source = $obj->ref_facture_source; // Ref credit note or deposit source + $this->type_facture_source = $obj->type_facture_source; // Type credit note or deposit source + $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line; + $this->fk_invoice_supplier = $obj->fk_invoice_supplier; + $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id credit note or deposit source + $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref credit note or deposit source + $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source; // Type credit note or deposit source + $this->description = $obj->description; + $this->datec = $this->db->jdate($obj->datec); - $this->db->free($resql); - return 1; - } else { - $this->db->free($resql); - return 0; - } - } else { - $this->error = $this->db->error(); - return -1; - } - } + $this->db->free($resql); + return 1; + } else { + $this->db->free($resql); + return 0; + } + } else { + $this->error = $this->db->error(); + return -1; + } + } - /** - * Create a discount into database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - public function create($user) - { - global $conf, $langs; + /** + * Create a discount into database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf, $langs; - // Clean parameters - $this->amount_ht = price2num($this->amount_ht); - $this->amount_tva = price2num($this->amount_tva); - $this->amount_ttc = price2num($this->amount_ttc); + // Clean parameters + $this->amount_ht = price2num($this->amount_ht); + $this->amount_tva = price2num($this->amount_tva); + $this->amount_ttc = price2num($this->amount_ttc); - $this->tva_tx = price2num($this->tva_tx); + $this->tva_tx = price2num($this->tva_tx); - $this->multicurrency_amount_ht = price2num($this->multicurrency_amount_ht); - $this->multicurrency_amount_tva = price2num($this->multicurrency_amount_tva); - $this->multicurrency_amount_ttc = price2num($this->multicurrency_amount_ttc); + $this->multicurrency_amount_ht = price2num($this->multicurrency_amount_ht); + $this->multicurrency_amount_tva = price2num($this->multicurrency_amount_tva); + $this->multicurrency_amount_ttc = price2num($this->multicurrency_amount_ttc); - if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht = 0; - if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva = 0; - if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc = 0; + if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht = 0; + if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva = 0; + if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc = 0; - // Check parameters - if (empty($this->description)) - { - $this->error = 'BadValueForPropertyDescription'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -1; - } + // Check parameters + if (empty($this->description)) + { + $this->error = 'BadValueForPropertyDescription'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -1; + } - $userid = $user->id; + $userid = $user->id; if (!($userid > 0)) // For example when record is saved into an anonymous context with a not loaded object $user. { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -240,463 +240,463 @@ class DiscountAbsolute $userid = $tmpinvoice->fk_user_author; // We use the author of invoice } - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,"; - $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,"; - $sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,"; - $sql .= " fk_facture_source, fk_invoice_supplier_source"; - $sql .= ")"; - $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',"; - $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.", '".$this->db->escape($this->vat_src_code)."',"; - $sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", "; - $sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").","; - $sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null"); - $sql .= ")"; + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,"; + $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,"; + $sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,"; + $sql .= " fk_facture_source, fk_invoice_supplier_source"; + $sql .= ")"; + $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',"; + $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.", '".$this->db->escape($this->vat_src_code)."',"; + $sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", "; + $sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").","; + $sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null"); + $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); - return $this->id; - } else { - $this->error = $this->db->lasterror().' - sql='.$sql; - return -1; - } - } + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); + return $this->id; + } else { + $this->error = $this->db->lasterror().' - sql='.$sql; + return -1; + } + } - /** - * Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed - * - * @param User $user Object of user asking to delete - * @return int <0 if KO, >0 if OK - */ - public function delete($user) - { - global $conf, $langs; + /** + * Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed + * + * @param User $user Object of user asking to delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + global $conf, $langs; - // Check if we can remove the discount - if ($this->fk_facture_source) - { - $sql = "SELECT COUNT(rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount - $sql .= " OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND fk_facture_source = ".$this->fk_facture_source; - //$sql.=" AND rowid != ".$this->id; + // Check if we can remove the discount + if ($this->fk_facture_source) + { + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount + $sql .= " OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND fk_facture_source = ".$this->fk_facture_source; + //$sql.=" AND rowid != ".$this->id; - dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj->nb > 0) - { - $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; - return -2; - } - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj->nb > 0) + { + $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; + return -2; + } + } else { + dol_print_error($this->db); + return -1; + } + } - // Check if we can remove the discount - if ($this->fk_invoice_supplier_source) - { - $sql = "SELECT COUNT(rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; - $sql .= " WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount - $sql .= " OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; - //$sql.=" AND rowid != ".$this->id; + // Check if we can remove the discount + if ($this->fk_invoice_supplier_source) + { + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except"; + $sql .= " WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount + $sql .= " OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; + //$sql.=" AND rowid != ".$this->id; - dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($obj->nb > 0) - { - $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; - return -2; - } - } else { - dol_print_error($this->db); - return -1; - } - } + dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj->nb > 0) + { + $this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; + return -2; + } + } else { + dol_print_error($this->db); + return -1; + } + } - $this->db->begin(); + $this->db->begin(); - // Delete but only if not used - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; - if ($this->fk_facture_source) $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie - elseif ($this->fk_invoice_supplier_source) $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie - else $sql .= " WHERE rowid = ".$this->id; // Delete only line - $sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount - $sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit - $sql .= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount - $sql .= " AND fk_invoice_supplier IS NULL)"; // Not used as credit note and not used as deposit + // Delete but only if not used + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; + if ($this->fk_facture_source) $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie + elseif ($this->fk_invoice_supplier_source) $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie + else $sql .= " WHERE rowid = ".$this->id; // Delete only line + $sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount + $sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit + $sql .= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount + $sql .= " AND fk_invoice_supplier IS NULL)"; // Not used as credit note and not used as deposit - dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - // If source of discount was a credit note or deposit, we change source statut. - if ($this->fk_facture_source) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $sql .= " set paye=0, fk_statut=1"; - $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source; + dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + // If source of discount was a credit note or deposit, we change source statut. + if ($this->fk_facture_source) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $sql .= " set paye=0, fk_statut=1"; + $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source; - dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } elseif ($this->fk_invoice_supplier_source) { - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; - $sql .= " set paye=0, fk_statut=1"; - $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; + dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } elseif ($this->fk_invoice_supplier_source) { + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; + $sql .= " set paye=0, fk_statut=1"; + $sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_invoice_supplier_source; - dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - $this->db->commit(); - return 1; - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } else { - $this->db->commit(); - return 1; - } - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } + dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $this->db->commit(); + return 1; + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } else { + $this->db->commit(); + return 1; + } + } else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Link the discount to a particular invoice line or a particular invoice. - * When discount is a global discount used as an invoice line, we link using rowidline. - * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice - * - * @param int $rowidline Invoice line id (To use discount into invoice lines) - * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) - * @return int <0 if KO, >0 if OK - */ - public function link_to_invoice($rowidline, $rowidinvoice) - { - // phpcs:enable - // Check parameters - if (!$rowidline && !$rowidinvoice) - { - $this->error = 'ErrorBadParameters'; - return -1; - } - if ($rowidline && $rowidinvoice) - { - $this->error = 'ErrorBadParameters'; - return -2; - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Link the discount to a particular invoice line or a particular invoice. + * When discount is a global discount used as an invoice line, we link using rowidline. + * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice + * + * @param int $rowidline Invoice line id (To use discount into invoice lines) + * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) + * @return int <0 if KO, >0 if OK + */ + public function link_to_invoice($rowidline, $rowidinvoice) + { + // phpcs:enable + // Check parameters + if (!$rowidline && !$rowidinvoice) + { + $this->error = 'ErrorBadParameters'; + return -1; + } + if ($rowidline && $rowidinvoice) + { + $this->error = 'ErrorBadParameters'; + return -2; + } - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if (!empty($this->discount_type)) { - if ($rowidline) $sql .= " SET fk_invoice_supplier_line = ".$rowidline; - if ($rowidinvoice) $sql .= " SET fk_invoice_supplier = ".$rowidinvoice; - } else { - if ($rowidline) $sql .= " SET fk_facture_line = ".$rowidline; - if ($rowidinvoice) $sql .= " SET fk_facture = ".$rowidinvoice; - } - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; + if (!empty($this->discount_type)) { + if ($rowidline) $sql .= " SET fk_invoice_supplier_line = ".$rowidline; + if ($rowidinvoice) $sql .= " SET fk_invoice_supplier = ".$rowidinvoice; + } else { + if ($rowidline) $sql .= " SET fk_facture_line = ".$rowidline; + if ($rowidinvoice) $sql .= " SET fk_facture = ".$rowidinvoice; + } + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::link_to_invoice", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - if (!empty($this->discount_type)) { - $this->fk_invoice_supplier_line = $rowidline; - $this->fk_invoice_supplier = $rowidinvoice; - } else { - $this->fk_facture_line = $rowidline; - $this->fk_facture = $rowidinvoice; - } - return 1; - } else { - $this->error = $this->db->error(); - return -3; - } - } + dol_syslog(get_class($this)."::link_to_invoice", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if (!empty($this->discount_type)) { + $this->fk_invoice_supplier_line = $rowidline; + $this->fk_invoice_supplier = $rowidinvoice; + } else { + $this->fk_facture_line = $rowidline; + $this->fk_facture = $rowidinvoice; + } + return 1; + } else { + $this->error = $this->db->error(); + return -3; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Link the discount to a particular invoice line or a particular invoice. - * Do not call this if discount is linked to a reconcialiated invoice - * - * @return int <0 if KO, >0 if OK - */ - public function unlink_invoice() - { - // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if (!empty($this->discount_type)) { - $sql .= " SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; - } else { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Link the discount to a particular invoice line or a particular invoice. + * Do not call this if discount is linked to a reconcialiated invoice + * + * @return int <0 if KO, >0 if OK + */ + public function unlink_invoice() + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; + if (!empty($this->discount_type)) { + $sql .= " SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; + } else { $sql .= " SET fk_facture_line = NULL, fk_facture = NULL"; } - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::unlink_invoice", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - return 1; - } else { - $this->error = $this->db->error(); - return -3; - } - } + dol_syslog(get_class($this)."::unlink_invoice", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + return 1; + } else { + $this->error = $this->db->error(); + return -3; + } + } - /** - * Return amount (with tax) of discounts currently available for a company, user or other criteria - * - * @param Societe $company Object third party for filter - * @param User $user Filtre sur un user auteur des remises - * @param string $filter Filtre autre - * @param int $maxvalue Filter on max value for discount - * @param int $discount_type 0 => customer discount, 1 => supplier discount + /** + * Return amount (with tax) of discounts currently available for a company, user or other criteria + * + * @param Societe $company Object third party for filter + * @param User $user Filtre sur un user auteur des remises + * @param string $filter Filtre autre + * @param int $maxvalue Filter on max value for discount + * @param int $discount_type 0 => customer discount, 1 => supplier discount * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, amount otherwise - */ - public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) - { - global $conf; + * @return int <0 if KO, amount otherwise + */ + public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) + { + global $conf; - dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG); + dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG); - $sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; - $sql .= " WHERE rc.entity = ".$conf->entity; - $sql .= " AND rc.discount_type=".intval($discount_type); - if (!empty($discount_type)) { - $sql .= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; // Available from supplier - } else { - $sql .= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer - } - if (is_object($company)) $sql .= " AND rc.fk_soc = ".$company->id; - if (is_object($user)) $sql .= " AND rc.fk_user = ".$user->id; - if ($filter) $sql .= ' AND ('.$filter.')'; - if ($maxvalue) $sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue); + $sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + $sql .= " WHERE rc.entity = ".$conf->entity; + $sql .= " AND rc.discount_type=".intval($discount_type); + if (!empty($discount_type)) { + $sql .= " AND (rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_line IS NULL)"; // Available from supplier + } else { + $sql .= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer + } + if (is_object($company)) $sql .= " AND rc.fk_soc = ".$company->id; + if (is_object($user)) $sql .= " AND rc.fk_user = ".$user->id; + if ($filter) $sql .= ' AND ('.$filter.')'; + if ($maxvalue) $sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue); - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - //while ($obj) - //{ - //print 'zz'.$obj->amount; - //$obj = $this->db->fetch_object($resql); - //} + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + //while ($obj) + //{ + //print 'zz'.$obj->amount; + //$obj = $this->db->fetch_object($resql); + //} if ($multicurrency) { return $obj->amount_multicurrency; } - return $obj->amount; - } - return -1; - } - - - /** - * Return amount (with tax) of all deposits invoices used by invoice as a payment. - * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). - * - * @param CommonInvoice $invoice Object invoice (customer of supplier) - * @param int $multicurrency 1=Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - public function getSumDepositsUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql .= ' AND f.type = 3'; - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; - $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql .= ' AND f.type = 3'; - } else { - $this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency == 1) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - /** - * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment - * - * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency 1=Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and excess received amount otherwise - */ - public function getSumCreditNotesUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; - $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.')'; // Find discount coming from credit note or excess paid - } else { - $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency == 1) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - /** - * Return amount (with tax) of all converted amount for this credit note - * - * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) - { - dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); - - if ($invoice->element == 'facture' || $invoice->element == 'invoice') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; - $sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; - } elseif ($invoice->element == 'invoice_supplier') - { - $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; - $sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; - } else { - $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; - dol_print_error($this->error); - return -1; - } - - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - if ($multicurrency) return $obj->multicurrency_amount; - else return $obj->amount; - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - - /** - * Return clickable ref of object (with picto or not) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only - * @param string $option Where to link to ('invoice' or 'discount') - * @return string String with URL - */ - public function getNomUrl($withpicto, $option = 'invoice') - { - global $langs; - - $result = ''; - $link = ''; - $linkend = ''; - $label = ''; - $picto = ''; - $ref = ''; - - if ($option == 'invoice') { - $facid = !empty($this->discount_type) ? $this->fk_invoice_supplier_source : $this->fk_facture_source; - $link = !empty($this->discount_type) ? '/fourn/facture/card.php' : '/compta/facture/card.php'; - $label = $langs->trans("ShowSourceInvoice").': '.$this->ref_facture_source; - $link = ''; - $linkend = ''; - $ref = !empty($this->discount_type) ? $this->ref_invoice_supplier_source : $this->ref_facture_source; - $picto = 'bill'; - } - if ($option == 'discount') { - $label = $langs->trans("Discount"); - $link = ''; - $linkend = ''; - $ref = $langs->trans("Discount"); - $picto = 'generic'; - } - - - if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result .= ' '; - $result .= $link.$ref.$linkend; - return $result; - } + return $obj->amount; + } + return -1; + } /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void + * Return amount (with tax) of all deposits invoices used by invoice as a payment. + * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). + * + * @param CommonInvoice $invoice Object invoice (customer of supplier) + * @param int $multicurrency 1=Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + public function getSumDepositsUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; + $sql .= ' AND f.type = 3'; + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; + $sql .= ' AND f.type = 3'; + } else { + $this->error = get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency == 1) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + /** + * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment + * + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency 1=Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and excess received amount otherwise + */ + public function getSumCreditNotesUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; + $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; + $sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.')'; // Find discount coming from credit note or excess paid + } else { + $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency == 1) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + /** + * Return amount (with tax) of all converted amount for this credit note + * + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) + { + dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; + } elseif ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; + } else { + $this->error = get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) return $obj->multicurrency_amount; + else return $obj->amount; + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + /** + * Return clickable ref of object (with picto or not) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only + * @param string $option Where to link to ('invoice' or 'discount') + * @return string String with URL + */ + public function getNomUrl($withpicto, $option = 'invoice') + { + global $langs; + + $result = ''; + $link = ''; + $linkend = ''; + $label = ''; + $picto = ''; + $ref = ''; + + if ($option == 'invoice') { + $facid = !empty($this->discount_type) ? $this->fk_invoice_supplier_source : $this->fk_facture_source; + $link = !empty($this->discount_type) ? '/fourn/facture/card.php' : '/compta/facture/card.php'; + $label = $langs->trans("ShowSourceInvoice").': '.$this->ref_facture_source; + $link = ''; + $linkend = ''; + $ref = !empty($this->discount_type) ? $this->ref_invoice_supplier_source : $this->ref_facture_source; + $picto = 'bill'; + } + if ($option == 'discount') { + $label = $langs->trans("Discount"); + $link = ''; + $linkend = ''; + $ref = $langs->trans("Discount"); + $picto = 'generic'; + } + + + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + $result .= $link.$ref.$linkend; + return $result; + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void */ public function initAsSpecimen() { diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 55474850b8e..a47ebbacd9f 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -28,132 +28,132 @@ */ class DolEditor { - public $tool; // Store the selected tool + public $tool; // Store the selected tool - // If using fckeditor - public $editor; + // If using fckeditor + public $editor; - // If not using fckeditor - public $content; - public $htmlname; - public $toolbarname; - public $toolbarstartexpanded; - public $rows; - public $cols; - public $height; - public $width; - public $readonly; + // If not using fckeditor + public $content; + public $htmlname; + public $toolbarname; + public $toolbarstartexpanded; + public $rows; + public $cols; + public $height; + public $width; + public $readonly; - /** - * Create an object to build an HTML area to edit a large string content - * - * @param string $htmlname HTML name of WYSIWIG field - * @param string $content Content of WYSIWIG field - * @param int $width Width in pixel of edit area (auto by default) - * @param int $height Height in pixel of edit area (200px by default) - * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). - * @param string $toolbarlocation Where bar is stored : - * 'In' each window has its own toolbar - * 'Out:name' share toolbar into the div called 'name' - * @param boolean $toolbarstartexpanded Bar is visible or not at start + /** + * Create an object to build an HTML area to edit a large string content + * + * @param string $htmlname HTML name of WYSIWIG field + * @param string $content Content of WYSIWIG field + * @param int $width Width in pixel of edit area (auto by default) + * @param int $height Height in pixel of edit area (200px by default) + * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). + * @param string $toolbarlocation Where bar is stored : + * 'In' each window has its own toolbar + * 'Out:name' share toolbar into the div called 'name' + * @param boolean $toolbarstartexpanded Bar is visible or not at start * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". - * @param int $rows Size of rows for textarea tool + * @param int $rows Size of rows for textarea tool * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') * @param int $readonly 0=Read/Edit, 1=Read only */ - public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) - { - global $conf, $langs; + public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) + { + global $conf, $langs; - dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); + dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); - if (!$rows) $rows = round($height / 20); - if (!$cols) $cols = ($width ?round($width / 6) : 80); + if (!$rows) $rows = round($height / 20); + if (!$cols) $cols = ($width ?round($width / 6) : 80); $shorttoolbarname = preg_replace('/_encoded$/', '', $toolbarname); - // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') - $defaulteditor = 'ckeditor'; - $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; - $this->uselocalbrowser = $uselocalbrowser; - $this->readonly = $readonly; + // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') + $defaulteditor = 'ckeditor'; + $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; + $this->uselocalbrowser = $uselocalbrowser; + $this->readonly = $readonly; - // Check if extended editor is ok. If not we force textarea - if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; + // Check if extended editor is ok. If not we force textarea + if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; if ($okforextendededitor === 'ace') $this->tool = 'ace'; - //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile + //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile - // Define some properties - if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) - { - if ($this->tool == 'ckeditor' && ! dol_textishtml($content)) { // We force content to be into HTML if we are using an advanced editor if content is not HTML. - $this->content = dol_nl2br($content); - } - else { - $this->content = $content; - } - $this->htmlname = $htmlname; - $this->toolbarname = $shorttoolbarname; - $this->toolbarstartexpanded = $toolbarstartexpanded; - $this->rows = max(ROWS_3, $rows); - $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max - $this->height = $height; - $this->width = $width; - } - } + // Define some properties + if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) + { + if ($this->tool == 'ckeditor' && ! dol_textishtml($content)) { // We force content to be into HTML if we are using an advanced editor if content is not HTML. + $this->content = dol_nl2br($content); + } + else { + $this->content = $content; + } + $this->htmlname = $htmlname; + $this->toolbarname = $shorttoolbarname; + $this->toolbarstartexpanded = $toolbarstartexpanded; + $this->rows = max(ROWS_3, $rows); + $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max + $this->height = $height; + $this->width = $width; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Output edit area inside the HTML stream. - * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) - * - * @param int $noprint 1=Return HTML string instead of printing it to output - * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });". Used by CKEditor only. - * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only. - * @param string $titlecontent Show title content before editor area. Used by ACE editor only. - * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) - * @return void|string - */ - public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') - { - // phpcs:enable - global $conf, $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Output edit area inside the HTML stream. + * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) + * + * @param int $noprint 1=Return HTML string instead of printing it to output + * @param string $morejs Add more js. For example: ".on( \'saveSnapshot\', function(e) { alert(\'ee\'); });". Used by CKEditor only. + * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. Used by CKEditor only. + * @param string $titlecontent Show title content before editor area. Used by ACE editor only. + * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) + * @return void|string + */ + public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') + { + // phpcs:enable + global $conf, $langs; - $fullpage = false; - if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) - { - $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all - } + $fullpage = false; + if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) + { + $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all + } - $found = 0; + $found = 0; $out = ''; - if (in_array($this->tool, array('textarea', 'ckeditor'))) - { - $found = 1; - //$out.= ''; + if (in_array($this->tool, array('textarea', 'ckeditor'))) + { + $found = 1; + //$out.= ''; - if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) - { - if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); + if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) + { + if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); - if (!empty($conf->global->FCKEDITOR_SKIN)) { + if (!empty($conf->global->FCKEDITOR_SKIN)) { $skin = $conf->global->FCKEDITOR_SKIN; } else { $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa } - $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; + $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out .= ''."\n"; - $out .= ''."\n"; - } - } + } + $out .= ' })'.$morejs; + $out .= '});'."\n"; + $out .= ''."\n"; + } + } - // Output editor ACE - // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. - if (preg_match('/^ace/', $this->tool)) - { - $found = 1; + // Output editor ACE + // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. + if (preg_match('/^ace/', $this->tool)) + { + $found = 1; $format = $option; - $out .= "\n".''."\n"; + $out .= "\n".''."\n"; if ($titlecontent) { - $out .= '
'.$titlecontent; - $out .= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; - $out .= '
'; - $out .= ''."\n"; + $out .= ''."\n"; } - $out .= '
content);
-        	$out .= '
'; - $out .= ''; + $out .= '
content);
+			$out .= '
'; + $out .= ''; - $out .= ''."\n"; - } + $out .= ''."\n"; + } - if (empty($found)) - { - $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; - } + if (empty($found)) + { + $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; + } - if ($noprint) return $out; - else print $out; - } + if ($noprint) return $out; + else print $out; + } } diff --git a/htdocs/core/class/dolexception.class.php b/htdocs/core/class/dolexception.class.php index 2c43a43127c..e083a47d5f7 100644 --- a/htdocs/core/class/dolexception.class.php +++ b/htdocs/core/class/dolexception.class.php @@ -27,10 +27,10 @@ */ class DolException extends Exception { - /** - * Constructor - */ - public function __construct() - { - } + /** + * Constructor + */ + public function __construct() + { + } } diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 2b148a96e8a..2619d09602b 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -33,7 +33,7 @@ */ class DolGeoIP { - public $gi; + public $gi; /** * Constructor @@ -50,18 +50,18 @@ class DolGeoIP if ($type == 'country') { - // geoip may have been already included with PEAR + // geoip may have been already included with PEAR if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { - require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; - } + { + require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; + } } elseif ($type == 'city') { - // geoip may have been already included with PEAR + // geoip may have been already included with PEAR if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) - { - require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; - } + { + require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; + } } else { print 'ErrorBadParameterInConstructor'; return 0; } // Here, function exists (embedded into PHP or exists because we made include) @@ -93,9 +93,9 @@ class DolGeoIP { $this->gi = geoip_open($datfile, GEOIP_STANDARD); } else { - $this->gi = 'NOGI'; // We are using embedded php geoip functions - //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); - //print geoip_database_info(); + $this->gi = 'NOGI'; // We are using embedded php geoip functions + //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); + //print geoip_database_info(); } } @@ -118,8 +118,8 @@ class DolGeoIP } if ($this->gi == 'NOGI') { - // geoip_country_code_by_addr does not exists - return strtolower(geoip_country_code_by_name($ip)); + // geoip_country_code_by_addr does not exists + return strtolower(geoip_country_code_by_name($ip)); } else { if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) { @@ -133,8 +133,8 @@ class DolGeoIP return ''; } } else { - if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); - return strtolower(geoip_country_code_by_addr($this->gi, $ip)); + if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); + return strtolower(geoip_country_code_by_addr($this->gi, $ip)); } } else { if ($geoipversion == '2') @@ -186,37 +186,37 @@ class DolGeoIP } } - /** - * Return verion of data file - * - * @return string Version of datafile - */ - public function getVersion() - { - global $conf; + /** + * Return verion of data file + * + * @return string Version of datafile + */ + public function getVersion() + { + global $conf; - $geoipversion = '2'; // 'php', or '2' - if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; + $geoipversion = '2'; // 'php', or '2' + if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION; - if ($geoipversion == 'php') - { - if ($this->gi == 'NOGI') return geoip_database_info(); - else return 'geoip_database_info() function not available'; - } + if ($geoipversion == 'php') + { + if ($this->gi == 'NOGI') return geoip_database_info(); + else return 'geoip_database_info() function not available'; + } - return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')'; - } + return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')'; + } - /** - * Close geoip object - * - * @return void - */ - public function close() - { - if (function_exists('geoip_close')) { - // With some geoip with PEAR, geoip_close function may not exists - geoip_close($this->gi); - } - } + /** + * Close geoip object + * + * @return void + */ + public function close() + { + if (function_exists('geoip_close')) { + // With some geoip with PEAR, geoip_close function may not exists + geoip_close($this->gi); + } + } } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index dee727cb596..0c6d15784f2 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -120,7 +120,7 @@ class DolGraph } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * @@ -129,12 +129,12 @@ class DolGraph */ public function SetHorizTickIncrement($xi) { - // phpcs:enable + // phpcs:enable $this->horizTickIncrement = $xi; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * @@ -143,12 +143,12 @@ class DolGraph */ public function SetNumXTicks($xt) { - // phpcs:enable + // phpcs:enable $this->SetNumXTicks = $xt; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set label interval to reduce number of labels * @@ -157,12 +157,12 @@ class DolGraph */ public function SetLabelInterval($x) { - // phpcs:enable + // phpcs:enable $this->labelInterval = $x; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide X grid * @@ -171,12 +171,12 @@ class DolGraph */ public function SetHideXGrid($bool) { - // phpcs:enable + // phpcs:enable $this->hideXGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide Y grid * @@ -185,12 +185,12 @@ class DolGraph */ public function SetHideYGrid($bool) { - // phpcs:enable + // phpcs:enable $this->hideYGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set y label * @@ -199,11 +199,11 @@ class DolGraph */ public function SetYLabel($label) { - // phpcs:enable + // phpcs:enable $this->YLabel = $label; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set width * @@ -212,11 +212,11 @@ class DolGraph */ public function SetWidth($w) { - // phpcs:enable + // phpcs:enable $this->width = $w; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set title * @@ -225,11 +225,11 @@ class DolGraph */ public function SetTitle($title) { - // phpcs:enable + // phpcs:enable $this->title = $title; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * @@ -239,11 +239,11 @@ class DolGraph */ public function SetData($data) { - // phpcs:enable + // phpcs:enable $this->data = $data; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * @@ -252,11 +252,11 @@ class DolGraph */ public function SetDataColor($datacolor) { - // phpcs:enable + // phpcs:enable $this->datacolor = $datacolor; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set type * @@ -266,11 +266,11 @@ class DolGraph */ public function SetType($type) { - // phpcs:enable + // phpcs:enable $this->type = $type; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set legend * @@ -279,11 +279,11 @@ class DolGraph */ public function SetLegend($legend) { - // phpcs:enable + // phpcs:enable $this->Legend = $legend; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min width * @@ -292,120 +292,120 @@ class DolGraph */ public function SetLegendWidthMin($legendwidthmin) { - // phpcs:enable + // phpcs:enable $this->LegendWidthMin = $legendwidthmin; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set max value * * @param int $max Max value * @return void */ - public function SetMaxValue($max) + public function SetMaxValue($max) { - // phpcs:enable + // phpcs:enable $this->MaxValue = $max; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value * * @return int Max value */ - public function GetMaxValue() + public function GetMaxValue() { - // phpcs:enable + // phpcs:enable return $this->MaxValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min value * * @param int $min Min value * @return void */ - public function SetMinValue($min) + public function SetMinValue($min) { - // phpcs:enable + // phpcs:enable $this->MinValue = $min; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get min value * * @return int Max value */ - public function GetMinValue() + public function GetMinValue() { - // phpcs:enable + // phpcs:enable return $this->MinValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set height * * @param int $h Height * @return void */ - public function SetHeight($h) + public function SetHeight($h) { - // phpcs:enable + // phpcs:enable $this->height = $h; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - public function SetShading($s) + public function SetShading($s) { - // phpcs:enable + // phpcs:enable $this->SetShading = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - public function SetCssPrefix($s) + public function SetCssPrefix($s) { - // phpcs:enable + // phpcs:enable $this->cssprefix = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bg color * * @return void */ - public function ResetBgColor() + public function ResetBgColor() { - // phpcs:enable + // phpcs:enable unset($this->bgcolor); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bgcolorgrid * * @return void */ - public function ResetBgColorGrid() + public function ResetBgColorGrid() { - // phpcs:enable + // phpcs:enable unset($this->bgcolorgrid); } @@ -414,7 +414,7 @@ class DolGraph * * @return string Error */ - public function isGraphKo() + public function isGraphKo() { return $this->error; } @@ -425,7 +425,7 @@ class DolGraph * @param int $showlegend 1=Show legend (default), 0=Hide legend, 2=Show legend on right * @return void */ - public function setShowLegend($showlegend) + public function setShowLegend($showlegend) { $this->showlegend = $showlegend; } @@ -436,7 +436,7 @@ class DolGraph * @param int $showpointvalue 1=Show value for each point, as tooltip or inline (default), 0=Hide value * @return void */ - public function setShowPointValue($showpointvalue) + public function setShowPointValue($showpointvalue) { $this->showpointvalue = $showpointvalue; } @@ -447,23 +447,23 @@ class DolGraph * @param int $showpercent 1=Show percent for each point, as tooltip or inline, 0=Hide percent (default) * @return void */ - public function setShowPercent($showpercent) + public function setShowPercent($showpercent) { $this->showpercent = $showpercent; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of complete image * * @param array $bg_color array(R,G,B) ou 'onglet' ou 'default' * @return void */ - public function SetBgColor($bg_color = array(255, 255, 255)) + public function SetBgColor($bg_color = array(255, 255, 255)) { - // phpcs:enable + // phpcs:enable global $theme_bgcolor, $theme_bgcoloronglet; if (!is_array($bg_color)) @@ -480,16 +480,16 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of grid * * @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default' * @return void */ - public function SetBgColorGrid($bg_colorgrid = array(255, 255, 255)) + public function SetBgColorGrid($bg_colorgrid = array(255, 255, 255)) { - // phpcs:enable + // phpcs:enable global $theme_bgcolor, $theme_bgcoloronglet; if (!is_array($bg_colorgrid)) @@ -506,27 +506,27 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset data color * * @return void */ - public function ResetDataColor() - { - // phpcs:enable - unset($this->datacolor); - } + public function ResetDataColor() + { + // phpcs:enable + unset($this->datacolor); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Get max value * * @return int Max value */ - public function GetMaxValueInData() + public function GetMaxValueInData() { - // phpcs:enable + // phpcs:enable if (!is_array($this->data)) return 0; $k = 0; @@ -547,15 +547,15 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return int Min value of all data */ - public function GetMinValueInData() + public function GetMinValueInData() { - // phpcs:enable + // phpcs:enable if (!is_array($this->data)) return 0; $k = 0; @@ -576,15 +576,15 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return max value of all data * * @return int Max value of all data */ - public function GetCeilMaxValue() + public function GetCeilMaxValue() { - // phpcs:enable + // phpcs:enable $max = $this->GetMaxValueInData(); if ($max != 0) $max++; $size = dol_strlen(abs(ceil($max))); @@ -601,15 +601,15 @@ class DolGraph return $res; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return double Max value of all data */ - public function GetFloorMinValue() + public function GetFloorMinValue() { - // phpcs:enable + // phpcs:enable $min = $this->GetMinValueInData(); if ($min == '') $min = 0; if ($min != 0) $min--; @@ -633,7 +633,7 @@ class DolGraph * @param string $fileurl Url path to show image if saved onto disk * @return integer|null */ - public function draw($file, $fileurl = '') + public function draw($file, $fileurl = '') { if (empty($file)) { @@ -656,7 +656,7 @@ class DolGraph call_user_func_array(array($this, $call), array($file, $fileurl)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build a graph using JFlot library. Input when calling this method should be: * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); @@ -675,7 +675,7 @@ class DolGraph */ private function draw_jflot($file, $fileurl) { - // phpcs:enable + // phpcs:enable global $conf, $langs; dol_syslog(get_class($this)."::draw_jflot this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue); @@ -732,9 +732,9 @@ class DolGraph if (!empty($this->title)) $this->stringtoshow .= '
'.$this->title.'
'; if (!empty($this->shownographyet)) { - $this->stringtoshow .= '
'; - $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'...
'; - return; + $this->stringtoshow .= '
'; + $this->stringtoshow .= '
'.$langs->trans("NotEnoughDataYet").'...
'; + return; } // Start the div that will contains all the graph @@ -825,7 +825,7 @@ class DolGraph // Other cases, graph of type 'bars', 'lines' else { // Add code to support tooltips - // TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes + // TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes $this->stringtoshow .= ' function showTooltip_'.$tag.'(x, y, contents) { $(\'
\' + contents + \'
\').css({ @@ -882,13 +882,13 @@ class DolGraph $color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); $this->stringtoshow .= '{ '; if (! isset($this->type[$i]) || $this->type[$i] == 'bars') { - if ($nblot == 3) { - if ($i == $firstlot) $align = 'right'; - elseif ($i == $firstlot + 1) $align = 'center'; - else $align = 'left'; - $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; - } else $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; - } + if ($nblot == 3) { + if ($i == $firstlot) $align = 'right'; + elseif ($i == $firstlot + 1) $align = 'center'; + else $align = 'left'; + $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "'.$align.'", barWidth: 0.45 }, '; + } else $this->stringtoshow.='bars: { lineWidth: 1, show: true, align: "'.($i==$firstlot?'center':'left').'", barWidth: 0.5 }, '; + } if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) $this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: '.($this->type[$i] == 'linesnopoint' ? 'false' : 'true').' }, '; $this->stringtoshow .= 'color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }'; $i++; @@ -1280,7 +1280,7 @@ class DolGraph * * @return string HTML string to total value */ - public function total() + public function total() { $value = 0; foreach ($this->data as $valarray) // Loop on each x @@ -1296,7 +1296,7 @@ class DolGraph * @param int|string $shownographyet Show graph to say there is not enough data or the message in $shownographyet if it is a string. * @return string HTML string to show graph */ - public function show($shownographyet = 0) + public function show($shownographyet = 0) { global $langs; @@ -1305,9 +1305,9 @@ class DolGraph $s = '
'; $s .= '
'; if (is_numeric($shownographyet)) { - $s .= $langs->trans("NotEnoughDataYet").'...'; + $s .= $langs->trans("NotEnoughDataYet").'...'; } else { - $s .= $shownographyet.'...'; + $s .= $shownographyet.'...'; } $s .= '
'; return $s; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index ba636ac2569..c8905e756d6 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -115,429 +115,429 @@ use Mike42\Escpos\EscposImage; */ class dolReceiptPrinter extends Printer { - const CONNECTOR_DUMMY = 1; - const CONNECTOR_FILE_PRINT = 2; - const CONNECTOR_NETWORK_PRINT = 3; - const CONNECTOR_WINDOWS_PRINT = 4; - const CONNECTOR_CUPS_PRINT = 5; + const CONNECTOR_DUMMY = 1; + const CONNECTOR_FILE_PRINT = 2; + const CONNECTOR_NETWORK_PRINT = 3; + const CONNECTOR_WINDOWS_PRINT = 4; + const CONNECTOR_CUPS_PRINT = 5; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /* + /* * @var string[] array of tags */ - public $tags; - public $printer; - public $template; + public $tags; + public $printer; + public $template; - /** - * Number of order printer - * @var int - */ - public $orderprinter; + /** + * Number of order printer + * @var int + */ + public $orderprinter; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); - /** - * Constructor - * - * @param DoliDB $db database - */ - public function __construct($db) - { - $this->db = $db; - $this->tags = array( - 'dol_line_feed' => 'DOL_LINE_FEED', - 'dol_line_feed_reverse' => 'DOL_LINE_FEED_REVERSE', - 'dol_align_left' => 'DOL_ALIGN_LEFT', - 'dol_align_center' => 'DOL_ALIGN_CENTER', - 'dol_align_right' => 'DOL_ALIGN_RIGHT', - 'dol_use_font_a' => 'DOL_USE_FONT_A', - 'dol_use_font_b' => 'DOL_USE_FONT_B', - 'dol_use_font_c' => 'DOL_USE_FONT_C', - 'dol_bold' => 'DOL_BOLD', - 'dol_bold_disabled' => 'DOL_BOLD_DISABLED', - 'dol_double_height' => 'DOL_DOUBLE_HEIGHT', - 'dol_double_width' => 'DOL_DOUBLE_WIDTH', - 'dol_default_height_width' => 'DOL_DEFAULT_HEIGHT_WIDTH', - 'dol_underline' => 'DOL_UNDERLINE', - 'dol_underline_disabled' => 'DOL_UNDERLINE_DISABLED', - 'dol_cut_paper_full' => 'DOL_CUT_PAPER_FULL', - 'dol_cut_paper_partial' => 'DOL_CUT_PAPER_PARTIAL', - 'dol_open_drawer' => 'DOL_OPEN_DRAWER', - 'dol_beep' => 'DOL_BEEP', - 'dol_print_text' => 'DOL_PRINT_TEXT', - 'dol_print_barcode' => 'DOL_PRINT_BARCODE', - 'dol_value_date' => 'DateInvoice', - 'dol_value_date_time' => 'DateInvoiceWithTime', - 'dol_value_year' => 'YearInvoice', - 'dol_value_month_letters' => 'DOL_VALUE_MONTH_LETTERS', - 'dol_value_month' => 'DOL_VALUE_MONTH', - 'dol_value_day' => 'DOL_VALUE_DAY', - 'dol_value_day_letters' => 'DOL_VALUE_DAY', - 'dol_print_payment' => 'DOL_PRINT_PAYMENT', - 'dol_print_logo' => 'DOL_PRINT_LOGO', - 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', - 'dol_value_object_id' => 'InvoiceID', - 'dol_value_object_ref' => 'InvoiceRef', - 'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES', - 'dol_print_object_tax' => 'TotalVAT', - 'dol_print_object_local_tax1' => 'TotalLT1', - 'dol_print_object_local_tax2' => 'TotalLT2', - 'dol_print_object_total' => 'Total', - 'dol_print_object_number' => 'DOL_PRINT_OBJECT_NUMBER', - //'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS', - 'dol_print_order_lines' => 'DOL_PRINT_ORDER_LINES', - 'dol_value_customer_firstname' => 'DOL_VALUE_CUSTOMER_FIRSTNAME', - 'dol_value_customer_lastname' => 'DOL_VALUE_CUSTOMER_LASTNAME', - 'dol_value_customer_mail' => 'DOL_VALUE_CUSTOMER_MAIL', - 'dol_value_customer_phone' => 'DOL_VALUE_CUSTOMER_PHONE', - 'dol_value_customer_skype' => 'DOL_VALUE_CUSTOMER_SKYPE', - 'dol_value_customer_tax_number' => 'DOL_VALUE_CUSTOMER_TAX_NUMBER', - //'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE', - //'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS', - 'dol_value_mysoc_name' => 'DOL_VALUE_MYSOC_NAME', - 'dol_value_mysoc_address' => 'Address', - 'dol_value_mysoc_zip' => 'Zip', - 'dol_value_mysoc_town' => 'Town', - 'dol_value_mysoc_country' => 'Country', - 'dol_value_mysoc_idprof1' => 'ProfId1', - 'dol_value_mysoc_idprof2' => 'ProfId2', - 'dol_value_mysoc_idprof3' => 'ProfId3', - 'dol_value_mysoc_idprof4' => 'ProfId4', - 'dol_value_mysoc_idprof5' => 'ProfId5', - 'dol_value_mysoc_idprof6' => 'ProfId6', - 'dol_value_mysoc_tva_intra' => 'VATIntra', - 'dol_value_mysoc_capital' => 'Capital', - 'dol_value_vendor_lastname' => 'VendorLastname', - 'dol_value_vendor_firstname' => 'VendorFirstname', - 'dol_value_vendor_mail' => 'VendorEmail', - ); - } + /** + * Constructor + * + * @param DoliDB $db database + */ + public function __construct($db) + { + $this->db = $db; + $this->tags = array( + 'dol_line_feed' => 'DOL_LINE_FEED', + 'dol_line_feed_reverse' => 'DOL_LINE_FEED_REVERSE', + 'dol_align_left' => 'DOL_ALIGN_LEFT', + 'dol_align_center' => 'DOL_ALIGN_CENTER', + 'dol_align_right' => 'DOL_ALIGN_RIGHT', + 'dol_use_font_a' => 'DOL_USE_FONT_A', + 'dol_use_font_b' => 'DOL_USE_FONT_B', + 'dol_use_font_c' => 'DOL_USE_FONT_C', + 'dol_bold' => 'DOL_BOLD', + 'dol_bold_disabled' => 'DOL_BOLD_DISABLED', + 'dol_double_height' => 'DOL_DOUBLE_HEIGHT', + 'dol_double_width' => 'DOL_DOUBLE_WIDTH', + 'dol_default_height_width' => 'DOL_DEFAULT_HEIGHT_WIDTH', + 'dol_underline' => 'DOL_UNDERLINE', + 'dol_underline_disabled' => 'DOL_UNDERLINE_DISABLED', + 'dol_cut_paper_full' => 'DOL_CUT_PAPER_FULL', + 'dol_cut_paper_partial' => 'DOL_CUT_PAPER_PARTIAL', + 'dol_open_drawer' => 'DOL_OPEN_DRAWER', + 'dol_beep' => 'DOL_BEEP', + 'dol_print_text' => 'DOL_PRINT_TEXT', + 'dol_print_barcode' => 'DOL_PRINT_BARCODE', + 'dol_value_date' => 'DateInvoice', + 'dol_value_date_time' => 'DateInvoiceWithTime', + 'dol_value_year' => 'YearInvoice', + 'dol_value_month_letters' => 'DOL_VALUE_MONTH_LETTERS', + 'dol_value_month' => 'DOL_VALUE_MONTH', + 'dol_value_day' => 'DOL_VALUE_DAY', + 'dol_value_day_letters' => 'DOL_VALUE_DAY', + 'dol_print_payment' => 'DOL_PRINT_PAYMENT', + 'dol_print_logo' => 'DOL_PRINT_LOGO', + 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', + 'dol_value_object_id' => 'InvoiceID', + 'dol_value_object_ref' => 'InvoiceRef', + 'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES', + 'dol_print_object_tax' => 'TotalVAT', + 'dol_print_object_local_tax1' => 'TotalLT1', + 'dol_print_object_local_tax2' => 'TotalLT2', + 'dol_print_object_total' => 'Total', + 'dol_print_object_number' => 'DOL_PRINT_OBJECT_NUMBER', + //'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS', + 'dol_print_order_lines' => 'DOL_PRINT_ORDER_LINES', + 'dol_value_customer_firstname' => 'DOL_VALUE_CUSTOMER_FIRSTNAME', + 'dol_value_customer_lastname' => 'DOL_VALUE_CUSTOMER_LASTNAME', + 'dol_value_customer_mail' => 'DOL_VALUE_CUSTOMER_MAIL', + 'dol_value_customer_phone' => 'DOL_VALUE_CUSTOMER_PHONE', + 'dol_value_customer_skype' => 'DOL_VALUE_CUSTOMER_SKYPE', + 'dol_value_customer_tax_number' => 'DOL_VALUE_CUSTOMER_TAX_NUMBER', + //'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE', + //'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS', + 'dol_value_mysoc_name' => 'DOL_VALUE_MYSOC_NAME', + 'dol_value_mysoc_address' => 'Address', + 'dol_value_mysoc_zip' => 'Zip', + 'dol_value_mysoc_town' => 'Town', + 'dol_value_mysoc_country' => 'Country', + 'dol_value_mysoc_idprof1' => 'ProfId1', + 'dol_value_mysoc_idprof2' => 'ProfId2', + 'dol_value_mysoc_idprof3' => 'ProfId3', + 'dol_value_mysoc_idprof4' => 'ProfId4', + 'dol_value_mysoc_idprof5' => 'ProfId5', + 'dol_value_mysoc_idprof6' => 'ProfId6', + 'dol_value_mysoc_tva_intra' => 'VATIntra', + 'dol_value_mysoc_capital' => 'Capital', + 'dol_value_vendor_lastname' => 'VendorLastname', + 'dol_value_vendor_firstname' => 'VendorFirstname', + 'dol_value_vendor_mail' => 'VendorEmail', + ); + } - /** - * list printers - * - * @return int 0 if OK; >0 if KO - */ - public function listPrinters() - { - global $conf; - $error = 0; - $line = 0; - $obj = array(); - $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - while ($line < $num) { - $row = $this->db->fetch_array($resql); - switch ($row['fk_type']) { - case 1: - $row['fk_type_name'] = 'CONNECTOR_DUMMY'; - break; - case 2: - $row['fk_type_name'] = 'CONNECTOR_FILE_PRINT'; - break; - case 3: - $row['fk_type_name'] = 'CONNECTOR_NETWORK_PRINT'; - break; - case 4: - $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT'; - break; - case 5: - $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT'; - break; - default: - $row['fk_type_name'] = 'CONNECTOR_UNKNOWN'; - break; - } - switch ($row['fk_profile']) { - case 0: - $row['fk_profile_name'] = 'PROFILE_DEFAULT'; - break; - case 1: - $row['fk_profile_name'] = 'PROFILE_SIMPLE'; - break; - case 2: - $row['fk_profile_name'] = 'PROFILE_EPOSTEP'; - break; - case 3: - $row['fk_profile_name'] = 'PROFILE_P822D'; - break; - default: - $row['fk_profile_name'] = 'PROFILE_STAR'; - break; - } - $obj[] = $row; - $line++; - } - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - $this->listprinters = $obj; - return $error; - } + /** + * list printers + * + * @return int 0 if OK; >0 if KO + */ + public function listPrinters() + { + global $conf; + $error = 0; + $line = 0; + $obj = array(); + $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + while ($line < $num) { + $row = $this->db->fetch_array($resql); + switch ($row['fk_type']) { + case 1: + $row['fk_type_name'] = 'CONNECTOR_DUMMY'; + break; + case 2: + $row['fk_type_name'] = 'CONNECTOR_FILE_PRINT'; + break; + case 3: + $row['fk_type_name'] = 'CONNECTOR_NETWORK_PRINT'; + break; + case 4: + $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT'; + break; + case 5: + $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT'; + break; + default: + $row['fk_type_name'] = 'CONNECTOR_UNKNOWN'; + break; + } + switch ($row['fk_profile']) { + case 0: + $row['fk_profile_name'] = 'PROFILE_DEFAULT'; + break; + case 1: + $row['fk_profile_name'] = 'PROFILE_SIMPLE'; + break; + case 2: + $row['fk_profile_name'] = 'PROFILE_EPOSTEP'; + break; + case 3: + $row['fk_profile_name'] = 'PROFILE_P822D'; + break; + default: + $row['fk_profile_name'] = 'PROFILE_STAR'; + break; + } + $obj[] = $row; + $line++; + } + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + $this->listprinters = $obj; + return $error; + } - /** - * List printers templates - * - * @return int 0 if OK; >0 if KO - */ - public function listPrintersTemplates() - { - global $conf; - $error = 0; - $line = 0; - $obj = array(); - $sql = 'SELECT rowid, name, template'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' WHERE entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - while ($line < $num) { - $obj[] = $this->db->fetch_array($resql); - $line++; - } - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - $this->listprinterstemplates = $obj; - return $error; - } + /** + * List printers templates + * + * @return int 0 if OK; >0 if KO + */ + public function listPrintersTemplates() + { + global $conf; + $error = 0; + $line = 0; + $obj = array(); + $sql = 'SELECT rowid, name, template'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' WHERE entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + while ($line < $num) { + $obj[] = $this->db->fetch_array($resql); + $line++; + } + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + $this->listprinterstemplates = $obj; + return $error; + } - /** - * Form to Select type printer - * - * @param string $selected Id printer type pre-selected - * @param string $htmlname select html name - * @return int 0 if OK; >0 if KO - */ - public function selectTypePrinter($selected = '', $htmlname = 'printertypeid') - { - global $langs; + /** + * Form to Select type printer + * + * @param string $selected Id printer type pre-selected + * @param string $htmlname select html name + * @return int 0 if OK; >0 if KO + */ + public function selectTypePrinter($selected = '', $htmlname = 'printertypeid') + { + global $langs; - $options = array( - 1 => $langs->trans('CONNECTOR_DUMMY'), - 2 => $langs->trans('CONNECTOR_FILE_PRINT'), - 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), - 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'), + $options = array( + 1 => $langs->trans('CONNECTOR_DUMMY'), + 2 => $langs->trans('CONNECTOR_FILE_PRINT'), + 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), + 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'), 5 => $langs->trans('CONNECTOR_CUPS_PRINT'), - ); + ); - $this->resprint = Form::selectarray($htmlname, $options, $selected); + $this->resprint = Form::selectarray($htmlname, $options, $selected); - return 0; - } + return 0; + } - /** - * Form to Select Profile printer - * - * @param string $selected Id printer profile pre-selected - * @param string $htmlname select html name - * @return int 0 if OK; >0 if KO - */ - public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') - { - global $langs; + /** + * Form to Select Profile printer + * + * @param string $selected Id printer profile pre-selected + * @param string $htmlname select html name + * @return int 0 if OK; >0 if KO + */ + public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') + { + global $langs; - $options = array( - 0 => $langs->trans('PROFILE_DEFAULT'), - 1 => $langs->trans('PROFILE_SIMPLE'), - 2 => $langs->trans('PROFILE_EPOSTEP'), - 3 => $langs->trans('PROFILE_P822D'), - 4 => $langs->trans('PROFILE_STAR'), - ); + $options = array( + 0 => $langs->trans('PROFILE_DEFAULT'), + 1 => $langs->trans('PROFILE_SIMPLE'), + 2 => $langs->trans('PROFILE_EPOSTEP'), + 3 => $langs->trans('PROFILE_P822D'), + 4 => $langs->trans('PROFILE_STAR'), + ); - $this->profileresprint = Form::selectarray($htmlname, $options, $selected); - return 0; - } + $this->profileresprint = Form::selectarray($htmlname, $options, $selected); + return 0; + } - /** - * Function to Add a printer in db - * - * @param string $name Printer name - * @param int $type Printer type - * @param int $profile Printer profile - * @param string $parameter Printer parameter - * @return int 0 if OK; >0 if KO - */ - public function addPrinter($name, $type, $profile, $parameter) - { - global $conf; - $error = 0; - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; - $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Add a printer in db + * + * @param string $name Printer name + * @param int $type Printer type + * @param int $profile Printer profile + * @param string $parameter Printer parameter + * @return int 0 if OK; >0 if KO + */ + public function addPrinter($name, $type, $profile, $parameter) + { + global $conf; + $error = 0; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; + $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Update a printer in db - * - * @param string $name Printer name - * @param int $type Printer type - * @param int $profile Printer profile - * @param string $parameter Printer parameter - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function updatePrinter($name, $type, $profile, $parameter, $printerid) - { - global $conf; - $error = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' SET name="'.$this->db->escape($name).'"'; - $sql .= ', fk_type='.$type; - $sql .= ', fk_profile='.$profile; - $sql .= ', parameter="'.$this->db->escape($parameter).'"'; - $sql .= ' WHERE rowid='.$printerid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Update a printer in db + * + * @param string $name Printer name + * @param int $type Printer type + * @param int $profile Printer profile + * @param string $parameter Printer parameter + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function updatePrinter($name, $type, $profile, $parameter, $printerid) + { + global $conf; + $error = 0; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' SET name="'.$this->db->escape($name).'"'; + $sql .= ', fk_type='.$type; + $sql .= ', fk_profile='.$profile; + $sql .= ', parameter="'.$this->db->escape($parameter).'"'; + $sql .= ' WHERE rowid='.$printerid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Delete a printer from db - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function deletePrinter($printerid) - { - global $conf; - $error = 0; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid='.$printerid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Delete a printer from db + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function deletePrinter($printerid) + { + global $conf; + $error = 0; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE rowid='.$printerid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to add a printer template in db - * - * @param string $name Template name - * @param int $template Template - * @return int 0 if OK; >0 if KO - */ - public function addTemplate($name, $template) - { - global $conf; - $error = 0; - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' (name, template, entity) VALUES ("'.$this->db->escape($name).'"'; - $sql .= ', "'.$this->db->escape($template).'", '.$conf->entity.')'; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to add a printer template in db + * + * @param string $name Template name + * @param int $template Template + * @return int 0 if OK; >0 if KO + */ + public function addTemplate($name, $template) + { + global $conf; + $error = 0; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' (name, template, entity) VALUES ("'.$this->db->escape($name).'"'; + $sql .= ', "'.$this->db->escape($template).'", '.$conf->entity.')'; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to delete a printer template in db - * - * @param int $templateid Template ID - * @return int 0 if OK; >0 if KO - */ - public function deleteTemplate($templateid) - { - global $conf; - $error = 0; - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= " WHERE rowid = ".((int) $this->db->escape($templateid)); - $sql .= " AND entity = ".$conf->entity; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to delete a printer template in db + * + * @param int $templateid Template ID + * @return int 0 if OK; >0 if KO + */ + public function deleteTemplate($templateid) + { + global $conf; + $error = 0; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= " WHERE rowid = ".((int) $this->db->escape($templateid)); + $sql .= " AND entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Update a printer template in db - * - * @param string $name Template name - * @param int $template Template - * @param int $templateid Template id - * @return int 0 if OK; >0 if KO - */ - public function updateTemplate($name, $template, $templateid) - { - global $conf; - $error = 0; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' SET name="'.$this->db->escape($name).'"'; - $sql .= ', template="'.$this->db->escape($template).'"'; - $sql .= ' WHERE rowid='.$templateid; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; - $this->errors[] = $this->db->lasterror; - } - return $error; - } + /** + * Function to Update a printer template in db + * + * @param string $name Template name + * @param int $template Template + * @param int $templateid Template id + * @return int 0 if OK; >0 if KO + */ + public function updateTemplate($name, $template, $templateid) + { + global $conf; + $error = 0; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' SET name="'.$this->db->escape($name).'"'; + $sql .= ', template="'.$this->db->escape($template).'"'; + $sql .= ' WHERE rowid='.$templateid; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = $this->db->lasterror; + } + return $error; + } - /** - * Function to Send Test page to Printer - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function sendTestToPrinter($printerid) - { - global $conf; - $error = 0; - $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); - //$this->profile = CapabilityProfile::load("TM-T88IV"); - $ret = $this->initPrinter($printerid); - if ($ret > 0) { - setEventMessages($this->error, $this->errors, 'errors'); - } else { - try { - $this->printer->bitImage($img); - $this->printer->text("Hello World!\n"); - $testStr = "1234567890"; - $this->printer->barcode($testStr); - //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1); - $this->printer->text("Most simple example\n"); - $this->printer->feed(); - $this->printer->cut(); + /** + * Function to Send Test page to Printer + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function sendTestToPrinter($printerid) + { + global $conf; + $error = 0; + $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); + //$this->profile = CapabilityProfile::load("TM-T88IV"); + $ret = $this->initPrinter($printerid); + if ($ret > 0) { + setEventMessages($this->error, $this->errors, 'errors'); + } else { + try { + $this->printer->bitImage($img); + $this->printer->text("Hello World!\n"); + $testStr = "1234567890"; + $this->printer->barcode($testStr); + //$this->printer->qrcode($testStr, Printer::QR_ECLEVEL_M, 5, Printer::QR_MODEL_1); + $this->printer->text("Most simple example\n"); + $this->printer->feed(); + $this->printer->cut(); // If is DummyPrintConnector send to log to debugging if ($this->printer->connector instanceof DummyPrintConnector) @@ -545,227 +545,227 @@ class dolReceiptPrinter extends Printer $data = $this->printer->connector-> getData(); dol_syslog($data); } - $this->printer->close(); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $error++; - } - } - return $error; - } + $this->printer->close(); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $error++; + } + } + return $error; + } - /** - * Function to Print Receipt Ticket - * - * @param Facture|Commande $object Order or invoice object - * @param int $templateid Template id - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function sendToPrinter($object, $templateid, $printerid) - { - global $conf, $mysoc, $langs, $user; - $error = 0; - $ret = $this->loadTemplate($templateid); + /** + * Function to Print Receipt Ticket + * + * @param Facture|Commande $object Order or invoice object + * @param int $templateid Template id + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function sendToPrinter($object, $templateid, $printerid) + { + global $conf, $mysoc, $langs, $user; + $error = 0; + $ret = $this->loadTemplate($templateid); - // tags a remplacer par leur valeur avant de parser (dol_value_xxx) - $this->template = str_replace('{dol_value_object_id}', $object->id, $this->template); - $this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template); - //$this->template = str_replace('', $object->points, $this->template); - $this->template = str_replace('{dol_value_date}', dol_print_date($object->date, 'day'), $this->template); - $this->template = str_replace('{dol_value_date_time}', dol_print_date($object->date, 'dayhour'), $this->template); - $this->template = str_replace('{dol_value_year}', dol_print_date($object->date, '%Y'), $this->template); - $this->template = str_replace('{dol_value_month_letters}', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template); - $this->template = str_replace('{dol_value_month}', dol_print_date($object->date, '%m'), $this->template); - $this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template); - $this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template); + // tags a remplacer par leur valeur avant de parser (dol_value_xxx) + $this->template = str_replace('{dol_value_object_id}', $object->id, $this->template); + $this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template); + //$this->template = str_replace('', $object->points, $this->template); + $this->template = str_replace('{dol_value_date}', dol_print_date($object->date, 'day'), $this->template); + $this->template = str_replace('{dol_value_date_time}', dol_print_date($object->date, 'dayhour'), $this->template); + $this->template = str_replace('{dol_value_year}', dol_print_date($object->date, '%Y'), $this->template); + $this->template = str_replace('{dol_value_month_letters}', $langs->trans("Month".dol_print_date($object->date, '%m')), $this->template); + $this->template = str_replace('{dol_value_month}', dol_print_date($object->date, '%m'), $this->template); + $this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template); + $this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template); - $this->template = str_replace('{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template); - $this->template = str_replace('{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template); - $this->template = str_replace('{dol_value_customer_mail}', $object->thirdparty->email, $this->template); - $this->template = str_replace('{dol_value_customer_phone}', $object->thirdparty->phone, $this->template); - //$this->template = str_replace('', $object->thirdparty->mobile, $this->template); - $this->template = str_replace('{dol_value_customer_tax_number}', $object->thirdparty->tva_intra, $this->template); - //$this->template = str_replace('', $object->customer_account_balance, $this->template); - //$this->template = str_replace('', $object->customer_points, $this->template); + $this->template = str_replace('{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template); + $this->template = str_replace('{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template); + $this->template = str_replace('{dol_value_customer_mail}', $object->thirdparty->email, $this->template); + $this->template = str_replace('{dol_value_customer_phone}', $object->thirdparty->phone, $this->template); + //$this->template = str_replace('', $object->thirdparty->mobile, $this->template); + $this->template = str_replace('{dol_value_customer_tax_number}', $object->thirdparty->tva_intra, $this->template); + //$this->template = str_replace('', $object->customer_account_balance, $this->template); + //$this->template = str_replace('', $object->customer_points, $this->template); - $this->template = str_replace('{dol_value_mysoc_name}', $mysoc->name, $this->template); - $this->template = str_replace('{dol_value_mysoc_address}', $mysoc->address, $this->template); - $this->template = str_replace('{dol_value_mysoc_zip}', $mysoc->zip, $this->template); - $this->template = str_replace('{dol_value_mysoc_town}', $mysoc->town, $this->template); - $this->template = str_replace('{dol_value_mysoc_country}', $mysoc->country, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof1}', $mysoc->idprof1, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof2}', $mysoc->idprof2, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof3}', $mysoc->idprof3, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof4}', $mysoc->idprof4, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof5}', $mysoc->idprof5, $this->template); - $this->template = str_replace('{dol_value_mysoc_idprof6}', $mysoc->idprof6, $this->template); - $this->template = str_replace('{dol_value_mysoc_tva_intra}', $mysoc->tva_intra, $this->template); - $this->template = str_replace('{dol_value_mysoc_capital}', $mysoc->capital, $this->template); + $this->template = str_replace('{dol_value_mysoc_name}', $mysoc->name, $this->template); + $this->template = str_replace('{dol_value_mysoc_address}', $mysoc->address, $this->template); + $this->template = str_replace('{dol_value_mysoc_zip}', $mysoc->zip, $this->template); + $this->template = str_replace('{dol_value_mysoc_town}', $mysoc->town, $this->template); + $this->template = str_replace('{dol_value_mysoc_country}', $mysoc->country, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof1}', $mysoc->idprof1, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof2}', $mysoc->idprof2, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof3}', $mysoc->idprof3, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof4}', $mysoc->idprof4, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof5}', $mysoc->idprof5, $this->template); + $this->template = str_replace('{dol_value_mysoc_idprof6}', $mysoc->idprof6, $this->template); + $this->template = str_replace('{dol_value_mysoc_tva_intra}', $mysoc->tva_intra, $this->template); + $this->template = str_replace('{dol_value_mysoc_capital}', $mysoc->capital, $this->template); - $this->template = str_replace('{dol_value_vendor_firstname}', $user->firstname, $this->template); - $this->template = str_replace('{dol_value_vendor_lastname}', $user->lastname, $this->template); - $this->template = str_replace('{dol_value_vendor_mail}', $user->email, $this->template); + $this->template = str_replace('{dol_value_vendor_firstname}', $user->firstname, $this->template); + $this->template = str_replace('{dol_value_vendor_lastname}', $user->lastname, $this->template); + $this->template = str_replace('{dol_value_vendor_mail}', $user->email, $this->template); - // parse template + // parse template $this->template = str_replace("{", "<", $this->template); $this->template = str_replace("}", ">", $this->template); - $p = xml_parser_create(); - xml_parse_into_struct($p, $this->template, $vals, $index); - xml_parser_free($p); - //print '
'.print_r($index, true).'
'; - //print '
'.print_r($vals, true).'
'; - // print ticket - $level = 0; - $nbcharactbyline = (!empty($conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE) ? $conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE : 48); - $ret = $this->initPrinter($printerid); - if ($ret > 0) { - setEventMessages($this->error, $this->errors, 'errors'); - } else { - $nboflines = count($vals); - for ($tplline = 0; $tplline < $nboflines; $tplline++) { - //var_dump($vals[$tplline]['value']); - switch ($vals[$tplline]['tag']) { - case 'DOL_PRINT_TEXT': - $this->printer->text($vals[$tplline]['value']); - break; - case 'DOL_PRINT_OBJECT_LINES': - foreach ($object->lines as $line) { - //var_dump($line); - $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX': - //var_dump($object); - $vatarray = array(); - foreach ($object->lines as $line) { - $vatarray[$line->tva_tx] += $line->total_tva; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX1': - //var_dump($object); - $total_localtax1 = 0; - foreach ($object->lines as $line) { - $total_localtax1 += $line->total_localtax1; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TAX2': - //var_dump($object); - $total_localtax2 = 0; - foreach ($object->lines as $line) { - $total_localtax2 += $line->total_localtax2; - } - foreach ($vatarray as $vatkey => $vatvalue) { - $this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n"); - } - break; - case 'DOL_PRINT_OBJECT_TOTAL': - $title = $langs->trans('TotalHT'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_ht), 10, ' ', STR_PAD_LEFT)."\n"); - $title = $langs->trans('TotalVAT'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_tva), 10, ' ', STR_PAD_LEFT)."\n"); - $title = $langs->trans('TotalTTC'); - $spacestoadd = $nbcharactbyline - strlen($title) - 10; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - break; - case 'DOL_LINE_FEED': - $this->printer->feed(); - break; - case 'DOL_LINE_FEED_REVERSE': - $this->printer->feedReverse(); - break; - case 'DOL_ALIGN_CENTER': - $this->printer->setJustification(Printer::JUSTIFY_CENTER); - break; - case 'DOL_ALIGN_RIGHT': - $this->printer->setJustification(Printer::JUSTIFY_RIGHT); - break; - case 'DOL_ALIGN_LEFT': - $this->printer->setJustification(Printer::JUSTIFY_LEFT); - break; - case 'DOL_OPEN_DRAWER': - $this->printer->pulse(); - break; - case 'DOL_ACTIVATE_BUZZER': - //$this->printer->buzzer(); - break; - case 'DOL_PRINT_BARCODE': - // $vals[$tplline]['value'] -> barcode($content, $type) - // var_dump($vals[$tplline]['value']); - try { - $this->printer->barcode($vals[$tplline]['value']); - } catch (Exception $e) { - $this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value']; - $error++; - } - break; - case 'DOL_PRINT_LOGO': - $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); - $this->printer->graphics($img); - break; - case 'DOL_PRINT_LOGO_OLD': - $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); - $this->printer->bitImage($img); - break; - case 'DOL_PRINT_QRCODE': - // $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model) - $this->printer->qrcode($vals[$tplline]['value']); - break; - case 'DOL_CUT_PAPER_FULL': - $this->printer->cut(Printer::CUT_FULL); - break; - case 'DOL_CUT_PAPER_PARTIAL': - $this->printer->cut(Printer::CUT_PARTIAL); - break; - case 'DOL_USE_FONT_A': - $this->printer->setFont(Printer::FONT_A); - break; - case 'DOL_USE_FONT_B': - $this->printer->setFont(Printer::FONT_B); - break; - case 'DOL_USE_FONT_C': - $this->printer->setFont(Printer::FONT_C); - break; + $p = xml_parser_create(); + xml_parse_into_struct($p, $this->template, $vals, $index); + xml_parser_free($p); + //print '
'.print_r($index, true).'
'; + //print '
'.print_r($vals, true).'
'; + // print ticket + $level = 0; + $nbcharactbyline = (!empty($conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE) ? $conf->global->RECEIPT_PRINTER_NB_CHARACT_BY_LINE : 48); + $ret = $this->initPrinter($printerid); + if ($ret > 0) { + setEventMessages($this->error, $this->errors, 'errors'); + } else { + $nboflines = count($vals); + for ($tplline = 0; $tplline < $nboflines; $tplline++) { + //var_dump($vals[$tplline]['value']); + switch ($vals[$tplline]['tag']) { + case 'DOL_PRINT_TEXT': + $this->printer->text($vals[$tplline]['value']); + break; + case 'DOL_PRINT_OBJECT_LINES': + foreach ($object->lines as $line) { + //var_dump($line); + $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX': + //var_dump($object); + $vatarray = array(); + foreach ($object->lines as $line) { + $vatarray[$line->tva_tx] += $line->total_tva; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX1': + //var_dump($object); + $total_localtax1 = 0; + foreach ($object->lines as $line) { + $total_localtax1 += $line->total_localtax1; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $this->printer->text(str_pad(price($total_localtax1), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TAX2': + //var_dump($object); + $total_localtax2 = 0; + foreach ($object->lines as $line) { + $total_localtax2 += $line->total_localtax2; + } + foreach ($vatarray as $vatkey => $vatvalue) { + $this->printer->text(str_pad(price($total_localtax2), 10, ' ', STR_PAD_LEFT)."\n"); + } + break; + case 'DOL_PRINT_OBJECT_TOTAL': + $title = $langs->trans('TotalHT'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_ht), 10, ' ', STR_PAD_LEFT)."\n"); + $title = $langs->trans('TotalVAT'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_tva), 10, ' ', STR_PAD_LEFT)."\n"); + $title = $langs->trans('TotalTTC'); + $spacestoadd = $nbcharactbyline - strlen($title) - 10; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + break; + case 'DOL_LINE_FEED': + $this->printer->feed(); + break; + case 'DOL_LINE_FEED_REVERSE': + $this->printer->feedReverse(); + break; + case 'DOL_ALIGN_CENTER': + $this->printer->setJustification(Printer::JUSTIFY_CENTER); + break; + case 'DOL_ALIGN_RIGHT': + $this->printer->setJustification(Printer::JUSTIFY_RIGHT); + break; + case 'DOL_ALIGN_LEFT': + $this->printer->setJustification(Printer::JUSTIFY_LEFT); + break; + case 'DOL_OPEN_DRAWER': + $this->printer->pulse(); + break; + case 'DOL_ACTIVATE_BUZZER': + //$this->printer->buzzer(); + break; + case 'DOL_PRINT_BARCODE': + // $vals[$tplline]['value'] -> barcode($content, $type) + // var_dump($vals[$tplline]['value']); + try { + $this->printer->barcode($vals[$tplline]['value']); + } catch (Exception $e) { + $this->errors[] = 'Invalid Barcode value: '.$vals[$tplline]['value']; + $error++; + } + break; + case 'DOL_PRINT_LOGO': + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); + $this->printer->graphics($img); + break; + case 'DOL_PRINT_LOGO_OLD': + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); + $this->printer->bitImage($img); + break; + case 'DOL_PRINT_QRCODE': + // $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model) + $this->printer->qrcode($vals[$tplline]['value']); + break; + case 'DOL_CUT_PAPER_FULL': + $this->printer->cut(Printer::CUT_FULL); + break; + case 'DOL_CUT_PAPER_PARTIAL': + $this->printer->cut(Printer::CUT_PARTIAL); + break; + case 'DOL_USE_FONT_A': + $this->printer->setFont(Printer::FONT_A); + break; + case 'DOL_USE_FONT_B': + $this->printer->setFont(Printer::FONT_B); + break; + case 'DOL_USE_FONT_C': + $this->printer->setFont(Printer::FONT_C); + break; case 'DOL_BOLD': - $this->printer->setEmphasis(true); - break; + $this->printer->setEmphasis(true); + break; case 'DOL_BOLD_DISABLED': - $this->printer->setEmphasis(false); - break; + $this->printer->setEmphasis(false); + break; case 'DOL_DOUBLE_HEIGHT': - $this->printer->setTextSize(1, 2); - break; + $this->printer->setTextSize(1, 2); + break; case 'DOL_DOUBLE_WIDTH': - $this->printer->setTextSize(2, 1); - break; + $this->printer->setTextSize(2, 1); + break; case 'DOL_DEFAULT_HEIGHT_WIDTH': - $this->printer->setTextSize(1, 1); - break; + $this->printer->setTextSize(1, 1); + break; case 'DOL_UNDERLINE': - $this->printer->setUnderline(true); - break; + $this->printer->setUnderline(true); + break; case 'DOL_UNDERLINE_DISABLED': - $this->printer->setUnderline(false); - break; + $this->printer->setUnderline(false); + break; case 'DOL_BEEP': - $this->printer->getPrintConnector() -> write("\x1e"); - break; + $this->printer->getPrintConnector() -> write("\x1e"); + break; case 'DOL_PRINT_ORDER_LINES': foreach ($object->lines as $line) { if ($line->special_code == $this->orderprinter) @@ -775,7 +775,7 @@ class dolReceiptPrinter extends Printer $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n"); } - } + } break; case 'DOL_PRINT_PAYMENT': $sql = "SELECT p.pos_change as pos_change, p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; @@ -793,10 +793,10 @@ class dolReceiptPrinter extends Printer $row = $this->db->fetch_object($resql); $spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12; $spaces = str_repeat(' ', $spacestoadd); - $amount_payment=($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; + $amount_payment = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount; if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment $this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n"); - if ($row->code == "LIQ" && $row->pos_change>0) // Print change only in cash payments + if ($row->code == "LIQ" && $row->pos_change > 0) // Print change only in cash payments { $spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12; $spaces = str_repeat(' ', $spacestoadd); @@ -806,15 +806,15 @@ class dolReceiptPrinter extends Printer } } break; - default: - $this->printer->text($vals[$tplline]['tag']); - $this->printer->text($vals[$tplline]['value']); - $this->errors[] = 'UnknowTag: <'.strtolower($vals[$tplline]['tag']).'>'; - $error++; - break; - } - } - // If is DummyPrintConnector send to log to debugging + default: + $this->printer->text($vals[$tplline]['tag']); + $this->printer->text($vals[$tplline]['value']); + $this->errors[] = 'UnknowTag: <'.strtolower($vals[$tplline]['tag']).'>'; + $error++; + break; + } + } + // If is DummyPrintConnector send to log to debugging if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") { $data = $this->printer->connector->getData(); @@ -822,103 +822,103 @@ class dolReceiptPrinter extends Printer dol_syslog($data); } // Close and print - $this->printer->close(); - } - return $error; - } + $this->printer->close(); + } + return $error; + } - /** - * Function to load Template - * - * @param int $templateid Template id - * @return int 0 if OK; >0 if KO - */ - public function loadTemplate($templateid) - { - global $conf; - $error = 0; - $sql = 'SELECT template'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql .= ' WHERE rowid='.$templateid; - $sql .= ' AND entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_array($resql); - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - if (empty($obj)) { - $error++; - $this->errors[] = 'TemplateDontExist'; - } else { - $this->template = $obj['0']; - } + /** + * Function to load Template + * + * @param int $templateid Template id + * @return int 0 if OK; >0 if KO + */ + public function loadTemplate($templateid) + { + global $conf; + $error = 0; + $sql = 'SELECT template'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' WHERE rowid='.$templateid; + $sql .= ' AND entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_array($resql); + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + if (empty($obj)) { + $error++; + $this->errors[] = 'TemplateDontExist'; + } else { + $this->template = $obj['0']; + } - return $error; - } + return $error; + } - /** - * Function Init Printer - * - * @param int $printerid Printer id - * @return int 0 if OK; >0 if KO - */ - public function initPrinter($printerid) - { - global $conf; + /** + * Function Init Printer + * + * @param int $printerid Printer id + * @return int 0 if OK; >0 if KO + */ + public function initPrinter($printerid) + { + global $conf; if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector"){ $this->connector = new DummyPrintConnector(); $this->printer = new Printer($this->connector, $this->profile); return; } - $error = 0; - $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql .= ' WHERE rowid = '.$printerid; - $sql .= ' AND entity = '.$conf->entity; - $resql = $this->db->query($sql); - if ($resql) { - $obj = $this->db->fetch_array($resql); - } else { - $error++; - $this->errors[] = $this->db->lasterror; - } - if (empty($obj)) { - $error++; - $this->errors[] = 'PrinterDontExist'; - } - if (!$error) { - $parameter = $obj['parameter']; - try { - switch ($obj['fk_type']) { - case 1: - $this->connector = new DummyPrintConnector(); - break; - case 2: - $this->connector = new FilePrintConnector($parameter); - break; - case 3: - $parameters = explode(':', $parameter); - $this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]); - break; - case 4: - $this->connector = new WindowsPrintConnector($parameter); - break; + $error = 0; + $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE rowid = '.$printerid; + $sql .= ' AND entity = '.$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_array($resql); + } else { + $error++; + $this->errors[] = $this->db->lasterror; + } + if (empty($obj)) { + $error++; + $this->errors[] = 'PrinterDontExist'; + } + if (!$error) { + $parameter = $obj['parameter']; + try { + switch ($obj['fk_type']) { + case 1: + $this->connector = new DummyPrintConnector(); + break; + case 2: + $this->connector = new FilePrintConnector($parameter); + break; + case 3: + $parameters = explode(':', $parameter); + $this->connector = new NetworkPrintConnector($parameters[0], $parameters[1]); + break; + case 4: + $this->connector = new WindowsPrintConnector($parameter); + break; case 5: - $this->connector = new CupsPrintConnector($parameter); - break; - default: - $this->connector = 'CONNECTOR_UNKNOWN'; - break; - } - $this->printer = new Printer($this->connector, $this->profile); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $error++; - } - } - return $error; - } + $this->connector = new CupsPrintConnector($parameter); + break; + default: + $this->connector = 'CONNECTOR_UNKNOWN'; + break; + } + $this->printer = new Printer($this->connector, $this->profile); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $error++; + } + } + return $error; + } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 2eaf5f744bd..efb2e554da9 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -114,15 +114,15 @@ class EmailSenderProfile extends CommonObject public $entity; /** - * @var string Email Sender Profile label - */ - public $label; + * @var string Email Sender Profile label + */ + public $label; public $email; /** - * @var integer|string date_creation - */ + * @var integer|string date_creation + */ public $date_creation; @@ -305,9 +305,9 @@ class EmailSenderProfile extends CommonObject $result = ''; $companylink = ''; - $label = $this->label; + $label = $this->label; - $url = ''; + $url = ''; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; $linkstart = ''; @@ -332,7 +332,7 @@ class EmailSenderProfile extends CommonObject return $this->LibStatut($this->active, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -356,8 +356,8 @@ class EmailSenderProfile extends CommonObject return dolGetStatus($label, $labelshort, '', $statusType, $mode); } - /** - * Charge les informations d'ordre info dans l'objet commande + /** + * Charge les informations d'ordre info dans l'objet commande * * @param int $id Id of order * @return void diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php index 7e02aa57032..c30c37266c1 100644 --- a/htdocs/core/class/evalmath.class.php +++ b/htdocs/core/class/evalmath.class.php @@ -149,8 +149,8 @@ class EvalMath $expr = trim($expr); if (substr($expr, - 1, 1) == ';') $expr = substr($expr, 0, strlen($expr) - 1); // strip semicolons at the end - // =============== - // is it a variable assignment? + // =============== + // is it a variable assignment? $matches = array(); if (preg_match('/^\s*([a-z]\w*)\s*=\s*(.+)$/', $expr, $matches)) { if (in_array($matches[1], $this->vb)) { // make sure we're not assigning to a constant @@ -160,8 +160,8 @@ class EvalMath return false; // get the result and make sure it's good $this->v[$matches[1]] = $tmp; // if so, stick it in the variable array return $this->v[$matches[1]]; // and return the resulting value - // =============== - // is it a function assignment? + // =============== + // is it a function assignment? } elseif (preg_match('/^\s*([a-z]\w*)\s*\(\s*([a-z]\w*(?:\s*,\s*[a-z]\w*)*)\s*\)\s*=\s*(.+)$/', $expr, $matches)) { $fnn = $matches[1]; // get the function name if (in_array($matches[1], $this->fb)) { // make sure it isn't built in @@ -235,7 +235,7 @@ class EvalMath $ops_p = array('+' => 0, '-' => 0, '*' => 1, '/' => 1, '_' => 1, '^' => 2); // operator precedence $expecting_op = false; // we use this in syntax-checking the expression - // and determining when a - is a negation + // and determining when a - is a negation $matches = array(); if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good @@ -244,7 +244,7 @@ class EvalMath while (1) { // 1 Infinite Loop ;) $op = substr($expr, $index, 1); // get the first character at the current index - // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand + // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand $match = array(); $ex = preg_match('/^([a-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr($expr, $index), $match); // =============== @@ -253,7 +253,7 @@ class EvalMath $index++; } elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack return $this->trigger(4, "illegal character '_'", "_"); // but not in the input expression - // =============== + // =============== } elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack? if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis? $op = '*'; @@ -372,7 +372,7 @@ class EvalMath $stack = new EvalMathStack(); foreach ($tokens as $token) { // nice and easy - // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on + // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on $matches = array(); if (in_array($token, array('+', '-', '*', '/', '^'))) { if (is_null($op2 = $stack->pop())) @@ -412,7 +412,7 @@ class EvalMath $fnn = 'log'; eval('$stack->push('.$fnn.'($op1));'); // perfectly safe eval() } elseif (array_key_exists($fnn, $this->f)) { // user function - // get args + // get args $args = array(); for ($i = count($this->f[$fnn]['args']) - 1; $i >= 0; $i--) { if (is_null($args[$this->f[$fnn]['args'][$i]] = $stack->pop())) diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index bffd23f05d2..fc0c4533b7d 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -43,10 +43,10 @@ class Events // extends CommonObject */ public $id; - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) @@ -58,7 +58,7 @@ class Events // extends CommonObject */ public $tms; - /** + /** * @var string Type */ public $type; @@ -94,7 +94,7 @@ class Events // extends CommonObject public $eventstolog = array( array('id'=>'USER_LOGIN', 'test'=>1), array('id'=>'USER_LOGIN_FAILED', 'test'=>1), - array('id'=>'USER_LOGOUT', 'test'=>1), + array('id'=>'USER_LOGOUT', 'test'=>1), array('id'=>'USER_CREATE', 'test'=>1), array('id'=>'USER_MODIFY', 'test'=>1), array('id'=>'USER_NEW_PASSWORD', 'test'=>1), @@ -187,7 +187,7 @@ class Events // extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - public function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { // Clean parameters $this->id = (int) $this->id; @@ -222,7 +222,7 @@ class Events // extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - public function fetch($id, $user = null) + public function fetch($id, $user = null) { $sql = "SELECT"; $sql .= " t.rowid,"; @@ -271,7 +271,7 @@ class Events // extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - public function delete($user) + public function delete($user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."events"; $sql .= " WHERE rowid=".$this->id; @@ -289,13 +289,13 @@ class Events // extends CommonObject /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - public function initAsSpecimen() + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() { $this->id = 0; @@ -306,5 +306,5 @@ class Events // extends CommonObject $this->ip = '1.2.3.4'; $this->user_agent = 'Mozilla specimen User Agent X.Y'; $this->prefix_session = dol_getprefix(); - } + } } diff --git a/htdocs/core/class/extralanguages.class.php b/htdocs/core/class/extralanguages.class.php index a57fa20f510..34c2e34dc82 100644 --- a/htdocs/core/class/extralanguages.class.php +++ b/htdocs/core/class/extralanguages.class.php @@ -28,13 +28,13 @@ class ExtraLanguages { /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** - * @var array New array to store extralanguages definition - */ + * @var array New array to store extralanguages definition + */ public $attributes; /** @@ -47,7 +47,7 @@ class ExtraLanguages */ public $errors = array(); - /** + /** * @var string DB Error number */ public $errno; @@ -57,7 +57,7 @@ class ExtraLanguages * Constructor * * @param DoliDB $db Database handler - */ + */ public function __construct($db) { $this->db = $db; @@ -67,7 +67,7 @@ class ExtraLanguages } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array this->attributes with list of fields per object that need an alternate translation. The object and field must be managed with * the widgetForTranslation() method. @@ -80,7 +80,7 @@ class ExtraLanguages */ public function fetch_name_extralanguages($elementtype, $forceload = false) { - // phpcs:enable + // phpcs:enable global $conf; if (empty($elementtype)) return array(); diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index c941a3a0745..b601994536e 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -176,16 +176,16 @@ class FileUpload ) ); - $hookmanager->executeHooks( - 'overrideUploadOptions', - array( - 'options' => &$options, - 'element' => $element - ), - $object, - $action, - $hookmanager - ); + $hookmanager->executeHooks( + 'overrideUploadOptions', + array( + 'options' => &$options, + 'element' => $element + ), + $object, + $action, + $hookmanager + ); if ($options) { $this->options = array_replace_recursive($this->options, $options); @@ -504,26 +504,26 @@ class FileUpload // param_name is an array identifier like "files[]", // $_FILES is a multi-dimensional array: foreach ($upload['tmp_name'] as $index => $value) { - $info[] = $this->handleFileUpload( - $upload['tmp_name'][$index], - isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], - isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], - isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], - $upload['error'][$index], - $index - ); + $info[] = $this->handleFileUpload( + $upload['tmp_name'][$index], + isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index], + isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index], + isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index], + $upload['error'][$index], + $index + ); } } elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { // param_name is a single object identifier like "file", // $_FILES is a one-dimensional array: - $info[] = $this->handleFileUpload( - isset($upload['tmp_name']) ? $upload['tmp_name'] : null, - isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), - isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), - isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), - isset($upload['error']) ? $upload['error'] : null, - 0 - ); + $info[] = $this->handleFileUpload( + isset($upload['tmp_name']) ? $upload['tmp_name'] : null, + isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : (isset($upload['name']) ? $upload['name'] : null), + isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : (isset($upload['size']) ? $upload['size'] : null), + isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : (isset($upload['type']) ? $upload['type'] : null), + isset($upload['error']) ? $upload['error'] : null, + 0 + ); } header('Vary: Accept'); $json = json_encode($info); diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index c0216f16a19..0e822076641 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -69,25 +69,25 @@ class Fiscalyear extends CommonObject public $label; /** - * Date start (date_start) - * - * @var integer - */ + * Date start (date_start) + * + * @var integer + */ public $date_start; /** - * Date end (date_end) - * - * @var integer - */ + * Date end (date_end) + * + * @var integer + */ public $date_end; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; public $statut; // 0=open, 1=closed @@ -214,11 +214,11 @@ class Fiscalyear extends CommonObject } /** - * Load an object from database - * - * @param int $id Id of record to load - * @return int <0 if KO, >0 if OK - */ + * Load an object from database + * + * @param int $id Id of record to load + * @return int <0 if KO, >0 if OK + */ public function fetch($id) { $sql = "SELECT rowid, label, date_start, date_end, statut"; @@ -245,7 +245,7 @@ class Fiscalyear extends CommonObject } } - /** + /** * Delete record * * @param int $id Id of record to delete diff --git a/htdocs/core/class/genericobject.class.php b/htdocs/core/class/genericobject.class.php index 25f3dc6af11..e27e45de954 100644 --- a/htdocs/core/class/genericobject.class.php +++ b/htdocs/core/class/genericobject.class.php @@ -29,13 +29,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class GenericObject extends CommonObject { - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } } diff --git a/htdocs/core/class/google.class.php b/htdocs/core/class/google.class.php index 117b8e30e02..ee122ff7cb5 100644 --- a/htdocs/core/class/google.class.php +++ b/htdocs/core/class/google.class.php @@ -26,63 +26,63 @@ */ class GoogleAPI { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - public $key; + public $key; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $key Google key - */ - public function __construct($db, $key) - { - $this->db = $db; - $this->key = $key; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $key Google key + */ + public function __construct($db, $key) + { + $this->db = $db; + $this->key = $key; + } - /** - * Return geo coordinates of an address - * - * @param string $address Address - * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France - * Example: 188, rue de Fontenay,+94300,+Vincennes,+France - * @return string Coordinates - */ - public function getGeoCoordinatesOfAddress($address) - { - global $conf; + /** + * Return geo coordinates of an address + * + * @param string $address Address + * Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France + * Example: 188, rue de Fontenay,+94300,+Vincennes,+France + * @return string Coordinates + */ + public function getGeoCoordinatesOfAddress($address) + { + global $conf; - $i = 0; + $i = 0; - // Desired address - $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; + // Desired address + $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; - // Retrieve the URL contents - $page = file_get_contents($urladdress); + // Retrieve the URL contents + $page = file_get_contents($urladdress); - $code = strstr($page, ''); - $code = strstr($code, '>'); - $val = strpos($code, "<"); - $code = substr($code, 1, $val - 1); - //print $code; - //print "
"; - $latitude = substr($code, 0, strpos($code, ",")); - $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); + $code = strstr($page, ''); + $code = strstr($code, '>'); + $val = strpos($code, "<"); + $code = substr($code, 1, $val - 1); + //print $code; + //print "
"; + $latitude = substr($code, 0, strpos($code, ",")); + $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); - // Output the coordinates - //echo "Longitude: $longitude ',' Latitude: $latitude"; + // Output the coordinates + //echo "Longitude: $longitude ',' Latitude: $latitude"; - $i++; - } + $i++; + } } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index dca7c123399..89b5a79df4b 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -144,7 +144,7 @@ class HookManager */ public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { - if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. + if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. $parameters['context'] = join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4a3561149ec..3bdbea18702 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1187,12 +1187,12 @@ class Form // We search companies $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; - if (! empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $sql .= ", s.address, s.zip, s.town"; $sql .= ", dictp.code as country_code"; } $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (! empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays"; } if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -1283,7 +1283,7 @@ class Form if ($obj->client || $obj->fournisseur) $label .= ')'; } - if (! empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $label .= ($obj->address ? ' - '.$obj->address : '').($obj->zip ? ' - '.$obj->zip : '').($obj->town ? ' '.$obj->town : ''); if (!empty($obj->country_code)) { $label .= ', '.$langs->trans('Country'.$obj->country_code); @@ -3566,106 +3566,106 @@ class Form return $return; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load in cache list of transport mode - * - * @return int Nb of lines loaded, <0 if KO - */ - public function load_cache_transport_mode() - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load in cache list of transport mode + * + * @return int Nb of lines loaded, <0 if KO + */ + public function load_cache_transport_mode() + { + // phpcs:enable + global $langs; - $num=count($this->cache_transport_mode); - if ($num > 0) return $num; // Cache already loaded + $num=count($this->cache_transport_mode); + if ($num > 0) return $num; // Cache already loaded - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $this->cache_transport_mode = array(); + $this->cache_transport_mode = array(); - $sql = "SELECT rowid, code, label, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; - $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; - //if ($active >= 0) $sql.= " AND active = ".$active; + $sql = "SELECT rowid, code, label, active"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; + $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; + //if ($active >= 0) $sql.= " AND active = ".$active; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); - // If traduction exist, we use it else we take the default label - $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); - $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; - $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; - $this->cache_transport_mode[$obj->rowid]['label']= $label; - $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; - $i++; - } + // If traduction exist, we use it else we take the default label + $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); + $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; + $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; + $this->cache_transport_mode[$obj->rowid]['label']= $label; + $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; + $i++; + } - $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); + $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); - return $num; - } - else { - dol_print_error($this->db); - return -1; - } - } + return $num; + } + else { + dol_print_error($this->db); + return -1; + } + } - /** - * Return list of transport mode for intracomm report - * - * @param string $selected Id of the transport mode pre-selected - * @param string $htmlname Name of the select field - * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code - * @param int $empty 1=can be empty, 0 else - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info - * @param int $maxlength Max length of label - * @param int $active Active or not, -1 = all - * @param string $morecss Add more CSS on select tag - * @return void - */ - public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') - { - global $langs,$user; + /** + * Return list of transport mode for intracomm report + * + * @param string $selected Id of the transport mode pre-selected + * @param string $htmlname Name of the select field + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code + * @param int $empty 1=can be empty, 0 else + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $maxlength Max length of label + * @param int $active Active or not, -1 = all + * @param string $morecss Add more CSS on select tag + * @return void + */ + public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + { + global $langs,$user; - dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); + dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); - $this->load_cache_transport_mode(); + $this->load_cache_transport_mode(); - print ''; + if ($empty) print ''; + foreach ($this->cache_transport_mode as $id => $arraytypes) + { + // If not good status + if ($active >= 0 && $arraytypes['active'] != $active) continue; - // We discard empty line if showempty is on because an empty line has already been output. - if ($empty && empty($arraytypes['code'])) continue; + // We discard empty line if showempty is on because an empty line has already been output. + if ($empty && empty($arraytypes['code'])) continue; - if ($format == 0) print ''; - } - print ''; - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } + if ($format == 0) print ''; + } + print ''; + if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } /** * Return a HTML select list of shipping mode @@ -4704,40 +4704,40 @@ class Form } } - /** - * Show form with transport mode - * - * @param string $page Page - * @param int $selected Id mode pre-select - * @param string $htmlname Name of select html field - * @param int $active Active or not, -1 = all - * @param int $addempty 1=Add empty entry - * @return void - */ - public function formSelectTransportMode($page, $selected = '', $htmlname = 'transport_mode_id', $active = 1, $addempty = 0) - { - global $langs; - if ($htmlname != "none") - { - print '
'; - print ''; - print ''; - $this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active); - print ''; - print '
'; - } - else { - if ($selected) - { - $this->load_cache_transport_mode(); - print $this->cache_transport_mode[$selected]['label']; - } else { - print " "; - } - } - } + /** + * Show form with transport mode + * + * @param string $page Page + * @param int $selected Id mode pre-select + * @param string $htmlname Name of select html field + * @param int $active Active or not, -1 = all + * @param int $addempty 1=Add empty entry + * @return void + */ + public function formSelectTransportMode($page, $selected = '', $htmlname = 'transport_mode_id', $active = 1, $addempty = 0) + { + global $langs; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + $this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active); + print ''; + print '
'; + } + else { + if ($selected) + { + $this->load_cache_transport_mode(); + print $this->cache_transport_mode[$selected]['label']; + } else { + print " "; + } + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with multicurrency code * @@ -5650,7 +5650,7 @@ class Form if ($d && $h) { $retstring .= ($h == 2 ? '
' : ' '); - $retstring.=''; + $retstring .= ''; } if ($h) @@ -6622,7 +6622,7 @@ class Form templateSelection: formatSelection /* For 4.0 */ }); });'."\n"; - } elseif ($addjscombo == 2 && ! defined('DISABLE_MULTISELECT')) + } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) { // Add other js lib // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index f48e9b8eb74..d6f7b269da1 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -36,26 +36,26 @@ class FormAccounting extends Form private $options_cache = array(); /** - * @var DoliDB Database handler. - */ - public $db; + * @var DoliDB Database handler. + */ + public $db; /** * @var string Error code (or message) */ public $error = ''; - /** + /** * Constructor * * @param DoliDB $db Database handler */ public function __construct($db) { - $this->db = $db; + $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of journals with label by nature * @@ -72,16 +72,16 @@ class FormAccounting extends Form */ public function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $out = ''; - $options = array(); + $options = array(); if ($usecache && !empty($this->options_cache[$usecache])) { - $options = $this->options_cache[$usecache]; - $selected = $selectid; + $options = $this->options_cache[$usecache]; + $selected = $selectid; } else { $sql = "SELECT rowid, code, label, nature, entity, active"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; @@ -99,27 +99,27 @@ class FormAccounting extends Form return -1; } - $selected = 0; + $selected = 0; $langs->load('accountancy'); while ($obj = $this->db->fetch_object($resql)) { $label = $obj->code.' - '.$langs->trans($obj->label); - $select_value_in = $obj->rowid; + $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; // Try to guess if we have found default value - if ($select_in == 1) { - $select_value_in = $obj->code; - } - if ($select_out == 1) { - $select_value_out = $obj->code; - } - // Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid - if ($selectid != '' && $selectid == $select_value_in) { - //var_dump("Found ".$selectid." ".$select_value_in); - $selected = $select_value_out; - } + if ($select_in == 1) { + $select_value_in = $obj->code; + } + if ($select_out == 1) { + $select_value_out = $obj->code; + } + // Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid + if ($selectid != '' && $selectid == $select_value_in) { + //var_dump("Found ".$selectid." ".$select_value_in); + $selected = $select_value_out; + } $options[$select_value_out] = $label; } @@ -136,83 +136,83 @@ class FormAccounting extends Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return list of accounting category. - * Use mysoc->country_id or mysoc->country_code so they must be defined. - * - * @param string $selected Preselected type - * @param string $htmlname Name of field in form - * @param int $useempty Set to 1 if we want an empty value - * @param int $maxlen Max length of text in combo box - * @param int $help Add or not the admin help picto - * @param int $allcountries All countries - * @return void - */ - public function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0) - { - // phpcs:enable - global $db, $langs, $user, $mysoc; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of accounting category. + * Use mysoc->country_id or mysoc->country_code so they must be defined. + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $useempty Set to 1 if we want an empty value + * @param int $maxlen Max length of text in combo box + * @param int $help Add or not the admin help picto + * @param int $allcountries All countries + * @return void + */ + public function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0) + { + // phpcs:enable + global $db, $langs, $user, $mysoc; - if (empty($mysoc->country_id) && empty($mysoc->country_code) && empty($allcountries)) - { - dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); - exit; - } + if (empty($mysoc->country_id) && empty($mysoc->country_code) && empty($allcountries)) + { + dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); + exit; + } - if (!empty($mysoc->country_id)) - { - $sql = "SELECT c.rowid, c.label as type, c.range_account"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; - $sql .= " WHERE c.active = 1"; + if (!empty($mysoc->country_id)) + { + $sql = "SELECT c.rowid, c.label as type, c.range_account"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; + $sql .= " WHERE c.active = 1"; $sql .= " AND c.category_type = 0"; - if (empty($allcountries)) $sql .= " AND c.fk_country = ".$mysoc->country_id; - $sql .= " ORDER BY c.label ASC"; - } else { - $sql = "SELECT c.rowid, c.label as type, c.range_account"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; - $sql .= " WHERE c.active = 1"; + if (empty($allcountries)) $sql .= " AND c.fk_country = ".$mysoc->country_id; + $sql .= " ORDER BY c.label ASC"; + } else { + $sql = "SELECT c.rowid, c.label as type, c.range_account"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; + $sql .= " WHERE c.active = 1"; $sql .= " AND c.category_type = 0"; $sql .= " AND c.fk_country = co.rowid"; - if (empty($allcountries)) $sql .= " AND co.code = '".$this->db->escape($mysoc->country_code)."'"; - $sql .= " ORDER BY c.label ASC"; - } + if (empty($allcountries)) $sql .= " AND co.code = '".$this->db->escape($mysoc->country_code)."'"; + $sql .= " ORDER BY c.label ASC"; + } - dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num) - { - $out = ''; + $i = 0; - if ($useempty) $out .= ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $out .= ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $out .= ''; - } else { - $menuarray[$prefix.'_'.$file] = ''; - } - } - } - closedir($handle); - } - } - } - } + if ($file == $selected) + { + $menuarray[$prefix.'_'.$file] = ''; + } else { + $menuarray[$prefix.'_'.$file] = ''; + } + } + } + closedir($handle); + } + } + } + } ksort($menuarray); // Output combo list of menus - print ''; + $oldprefix = ''; foreach ($menuarray as $key => $val) { $tab = explode('_', $key); @@ -208,7 +208,7 @@ class FormAdmin // Affiche titre print ''; @@ -217,69 +217,69 @@ class FormAdmin print $val."\n"; // Show menu entry } print ''; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return combo list of available menu families - * - * @param string $selected Menu pre-selected - * @param string $htmlname Name of html select - * @param string[] $dirmenuarray Directories to scan - * @return void - */ - public function select_menu_families($selected, $htmlname, $dirmenuarray) - { - // phpcs:enable - global $langs, $conf; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return combo list of available menu families + * + * @param string $selected Menu pre-selected + * @param string $htmlname Name of html select + * @param string[] $dirmenuarray Directories to scan + * @return void + */ + public function select_menu_families($selected, $htmlname, $dirmenuarray) + { + // phpcs:enable + global $langs, $conf; - //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set - $expdevmenu = array(); + //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set + $expdevmenu = array(); $menuarray = array(); foreach ($dirmenuarray as $dirmenu) { - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot.$dirmenu; - if (is_dir($dir)) - { - $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - $filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file); - if (preg_match('/^index/i', $filelib)) continue; - if (preg_match('/^default/i', $filelib)) continue; - if (preg_match('/^empty/i', $filelib)) continue; - if (preg_match('/\.lib/i', $filelib)) continue; - if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue; + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot.$dirmenu; + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file); + if (preg_match('/^index/i', $filelib)) continue; + if (preg_match('/^default/i', $filelib)) continue; + if (preg_match('/^empty/i', $filelib)) continue; + if (preg_match('/\.lib/i', $filelib)) continue; + if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue; - $menuarray[$filelib] = 1; - } - $menuarray['all'] = 1; - } - closedir($handle); - } - } - } + $menuarray[$filelib] = 1; + } + $menuarray['all'] = 1; + } + closedir($handle); + } + } + } } ksort($menuarray); // Affichage liste deroulante des menus - print ''; + $oldprefix = ''; foreach ($menuarray as $key => $val) { $tab = explode('_', $key); $newprefix = $tab[0]; print ''; - $arraytz = array( + $arraytz = array( "Pacific/Midway"=>"GMT-11:00", "Pacific/Fakaofo"=>"GMT-10:00", "America/Anchorage"=>"GMT-09:00", @@ -335,17 +335,17 @@ class FormAdmin "Pacific/Auckland"=>"GMT+12:00", "Pacific/Enderbury"=>"GMT+13:00" ); - foreach ($arraytz as $lib => $gmt) { - print ''."\n"; - } - print ''; - } + foreach ($arraytz as $lib => $gmt) { + print ''."\n"; + } + print ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return html select list with available languages (key='en_US', value='United States' for example) * @@ -365,23 +365,23 @@ class FormAdmin $sql = "SELECT code, label, width, height, unit"; $sql .= " FROM ".MAIN_DB_PREFIX."c_paper_format"; $sql .= " WHERE active=1"; - if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; + if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $unitKey = $langs->trans('SizeUnit'.$obj->unit); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $unitKey = $langs->trans('SizeUnit'.$obj->unit); - $paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey); + $paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey); - $i++; - } - } else { + $i++; + } + } else { dol_print_error($this->db); return ''; } @@ -396,7 +396,7 @@ class FormAdmin } foreach ($paperformat as $key => $value) { - if ($selected == $key) + if ($selected == $key) { $out .= ''; } else { diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index a359bd194f7..9d50a0bb60b 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -31,40 +31,40 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class FormBank { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Retourne la liste des types de comptes financiers - * - * @param integer $selected Type pre-selectionne - * @param string $htmlname Nom champ formulaire - * @return void - */ - public function selectTypeOfBankAccount($selected = Account::TYPE_CURRENT, $htmlname = 'type') - { - $account = new Account($this->db); + /** + * Retourne la liste des types de comptes financiers + * + * @param integer $selected Type pre-selectionne + * @param string $htmlname Nom champ formulaire + * @return void + */ + public function selectTypeOfBankAccount($selected = Account::TYPE_CURRENT, $htmlname = 'type') + { + $account = new Account($this->db); - print Form::selectarray($htmlname, $account->type_lib, $selected); - } + print Form::selectarray($htmlname, $account->type_lib, $selected); + } /** * Returns the name of the Iban label. India uses 'IFSC' and the rest of the world 'IBAN' name. diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index 104daf6de0e..52d4c795c85 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -29,198 +29,198 @@ */ class FormBarCode { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Return HTML select with list of bar code generators - * - * @param int $selected Id code pre-selected - * @param array $barcodelist Array of barcodes generators - * @param int $code_id Id du code barre - * @param int $idForm Id du formulaire - * @return string HTML select string - */ - public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') - { - global $conf, $langs; + /** + * Return HTML select with list of bar code generators + * + * @param int $selected Id code pre-selected + * @param array $barcodelist Array of barcodes generators + * @param int $code_id Id du code barre + * @param int $idForm Id du formulaire + * @return string HTML select string + */ + public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') + { + global $conf, $langs; - $disable = ''; + $disable = ''; - if (!empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - //onChange="barcode_coder_save(\''.$idForm.'\') - } + print ''."\n"; + //onChange="barcode_coder_save(\''.$idForm.'\') + } - // We check if barcode is already selected by default - if (((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) || - (!empty($conf->societe->enabled) && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id)) - { - $disable = 'disabled'; - } + // We check if barcode is already selected by default + if (((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) || + (!empty($conf->societe->enabled) && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id)) + { + $disable = 'disabled'; + } - if (!empty($conf->use_javascript_ajax)) - { - $select_encoder = '
'; - $select_encoder .= ''; - $select_encoder .= ''; - $select_encoder .= ''; - } + if (!empty($conf->use_javascript_ajax)) + { + $select_encoder = ''; + $select_encoder .= ''; + $select_encoder .= ''; + $select_encoder .= ''; + } - $selectname = (!empty($conf->use_javascript_ajax) ? 'coder' : 'coder'.$code_id); - $select_encoder .= ''; + $selectname = (!empty($conf->use_javascript_ajax) ? 'coder' : 'coder'.$code_id); + $select_encoder .= ''; - if (!empty($conf->use_javascript_ajax)) - { - $select_encoder .= '
'; - } + if (!empty($conf->use_javascript_ajax)) + { + $select_encoder .= ''; + } - return $select_encoder; - } + return $select_encoder; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Print form to select type of barcode - * - * @param int $selected Id code pre-selected - * @param string $htmlname Name of HTML select field - * @param int $useempty Affiche valeur vide dans liste - * @return void - * @deprecated - */ - public function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) - { - // phpcs:enable - print $this->selectBarcodeType($selected, $htmlname, $useempty); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Print form to select type of barcode + * + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Affiche valeur vide dans liste + * @return void + * @deprecated + */ + public function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + { + // phpcs:enable + print $this->selectBarcodeType($selected, $htmlname, $useempty); + } - /** - * Return html form to select type of barcode - * - * @param int $selected Id code pre-selected - * @param string $htmlname Name of HTML select field - * @param int $useempty Display empty value in select - * @return string - */ - public function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) - { - global $langs, $conf; + /** + * Return html form to select type of barcode + * + * @param int $selected Id code pre-selected + * @param string $htmlname Name of HTML select field + * @param int $useempty Display empty value in select + * @return string + */ + public function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + { + global $langs, $conf; - $out = ''; + $out = ''; - $sql = "SELECT rowid, code, libelle"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; - $sql .= " WHERE coder <> '0'"; - $sql .= " AND entity = ".$conf->entity; - $sql .= " ORDER BY code"; + $sql = "SELECT rowid, code, libelle"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql .= " WHERE coder <> '0'"; + $sql .= " AND entity = ".$conf->entity; + $sql .= " ORDER BY code"; - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; - if ($useempty && $num > 0) { - $out .= ''; - $out .= ''; - } + if ($useempty && $num > 0) { + $out .= ''; + $out .= ''; + } - while ($i < $num) { - $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid) { - $out .= ''; - $i++; - } - $out .= ""; - $out .= ajax_combobox("select_".$htmlname); - } else { - dol_print_error($this->db); - } - return $out; - } + while ($i < $num) { + $obj = $this->db->fetch_object($result); + if ($selected == $obj->rowid) { + $out .= ''; + $i++; + } + $out .= ""; + $out .= ajax_combobox("select_".$htmlname); + } else { + dol_print_error($this->db); + } + return $out; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Show form to select type of barcode - * - * @param string $page Page - * @param int $selected Id condition preselected - * @param string $htmlname Nom du formulaire select - * @return void - * @deprecated - */ - public function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') - { - // phpcs:enable - print $this->formBarcodeType($page, $selected, $htmlname); - } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show form to select type of barcode + * + * @param string $page Page + * @param int $selected Id condition preselected + * @param string $htmlname Nom du formulaire select + * @return void + * @deprecated + */ + public function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') + { + // phpcs:enable + print $this->formBarcodeType($page, $selected, $htmlname); + } - /** - * Return html form to select type of barcode - * - * @param string $page Page - * @param int $selected Id condition preselected - * @param string $htmlname Nom du formulaire select - * @return string - */ - public function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') - { - global $langs, $conf; - $out = ''; - if ($htmlname != "none") { - $out .= '
'; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= '
'; - $out .= $this->selectBarcodeType($selected, $htmlname, 1); - $out .= ''; - $out .= '
'; - } - return $out; - } + /** + * Return html form to select type of barcode + * + * @param string $page Page + * @param int $selected Id condition preselected + * @param string $htmlname Nom du formulaire select + * @return string + */ + public function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') + { + global $langs, $conf; + $out = ''; + if ($htmlname != "none") { + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
'; + $out .= $this->selectBarcodeType($selected, $htmlname, 1); + $out .= ''; + $out .= '
'; + } + return $out; + } } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index f6e412e0958..ee9e8564933 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -186,13 +186,13 @@ class FormCompany extends Form { global $user, $langs; - print '
'; + print ''; print ''; - print ''; + print ''; dol_syslog(__METHOD__, LOG_DEBUG); $sql = "SELECT code, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_prospectcontactlevel"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); @@ -220,8 +220,8 @@ class FormCompany extends Form print Form::selectarray($htmlname, $options, $selected); } else dol_print_error($this->db); - if (!empty($htmlname) && $user->admin) print ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print ''; + if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ''; print '
'; } diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index b2e32b8c063..7c91c1a4148 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -27,29 +27,29 @@ */ class FormContract { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a combo list with contracts qualified for a third party * @@ -61,9 +61,9 @@ class FormContract * @param int $showRef Show customer and supplier reference on each contract (when found) * @return int Nbr of project if OK, <0 if KO */ - public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) - { - // phpcs:enable + public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) + { + // phpcs:enable global $db, $user, $conf, $langs; $hideunselectables = false; @@ -78,12 +78,12 @@ class FormContract if ($socid > 0) { // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. - if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { - $sql .= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; + if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { + $sql .= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; } elseif ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { - $sql .= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; + $sql .= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; $sql .= " OR c.fk_soc IS NULL)"; - } + } } if ($socid == 0) $sql .= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; $sql .= " ORDER BY c.ref "; @@ -164,30 +164,30 @@ class FormContract dol_print_error($this->db); return -1; } - } + } - /** - * Show a form to select a contract - * - * @param int $page Page - * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) - * @param int $selected Id contract preselected - * @param string $htmlname Nom de la zone html - * @param int $maxlength Maximum length of label - * @param int $showempty Show empty line - * @param int $showRef Show customer and supplier reference on each contract (when found) - * @return int Nbr of project if OK, <0 if KO - */ - public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) - { - global $langs; + /** + * Show a form to select a contract + * + * @param int $page Page + * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) + * @param int $selected Id contract preselected + * @param string $htmlname Nom de la zone html + * @param int $maxlength Maximum length of label + * @param int $showempty Show empty line + * @param int $showRef Show customer and supplier reference on each contract (when found) + * @return int Nbr of project if OK, <0 if KO + */ + public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) + { + global $langs; - print "\n"; - print '
'; - print ''; - print ''; - $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); - print ''; - print '
'; - } + print "\n"; + print '
'; + print ''; + print ''; + $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); + print ''; + print '
'; + } } diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 2701d126331..b6a9140cf58 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -28,75 +28,75 @@ */ class FormCron extends Form { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** - * @var string Error code (or message) - */ - public $error = ''; + /** + * @var string Error code (or message) + */ + public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display On Off selector - * - * @param string $htmlname Html control name - * @param integer $selected selected value - * @param integer $readonly Select is read only or not - * @return string HTML select field - */ - public function select_typejob($htmlname, $selected = 0, $readonly = 0) - { - // phpcs:enable - global $langs; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Display On Off selector + * + * @param string $htmlname Html control name + * @param integer $selected selected value + * @param integer $readonly Select is read only or not + * @return string HTML select field + */ + public function select_typejob($htmlname, $selected = 0, $readonly = 0) + { + // phpcs:enable + global $langs; - $langs->load('cron@cron'); - $out = ''; - if (!empty($readonly)) { - if ($selected == 'command') { - $out = $langs->trans('CronType_command'); - $out .= ''; - } elseif ($selected == 'method') { - $out = $langs->trans('CronType_method'); - $out .= ''; - } - } else { - $out = ''; + $out .= ''; + $out .= ''; + } elseif ($selected == 'method') { + $out = $langs->trans('CronType_method'); + $out .= ''; + } + } else { + $out = ''; - } + $out .= ''; + } - return $out; - } + return $out; + } } diff --git a/htdocs/core/class/html.formexpensereport.class.php b/htdocs/core/class/html.formexpensereport.class.php index 516c6e4b59c..d65f68423b2 100644 --- a/htdocs/core/class/html.formexpensereport.class.php +++ b/htdocs/core/class/html.formexpensereport.class.php @@ -27,111 +27,111 @@ */ class FormExpenseReport { - /** - * @var DoliDB Database handler. - */ - public $db; + /** + * @var DoliDB Database handler. + */ + public $db; - /** + /** * @var string Error code (or message) */ public $error = ''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Retourne la liste deroulante des differents etats d'une note de frais. - * Les valeurs de la liste sont les id de la table c_expensereport_statuts - * - * @param int $selected preselect status - * @param string $htmlname Name of HTML select - * @param int $useempty 1=Add empty line - * @param int $useshortlabel Use short labels - * @return string HTML select with status - */ - public function selectExpensereportStatus($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) - { - global $langs; + /** + * Retourne la liste deroulante des differents etats d'une note de frais. + * Les valeurs de la liste sont les id de la table c_expensereport_statuts + * + * @param int $selected preselect status + * @param string $htmlname Name of HTML select + * @param int $useempty 1=Add empty line + * @param int $useshortlabel Use short labels + * @return string HTML select with status + */ + public function selectExpensereportStatus($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) + { + global $langs; - $tmpep = new ExpenseReport($this->db); + $tmpep = new ExpenseReport($this->db); - print ''; - print ajax_combobox($htmlname); - } + print ''; + print ajax_combobox($htmlname); + } - /** - * Return list of types of notes with select value = id - * - * @param int $selected Preselected type - * @param string $htmlname Name of field in form - * @param int $showempty Add an empty field - * @param int $active 1=Active only, 0=Unactive only, -1=All - * @return string Select html - */ - public function selectTypeExpenseReport($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) - { - // phpcs:enable - global $langs, $user; - $langs->load("trips"); + /** + * Return list of types of notes with select value = id + * + * @param int $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @param int $active 1=Active only, 0=Unactive only, -1=All + * @return string Select html + */ + public function selectTypeExpenseReport($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) + { + // phpcs:enable + global $langs, $user; + $langs->load("trips"); - $out = ''; + $out = ''; - $out .= ''; - $out .= ajax_combobox($htmlname); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $out .= '