diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index f3f3efa572c..2d633debbae 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -32,13 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("errors","admin","companies","resource","holiday","accountancy","hrm")); +$langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "accountancy", "hrm")); -$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; -$confirm=GETPOST('confirm', 'alpha'); -$id=32; -$rowid=GETPOST('rowid', 'alpha'); -$code=GETPOST('code', 'alpha'); +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; +$confirm = GETPOST('confirm', 'alpha'); +$id = 32; +$rowid = GETPOST('rowid', 'alpha'); +$code = GETPOST('code', 'alpha'); // Security access if (empty($user->rights->accounting->chartofaccount)) { @@ -50,15 +50,15 @@ $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); $actl[1] = img_picto($langs->trans("Activated"), 'switch_on'); -$listoffset=GETPOST('listoffset', 'alpha'); -$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000; +$listoffset = GETPOST('listoffset', 'alpha'); +$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000; $active = 1; $sortfield = GETPOST("sortfield", 'aZ09comma'); $sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $listlimit * $page ; +$offset = $listlimit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -71,52 +71,52 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(32); +$taborder = array(32); // Name of SQL tables of dictionaries -$tabname=array(); -$tabname[32]= MAIN_DB_PREFIX."c_accounting_category"; +$tabname = array(); +$tabname[32] = MAIN_DB_PREFIX."c_accounting_category"; // Dictionary labels -$tablib=array(); -$tablib[32]= "DictionaryAccountancyCategory"; +$tablib = array(); +$tablib[32] = "DictionaryAccountancyCategory"; // Requests to extract data -$tabsql=array(); -$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; +$tabsql = array(); +$tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; // Criteria to sort dictionaries -$tabsqlsort=array(); -$tabsqlsort[32]="position ASC"; +$tabsqlsort = array(); +$tabsqlsort[32] = "position ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire -$tabfield=array(); -$tabfield[32]= "code,label,range_account,category_type,formula,position,country"; +$tabfield = array(); +$tabfield[32] = "code,label,range_account,category_type,formula,position,country"; // Nom des champs d'edition pour modification d'un enregistrement -$tabfieldvalue=array(); -$tabfieldvalue[32]= "code,label,range_account,category_type,formula,position,country_id"; +$tabfieldvalue = array(); +$tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id"; // Nom des champs dans la table pour insertion d'un enregistrement -$tabfieldinsert=array(); -$tabfieldinsert[32]= "code,label,range_account,category_type,formula,position,fk_country"; +$tabfieldinsert = array(); +$tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on // "nameoffield" if id field is not "rowid" or has not autoincrement on -$tabrowid=array(); -$tabrowid[32]= ""; +$tabrowid = array(); +$tabrowid[32] = ""; // Condition to show dictionary in setup page -$tabcond=array(); -$tabcond[32]= ! empty($conf->accounting->enabled); +$tabcond = array(); +$tabcond[32] = !empty($conf->accounting->enabled); // List of help for fields -$tabhelp=array(); +$tabhelp = array(); $tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"), 'category_type'=>$langs->trans("SetToYesIfGroupIsComputationOfOtherGroups"), 'formula'=>$langs->trans("EnterCalculationRuleIfPreviousFieldIsYes")); // List of check for fields (NOT USED YET) -$tabfieldcheck=array(); +$tabfieldcheck = array(); $tabfieldcheck[32] = array(); // Complete all arrays with entries found into modules @@ -125,7 +125,7 @@ complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqls // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); -$sourceList=array(); +$sourceList = array(); @@ -141,24 +141,24 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', // Actions add or modify an entry into a dictionary if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { - $listfield=explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert=explode(',', $tabfieldinsert[$id]); - $listfieldmodify=explode(',', $tabfieldinsert[$id]); - $listfieldvalue=explode(',', $tabfieldvalue[$id]); + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); // Check that all fields are filled - $ok=1; + $ok = 1; foreach ($listfield as $f => $value) { if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'range_account' && empty($_POST['range_account'])) continue; if ($value == 'country' || $value == 'country_id') continue; - if (! isset($_POST[$value]) || $_POST[$value]=='') + if (!isset($_POST[$value]) || $_POST[$value] == '') { - $ok=0; - $fieldnamekey=$listfield[$f]; + $ok = 0; + $fieldnamekey = $listfield[$f]; // We take translate key of field - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; @@ -170,23 +170,23 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) } if (isset($_POST["code"])) { - if ($_POST["code"]=='0') + if ($_POST["code"] == '0') { - $ok=0; + $ok = 0; setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); } } - if (! is_numeric(GETPOST('position', 'alpha'))) + if (!is_numeric(GETPOST('position', 'alpha'))) { $langs->loadLangs(array("errors")); - $ok=0; + $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 + 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')) @@ -194,13 +194,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if ($tabrowid[$id]) { // Recupere id libre pour insertion - $newid=0; + $newid = 0; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $result = $db->query($sql); if ($result) { $obj = $db->fetch_object($result); - $newid=($obj->newid + 1); + $newid = ($obj->newid + 1); } else { dol_print_error($db); } @@ -209,32 +209,32 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) $sql.= $tabrowid[$id].","; - $sql.= $tabfieldinsert[$id]; - $sql.=",active)"; - $sql.= " VALUES("; + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].","; + $sql .= $tabfieldinsert[$id]; + $sql .= ",active)"; + $sql .= " VALUES("; // List of values - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) $sql.= $newid.","; - $i=0; + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.","; + $i = 0; foreach ($listfieldinsert as $f => $value) { if ($value == '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]])."'"; + 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)"; + $sql .= ",1)"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); if ($result) // Add is ok { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only + $_POST = array('id'=>$id); // Clean $_POST array, we keep only } else { @@ -250,16 +250,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // Si verif ok et action modify, on modifie la ligne if ($ok && GETPOST('actionmodify', 'alpha')) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; // Modifie valeur des champs - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify)) + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) { - $sql.= $tabrowid[$id]."="; - $sql.= "'".$db->escape($rowid)."', "; + $sql .= $tabrowid[$id]."="; + $sql .= "'".$db->escape($rowid)."', "; } $i = 0; foreach ($listfieldmodify as $field) @@ -270,18 +270,18 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) 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]])."'"; + 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." = '".$rowid."'"; + $sql .= " WHERE ".$rowidcol." = '".$rowid."'"; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); - if (! $resql) + if (!$resql) { setEventMessages($db->error(), null, 'errors'); } @@ -296,14 +296,14 @@ if (GETPOST('actioncancel', 'alpha')) if ($action == 'confirm_delete' && $confirm == 'yes') // delete { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); - if (! $result) + if (!$result) { if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { @@ -319,8 +319,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; @@ -339,8 +339,8 @@ if ($action == $acts[0]) // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; @@ -359,8 +359,8 @@ if ($action == $acts[1]) // favorite if ($action == 'activate_favorite') { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; @@ -379,8 +379,8 @@ if ($action == 'activate_favorite') // disable favorite if ($action == 'disable_favorite') { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; @@ -402,13 +402,13 @@ if ($action == 'disable_favorite') */ $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); llxHeader('', $langs->trans('DictionaryAccountancyCategory')); -$titre=$langs->trans($tablib[$id]); -$linkback=''; -$titlepicto='title_setup'; +$titre = $langs->trans($tablib[$id]); +$linkback = ''; +$titlepicto = 'title_setup'; print load_fiche_titre($titre, $linkback, $titlepicto); @@ -417,7 +417,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); @@ -427,22 +427,22 @@ if ($action == 'delete') if ($id) { // Complete requete recherche valeurs avec critere de tri - $sql=$tabsql[$id]; + $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 (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); + 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 ''; @@ -454,9 +454,9 @@ if ($id) // Form to add a new line if ($tabname[$id]) { - $alabelisused=0; + $alabelisused = 0; - $fieldlist=explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); // Line for title print ''; @@ -464,55 +464,55 @@ if ($id) { // 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') { + $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, '')); + $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); } else { - $valuetoshow=$langs->trans("Type"); + $valuetoshow = $langs->trans("Type"); } } - 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] == 'libelle' || $fieldlist[$field] == 'label') { + $valuetoshow = $langs->trans("Label"); } - if ($fieldlist[$field]=='libelle_facture') { - $valuetoshow=$langs->trans("LabelOnDocuments"); + if ($fieldlist[$field] == 'libelle_facture') { + $valuetoshow = $langs->trans("LabelOnDocuments"); } - if ($fieldlist[$field]=='country') { - $valuetoshow=$langs->trans("Country"); + if ($fieldlist[$field] == 'country') { + $valuetoshow = $langs->trans("Country"); } - if ($fieldlist[$field]=='accountancy_code') { - $valuetoshow=$langs->trans("AccountancyCode"); + if ($fieldlist[$field] == 'accountancy_code') { + $valuetoshow = $langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell') { - $valuetoshow=$langs->trans("AccountancyCodeSell"); + if ($fieldlist[$field] == 'accountancy_code_sell') { + $valuetoshow = $langs->trans("AccountancyCodeSell"); } - if ($fieldlist[$field]=='accountancy_code_buy') { - $valuetoshow=$langs->trans("AccountancyCodeBuy"); + 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] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { + $valuetoshow = $langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='range_account') { - $valuetoshow=$langs->trans("Comment"); + if ($fieldlist[$field] == 'range_account') { + $valuetoshow = $langs->trans("Comment"); } - if ($fieldlist[$field]=='category_type') { - $valuetoshow=$langs->trans("Calculated"); + if ($fieldlist[$field] == 'category_type') { + $valuetoshow = $langs->trans("Calculated"); } if ($valuetoshow != '') { print ''; - if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); else print $valuetoshow; print ''; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; } print ''; @@ -533,14 +533,14 @@ if ($id) foreach ($fieldlist as $key=>$val) { if (GETPOST($val) != '') - $obj->$val=GETPOST($val); + $obj->$val = GETPOST($val); } } $tmpaction = 'create'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; if (empty($reshook)) { @@ -552,42 +552,42 @@ if ($id) print ''; print ""; - $colspan=count($fieldlist)+3; + $colspan = count($fieldlist) + 3; if ($id == 32) $colspan++; - print ' '; // Keep   to have a line with enough height + 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); + $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; + 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'); + 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 ''; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print ''; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); print ''; } // Title line with search boxes print ''; - $filterfound=0; + $filterfound = 0; foreach ($fieldlist as $field => $value) { - $showfield=1; // By defaut + $showfield = 1; // By defaut - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } + if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } if ($showfield) { @@ -610,7 +610,7 @@ if ($id) print ''; if ($filterfound) { - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; } print ''; @@ -622,80 +622,80 @@ if ($id) { // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de donnees - $showfield=1; // By defaut - $class="left"; - $sortable=1; - $valuetoshow=''; + $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"); + $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] == 'price') { + $valuetoshow = $langs->trans("PriceUHT"); } - if ($fieldlist[$field]=='taux') { + if ($fieldlist[$field] == 'taux') { if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") { - $valuetoshow=$langs->trans("Rate"); + $valuetoshow = $langs->trans("Rate"); } else { - $valuetoshow=$langs->trans("Amount"); + $valuetoshow = $langs->trans("Amount"); } - $class='center'; + $class = 'center'; } - if ($fieldlist[$field]=='type') { - $valuetoshow=$langs->trans("Type"); + if ($fieldlist[$field] == 'type') { + $valuetoshow = $langs->trans("Type"); } - 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] == 'libelle' || $fieldlist[$field] == 'label') { + $valuetoshow = $langs->trans("Label"); } - if ($fieldlist[$field]=='country') { - $valuetoshow=$langs->trans("Country"); + if ($fieldlist[$field] == 'country') { + $valuetoshow = $langs->trans("Country"); } - if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { - $showfield=0; + 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') { + $valuetoshow = $langs->trans("AccountancyCode"); } - if ($fieldlist[$field]=='accountancy_code_sell') { - $valuetoshow=$langs->trans("AccountancyCodeSell"); - $sortable=0; + 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] == 'accountancy_code_buy') { + $valuetoshow = $langs->trans("AccountancyCodeBuy"); + $sortable = 0; } - if ($fieldlist[$field]=='fk_pcg_version') { - $valuetoshow=$langs->trans("Pcg_version"); + if ($fieldlist[$field] == 'fk_pcg_version') { + $valuetoshow = $langs->trans("Pcg_version"); } - if ($fieldlist[$field]=='account_parent') { - $valuetoshow=$langs->trans("Accountsparent"); + if ($fieldlist[$field] == 'account_parent') { + $valuetoshow = $langs->trans("Accountsparent"); } - if ($fieldlist[$field]=='pcg_type') { - $valuetoshow=$langs->trans("Pcg_type"); + if ($fieldlist[$field] == 'pcg_type') { + $valuetoshow = $langs->trans("Pcg_type"); } - if ($fieldlist[$field]=='pcg_subtype') { - $valuetoshow=$langs->trans("Pcg_subtype"); + if ($fieldlist[$field] == 'pcg_subtype') { + $valuetoshow = $langs->trans("Pcg_subtype"); } - if ($fieldlist[$field]=='type_template') { - $valuetoshow=$langs->trans("TypeOfTemplate"); + if ($fieldlist[$field] == 'type_template') { + $valuetoshow = $langs->trans("TypeOfTemplate"); } - if ($fieldlist[$field]=='range_account') { - $valuetoshow=$langs->trans("Comment"); + if ($fieldlist[$field] == 'range_account') { + $valuetoshow = $langs->trans("Comment"); } - if ($fieldlist[$field]=='category_type') { - $valuetoshow=$langs->trans("Calculated"); + 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($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($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print getTitleFieldOfList(''); @@ -709,12 +709,12 @@ if ($id) $obj = $db->fetch_object($resql); //print_r($obj); print ''; - if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { - $tmpaction='edit'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; // Show fields if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit'); @@ -725,7 +725,7 @@ if ($id) print ''; print ''; print ''; - print '
'; + print '
'; print ''; print ''; print ''; @@ -733,71 +733,71 @@ if ($id) 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 + $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]}; + $showfield = 1; + $class = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; if ($value == 'category_type') { $valuetoshow = yn($valuetoshow); } - elseif ($valuetoshow=='all') { - $valuetoshow=$langs->trans('All'); + elseif ($valuetoshow == 'all') { + $valuetoshow = $langs->trans('All'); } - elseif ($fieldlist[$field]=='country') { + elseif ($fieldlist[$field] == 'country') { if (empty($obj->country_code)) { - $valuetoshow='-'; + $valuetoshow = '-'; } else { - $key=$langs->trans("Country".strtoupper($obj->country_code)); - $valuetoshow=($key != "Country".strtoupper($obj->country_code)?$obj->country_code." - ".$key:$obj->country); + $key = $langs->trans("Country".strtoupper($obj->country_code)); + $valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country); } } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_country') { - $key=$langs->trans("Country".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_country') { + $key = $langs->trans("Country".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') { + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_availability') { $langs->loadLangs(array("propal")); - $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') { - $key=$langs->trans("Action".strtoupper($obj->code)); - $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_actioncomm') { + $key = $langs->trans("Action".strtoupper($obj->code)); + $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$fieldlist[$field]}); } - elseif ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { - $showfield=0; + elseif ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { + $showfield = 0; } - $class='tddict'; + $class = 'tddict'; // Show value for field if ($showfield) print ''.$valuetoshow.''; } } // Can an entry be erased or disabled ? - $iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default + $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):''); + $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 .= '&'; // Active print ''; @@ -865,38 +865,38 @@ $db->close(); */ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $context = '') { - global $conf,$langs,$db; + global $conf, $langs, $db; global $form, $mysoc; global $region_id; - global $elementList,$sourceList,$localtax_typeList; + global $elementList, $sourceList, $localtax_typeList; global $bc; $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); - if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); + if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); foreach ($fieldlist as $field => $value) { if ($fieldlist[$field] == 'country') { print ''; - $fieldname='country'; + $fieldname = 'country'; if ($context == 'add') { - $fieldname='country_id'; + $fieldname = 'country_id'; print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); } else { - print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:$mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); } print ''; } elseif ($fieldlist[$field] == 'country_id') { - if (! in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) + if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate) { - $country_id = (! empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); + $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); print ''; print ''; print ''; @@ -904,21 +904,21 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co } elseif ($fieldlist[$field] == 'category_type') { print ''; - print $form->selectyesno($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), 1); + print $form->selectyesno($fieldlist[$field], (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''), 1); print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { - print ''; + print ''; } else { print ''; - $size=''; $class=''; - if ($fieldlist[$field]=='code') $class='maxwidth100'; - if ($fieldlist[$field]=='position') $class='maxwidth50'; - if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent'; - if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='category_type') $size='size="2" '; - print ''; + $size = ''; $class = ''; + if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; + if ($fieldlist[$field] == 'position') $class = 'maxwidth50'; + if ($fieldlist[$field] == 'libelle') $class = 'quatrevingtpercent'; + if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'category_type') $size = 'size="2" '; + print ''; print ''; } } diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 885795ca437..6ddee1d147f 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -30,12 +30,12 @@ require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","admin","accountancy","salaries","loan")); +$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "loan")); // Security check if (empty($user->rights->accounting->chartofaccount)) @@ -97,12 +97,12 @@ if (GETPOST('change_chart', 'alpha')) { $chartofaccounts = GETPOST('chartofaccounts', 'int'); - if (! empty($chartofaccounts)) { - if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!empty($chartofaccounts)) { + if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { + $error++; } } else { - $error ++; + $error++; } } @@ -153,8 +153,8 @@ print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_a print ''.$langs->trans("DefaultBindingDesc").'
'; print '
'; -print ''; -print ''; +print ''; +print ''; print ''; @@ -166,14 +166,14 @@ foreach ($list_account_main as $key) { print ''; // Param $label = $langs->trans($key); - $keydesc=$key.'_Desc'; + $keydesc = $key.'_Desc'; $htmltext = $langs->trans($keydesc); print ''; print $form->textwithpicto($label, $htmltext); print ''; // Value - print ''; // Do not force class=right, or it align also the content of the select box + print ''; // Do not force class=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print ''; print ''; @@ -211,7 +211,7 @@ foreach ($list_account as $key) { print "\n"; -print '
'; +print '
'; print '
'; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index b0eaff04494..7c834c56ad2 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -32,13 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","compta","accountancy")); +$langs->loadLangs(array("admin", "compta", "accountancy")); -$action=GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; -$confirm=GETPOST('confirm', 'alpha'); -$id=35; -$rowid=GETPOST('rowid', 'alpha'); -$code=GETPOST('code', 'alpha'); +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; +$confirm = GETPOST('confirm', 'alpha'); +$id = 35; +$rowid = GETPOST('rowid', 'alpha'); +$code = GETPOST('code', 'alpha'); // Security access if (empty($user->rights->accounting->chartofaccount)) @@ -51,19 +51,19 @@ $acts[1] = "disable"; $actl[0] = img_picto($langs->trans("Disabled"), 'switch_off'); $actl[1] = img_picto($langs->trans("Activated"), 'switch_on'); -$listoffset=GETPOST('listoffset', 'alpha'); -$listlimit=GETPOST('listlimit', 'int')>0?GETPOST('listlimit', 'int'):1000; +$listoffset = GETPOST('listoffset', 'alpha'); +$listlimit = GETPOST('listlimit', 'int') > 0 ?GETPOST('listlimit', 'int') : 1000; $active = 1; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $listlimit * $page ; +$offset = $listlimit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (empty($sortfield)) $sortfield='code'; -if (empty($sortorder)) $sortorder='ASC'; +if (empty($sortfield)) $sortfield = 'code'; +if (empty($sortorder)) $sortorder = 'ASC'; $error = 0; @@ -74,52 +74,52 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(35); +$taborder = array(35); // Name of SQL tables of dictionaries -$tabname=array(); -$tabname[35]= MAIN_DB_PREFIX."accounting_journal"; +$tabname = array(); +$tabname[35] = MAIN_DB_PREFIX."accounting_journal"; // Dictionary labels -$tablib=array(); -$tablib[35]= "DictionaryAccountancyJournal"; +$tablib = array(); +$tablib[35] = "DictionaryAccountancyJournal"; // Requests to extract data -$tabsql=array(); -$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a"; +$tabsql = array(); +$tabsql[35] = "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a"; // Criteria to sort dictionaries -$tabsqlsort=array(); -$tabsqlsort[35]="code ASC"; +$tabsqlsort = array(); +$tabsqlsort[35] = "code ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire -$tabfield=array(); -$tabfield[35]= "code,label,nature"; +$tabfield = array(); +$tabfield[35] = "code,label,nature"; // Nom des champs d'edition pour modification d'un enregistrement -$tabfieldvalue=array(); -$tabfieldvalue[35]= "code,label,nature"; +$tabfieldvalue = array(); +$tabfieldvalue[35] = "code,label,nature"; // Nom des champs dans la table pour insertion d'un enregistrement -$tabfieldinsert=array(); -$tabfieldinsert[35]= "code,label,nature"; +$tabfieldinsert = array(); +$tabfieldinsert[35] = "code,label,nature"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on // "nameoffield" if id field is not "rowid" or has not autoincrement on -$tabrowid=array(); -$tabrowid[35]= ""; +$tabrowid = array(); +$tabrowid[35] = ""; // Condition to show dictionary in setup page -$tabcond=array(); -$tabcond[35]= ! empty($conf->accounting->enabled); +$tabcond = array(); +$tabcond[35] = !empty($conf->accounting->enabled); // List of help for fields -$tabhelp=array(); +$tabhelp = array(); $tabhelp[35] = array('code'=>$langs->trans("EnterAnyCode")); // List of check for fields (NOT USED YET) -$tabfieldcheck=array(); +$tabfieldcheck = array(); $tabfieldcheck[35] = array(); // Complete all arrays with entries found into modules @@ -151,25 +151,25 @@ if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', // Actions add or modify an entry into a dictionary if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { - $listfield=explode(',', str_replace(' ', '', $tabfield[$id])); - $listfieldinsert=explode(',', $tabfieldinsert[$id]); - $listfieldmodify=explode(',', $tabfieldinsert[$id]); - $listfieldvalue=explode(',', $tabfieldvalue[$id]); + $listfield = explode(',', str_replace(' ', '', $tabfield[$id])); + $listfieldinsert = explode(',', $tabfieldinsert[$id]); + $listfieldmodify = explode(',', $tabfieldinsert[$id]); + $listfieldvalue = explode(',', $tabfieldvalue[$id]); // Check that all fields are filled - $ok=1; + $ok = 1; foreach ($listfield as $f => $value) { - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; if ($fieldnamekey == 'nature') $fieldnamekey = 'NatureOfJournal'; } // Other checks if (isset($_POST["code"])) { - if ($_POST["code"]=='0') + if ($_POST["code"] == '0') { - $ok=0; + $ok = 0; setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); } /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base @@ -178,16 +178,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } - if (! GETPOST('label', 'alpha')) + if (!GETPOST('label', 'alpha')) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $ok=0; + $ok = 0; } // 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 + 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')) @@ -195,13 +195,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if ($tabrowid[$id]) { // Recupere id libre pour insertion - $newid=0; + $newid = 0; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $result = $db->query($sql); if ($result) { $obj = $db->fetch_object($result); - $newid=($obj->newid + 1); + $newid = ($obj->newid + 1); } else { dol_print_error($db); } @@ -210,34 +210,34 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // 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,entity)"; - $sql.= " VALUES("; + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) + $sql .= $tabrowid[$id].","; + $sql .= $tabfieldinsert[$id]; + $sql .= ",active,entity)"; + $sql .= " VALUES("; // List of values - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldinsert)) - $sql.= $newid.","; - $i=0; + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) + $sql .= $newid.","; + $i = 0; foreach ($listfieldinsert as $f => $value) { if ($value == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } - if ($i) $sql.=","; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + if ($i) $sql .= ","; + if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } - $sql.=",1,".$conf->entity.")"; + $sql .= ",1,".$conf->entity.")"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); if ($result) // Add is ok { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); - $_POST=array('id'=>$id); // Clean $_POST array, we keep only + $_POST = array('id'=>$id); // Clean $_POST array, we keep only } else { @@ -253,16 +253,16 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // Si verif ok et action modify, on modifie la ligne if ($ok && GETPOST('actionmodify', 'alpha')) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; // Modifie valeur des champs - if ($tabrowid[$id] && ! in_array($tabrowid[$id], $listfieldmodify)) + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) { - $sql.= $tabrowid[$id]."="; - $sql.= "'".$db->escape($rowid)."', "; + $sql .= $tabrowid[$id]."="; + $sql .= "'".$db->escape($rowid)."', "; } $i = 0; foreach ($listfieldmodify as $field) @@ -273,19 +273,19 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) elseif ($field == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } - if ($i) $sql.=","; - $sql.= $field."="; - if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' - else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + if ($i) $sql .= ","; + $sql .= $field."="; + if ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = '' + else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } - $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - $sql.=" AND entity = ".$conf->entity; + $sql .= " WHERE ".$rowidcol." = '".$rowid."'"; + $sql .= " AND entity = ".$conf->entity; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); - if (! $resql) + if (!$resql) { setEventMessages($db->error(), null, 'errors'); } @@ -300,15 +300,15 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) 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."='".$rowid."'"; - $sql.=" AND entity = ".$conf->entity; + $sql .= " AND entity = ".$conf->entity; dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); - if (! $result) + if (!$result) { if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { @@ -324,8 +324,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete // activate if ($action == $acts[0]) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'"; @@ -333,7 +333,7 @@ if ($action == $acts[0]) elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'"; } - $sql.=" AND entity = ".$conf->entity; + $sql .= " AND entity = ".$conf->entity; $result = $db->query($sql); if (!$result) @@ -345,8 +345,8 @@ if ($action == $acts[0]) // disable if ($action == $acts[1]) { - if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } - else { $rowidcol="rowid"; } + if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } + else { $rowidcol = "rowid"; } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'"; @@ -354,7 +354,7 @@ if ($action == $acts[1]) elseif ($code) { $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'"; } - $sql.=" AND entity = ".$conf->entity; + $sql .= " AND entity = ".$conf->entity; $result = $db->query($sql); if (!$result) @@ -369,16 +369,16 @@ if ($action == $acts[1]) */ $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); llxHeader(); -$titre=$langs->trans("DictionarySetup"); -$linkback=''; +$titre = $langs->trans("DictionarySetup"); +$linkback = ''; if ($id) { - $titre.=' - '.$langs->trans($tablib[$id]); - $titlepicto='title_accountancy'; + $titre .= ' - '.$langs->trans($tablib[$id]); + $titlepicto = 'title_accountancy'; } print load_fiche_titre($titre, $linkback, $titlepicto); @@ -387,7 +387,7 @@ print load_fiche_titre($titre, $linkback, $titlepicto); // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } //var_dump($elementList); @@ -397,15 +397,15 @@ if ($action == 'delete') if ($id) { // Complete requete recherche valeurs avec critere de tri - $sql=$tabsql[$id]; - $sql.= " WHERE a.entity = ".$conf->entity; + $sql = $tabsql[$id]; + $sql .= " WHERE a.entity = ".$conf->entity; // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.=$db->order($sortfield, $sortorder); - $sql.=$db->plimit($listlimit+1, $offset); + if ($sortfield == 'country') $sortfield = 'country_code'; + $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($listlimit + 1, $offset); - $fieldlist=explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); print '
'; print ''; @@ -417,9 +417,9 @@ if ($id) // Form to add a new line if ($tabname[$id]) { - $alabelisused=0; + $alabelisused = 0; - $fieldlist=explode(',', $tabfield[$id]); + $fieldlist = explode(',', $tabfield[$id]); // Line for title print ''; @@ -427,27 +427,27 @@ if ($id) { // 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]=='code') { - $valuetoshow=$langs->trans("Code"); + $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]=='libelle' || $fieldlist[$field]=='label') { - $valuetoshow=$langs->trans("Label"); + 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 ''; - 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]); + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); else print $valuetoshow; print ''; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; } print ''; @@ -468,14 +468,14 @@ if ($id) foreach ($fieldlist as $key=>$val) { if (GETPOST($val) != '') - $obj->$val=GETPOST($val); + $obj->$val = GETPOST($val); } } $tmpaction = 'create'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; if (empty($reshook)) { @@ -487,31 +487,31 @@ if ($id) print ''; print ""; - print ' '; // Keep   to have a line with enough height + 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); + $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; + 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'); + 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 ''; - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); + print ''; + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); print ''; } @@ -536,10 +536,10 @@ if ($id) { // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de donnees - $showfield=1; // By defaut - $class="left"; - $sortable=1; - $valuetoshow=''; + $showfield = 1; // By defaut + $class = "left"; + $sortable = 1; + $valuetoshow = ''; /* $tmparray=getLabelOfField($fieldlist[$field]); $showfield=$tmp['showfield']; @@ -547,24 +547,24 @@ if ($id) $align=$tmp['align']; $sortable=$tmp['sortable']; */ - $valuetoshow=ucfirst($fieldlist[$field]); // By defaut - $valuetoshow=$langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field]=='code') { - $valuetoshow=$langs->trans("Code"); + $valuetoshow = ucfirst($fieldlist[$field]); // By defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { - $valuetoshow=$langs->trans("Label"); + 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"); } // 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($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($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print getTitleFieldOfList(''); @@ -578,12 +578,12 @@ if ($id) $obj = $db->fetch_object($resql); //print_r($obj); print ''; - if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code))) + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { - $tmpaction='edit'; - $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook=$hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error=$hookmanager->error; $errors=$hookmanager->errors; + $tmpaction = 'edit'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; // Show fields if (empty($reshook)) fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit'); @@ -593,44 +593,44 @@ if ($id) print ''; print ''; 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 + $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)) { $langs->load("accountancy"); foreach ($fieldlist as $field => $value) { - $showfield=1; - $class="left"; - $valuetoshow=$obj->{$fieldlist[$field]}; - if ($valuetoshow=='all') { - $valuetoshow=$langs->trans('All'); + $showfield = 1; + $class = "left"; + $valuetoshow = $obj->{$fieldlist[$field]}; + if ($valuetoshow == 'all') { + $valuetoshow = $langs->trans('All'); } - elseif ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') { - $key=$langs->trans("AccountingJournalType".strtoupper($obj->nature)); - $valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature))?$key:$obj->{$fieldlist[$field]}); + elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { + $key = $langs->trans("AccountingJournalType".strtoupper($obj->nature)); + $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); + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { + $valuetoshow = $langs->trans($obj->label); } - $class='tddict'; + $class = 'tddict'; // Show value for field if ($showfield) print ''.$valuetoshow.''; } } // Can an entry be erased or disabled ? - $iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default + $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; @@ -644,11 +644,11 @@ if ($id) } } - $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):''); + $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 .= '&'; // Active print ''; @@ -708,10 +708,10 @@ $db->close(); */ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '') { - global $conf,$langs,$db; + global $conf, $langs, $db; global $form, $mysoc; global $region_id; - global $elementList,$sourceList,$localtax_typeList; + global $elementList, $sourceList, $localtax_typeList; global $bc; $formadmin = new FormAdmin($db); @@ -722,20 +722,20 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '') if ($fieldlist[$field] == 'nature') { print ''; - print $form->selectarray('nature', $sourceList, (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')); + print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { - print ''; + print ''; } else { print ''; - $size=''; $class=''; - if ($fieldlist[$field]=='code') $class='maxwidth100'; - if ($fieldlist[$field]=='label') $class='quatrevingtpercent'; - if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; - print ''; + $size = ''; $class = ''; + if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; + if ($fieldlist[$field] == 'label') $class = 'quatrevingtpercent'; + if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" '; + print ''; print ''; } } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 8374e20803c..d898be2b208 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -25,14 +25,14 @@ * \brief List operation of book keeping */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy")); @@ -107,12 +107,12 @@ $formaccounting = new FormAccounting($db); $formother = new FormOther($db); $form = new Form($db); -if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && ! GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) +if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !isset($_POST['begin']) && !isset($_GET['begin']) && !isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) { - if (empty($search_date_start) && empty($search_date_end) && ! GETPOSTISSET('restore_lastsearch_values')) + if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values')) { $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; + $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; $res = $db->query($query); if ($res->num_rows > 0) { @@ -155,7 +155,7 @@ $arrayfields = array( if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); -$listofformat=AccountancyExport::getType(); +$listofformat = AccountancyExport::getType(); $formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV; if (empty($listofformat[$formatexportset])) $formatexportset = 1; @@ -351,7 +351,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme } // Make a redirect to avoid to launch the delete later after a back button - header("Location: list.php".($param?'?'.$param:'')); + header("Location: list.php".($param ? '?'.$param : '')); exit; } else @@ -372,15 +372,15 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); } - header("Location: list.php?noreset=1".($param?'&'.$param:'')); + header("Location: list.php?noreset=1".($param ? '&'.$param : '')); exit; } } if ($action == 'setreexport') { $setreexport = GETPOST('value', 'int'); - if (! dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++; - if (! $error) { + if (!$error) { if ($conf->global->ACCOUNTING_REEXPORT == 1) { setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); } else { @@ -421,27 +421,27 @@ $sql .= " t.piece_num,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification,"; $sql .= " t.date_export"; -$sql .= ' FROM ' . MAIN_DB_PREFIX . $object->table_element . ' as t'; +$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; // Manage filter -$sqlwhere = array (); +$sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { if ($key == 't.doc_date') { - $sqlwhere[] = $key . '=\'' . $db->idate($value) . '\''; + $sqlwhere[] = $key.'=\''.$db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { - $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$db->idate($value).'\''; } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { - $sqlwhere[] = $key . '\'' . $db->escape($value) . '\''; + $sqlwhere[] = $key.'\''.$db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { - $sqlwhere[] = $key . '=' . $value; + $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key . ' LIKE \'' . $db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \''.$db->escape($value).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { - $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$db->idate($value).'\''; } elseif ($key == 't.tms>=' || $key == 't.tms<=') { - $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { - $sqlwhere[] = $key . '\'' . $db->idate($value) . '\''; + $sqlwhere[] = $key.'\''.$db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } else { @@ -449,14 +449,14 @@ if (count($filter) > 0) { } } } -$sql.= ' WHERE t.entity IN (' . getEntity('accountancy') . ')'; +$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')'; if ($conf->global->ACCOUNTING_REEXPORT == 0) { $sql .= " AND t.date_export IS NULL"; } if (count($sqlwhere) > 0) { - $sql .= ' AND ' . implode(' AND ', $sqlwhere); + $sql .= ' AND '.implode(' AND ', $sqlwhere); } -if (! empty($sortfield)) { +if (!empty($sortfield)) { $sql .= $db->order($sortfield, $sortorder); } //print $sql; @@ -478,14 +478,14 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { $accountancyexport = new AccountancyExport($db); $accountancyexport->export($object->lines, $formatexportset); - if (! empty($accountancyexport->errors)) + if (!empty($accountancyexport->errors)) { setEventMessages('', $accountancyexport->errors, 'errors'); } else { // Specify as export : update field date_export - $error=0; + $error = 0; $db->begin(); if (is_array($object->lines)) @@ -494,13 +494,13 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { { $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); + dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); $result = $db->query($sql); - if (! $result) + if (!$result) { $error++; break; @@ -508,7 +508,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { } } - if (! $error) + if (!$error) { $db->commit(); // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); @@ -550,10 +550,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -574,7 +574,7 @@ if ($action == 'delmouv') { print $formconfirm; } if ($action == 'delbookkeepingyear') { - $form_question = array (); + $form_question = array(); $delyear = GETPOST('delyear'); $deljournal = GETPOST('deljournal'); @@ -604,10 +604,10 @@ if ($action == 'delbookkeepingyear') { } //$param=''; param started before -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; -print ''; +print ''; print ''; print ''; if ($optioncss != '') print ''; @@ -620,27 +620,27 @@ if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); else $buttonLabel = $langs->trans("ExportList"); // Button re-export -if (! empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton =''.img_picto($langs->trans("Activated"), 'switch_on').' '; +if (!empty($conf->global->ACCOUNTING_REEXPORT)) { + $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").''; +$newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; -$newcardbutton.= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:''), $user->rights->accounting->mouvements->export); +$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); -$newcardbutton.= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); +$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); -$newcardbutton.= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create', '', $user->rights->accounting->mouvements->creer); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); -$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); +$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); -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -720,111 +720,111 @@ if (!empty($arrayfields['t.subledger_account']['checked'])) print ''; } // Label operation -if (! empty($arrayfields['t.label_operation']['checked'])) +if (!empty($arrayfields['t.label_operation']['checked'])) { print ''; - print ''; + print ''; print ''; } // Debit -if (! empty($arrayfields['t.debit']['checked'])) +if (!empty($arrayfields['t.debit']['checked'])) { print ''; print ''; print ''; } // Credit -if (! empty($arrayfields['t.credit']['checked'])) +if (!empty($arrayfields['t.credit']['checked'])) { print ''; print ''; print ''; } // Lettering code -if (! empty($arrayfields['t.lettering_code']['checked'])) +if (!empty($arrayfields['t.lettering_code']['checked'])) { print ''; - print ''; + print ''; print ''; } // Code journal -if (! empty($arrayfields['t.code_journal']['checked'])) +if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; } // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['t.date_creation']['checked'])) +if (!empty($arrayfields['t.date_creation']['checked'])) { print ''; print '
'; - print $langs->trans('From') . ' '; + print $langs->trans('From').' '; print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1); print '
'; print '
'; - print $langs->trans('to') . ' '; + print $langs->trans('to').' '; print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1); print '
'; print ''; } // Date modification -if (! empty($arrayfields['t.tms']['checked'])) +if (!empty($arrayfields['t.tms']['checked'])) { print ''; print '
'; - print $langs->trans('From') . ' '; + print $langs->trans('From').' '; print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1); print '
'; print '
'; - print $langs->trans('to') . ' '; + print $langs->trans('to').' '; print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1); print '
'; print ''; } // Date export -if (! empty($arrayfields['t.date_export']['checked'])) +if (!empty($arrayfields['t.date_export']['checked'])) { print ''; print '
'; - print $langs->trans('From') . ' '; + print $langs->trans('From').' '; print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1); print '
'; print '
'; - print $langs->trans('to') . ' '; + print $langs->trans('to').' '; print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1); print '
'; print ''; } // Action column print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; print "\n"; print ''; -if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -833,12 +833,12 @@ $line = new BookKeepingLine(); // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen $line->id = $obj->rowid; $line->doc_date = $db->jdate($obj->doc_date); @@ -1006,8 +1006,8 @@ print ''; // TODO Replace this with mass delete action if ($user->rights->accounting->mouvements->supprimer_tous) { - print '
' . "\n"; - print '' . $langs->trans("DeleteMvt") . ''; + print '
'."\n"; + print ''.$langs->trans("DeleteMvt").''; print '
'; } diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 7e8f14f2a53..f36b98b15b1 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -31,7 +31,7 @@ * \brief Class accountancy export */ -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; /** * Manage the different format accountancy export @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; class AccountancyExport { // Type of export. Used into $conf->global->ACCOUNTING_EXPORT_MODELCSV - public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV + public static $EXPORT_TYPE_CONFIGURABLE = 1; // CSV public static $EXPORT_TYPE_AGIRIS = 10; public static $EXPORT_TYPE_EBP = 15; public static $EXPORT_TYPE_CEGID = 20; @@ -83,7 +83,7 @@ class AccountancyExport $this->db = &$db; $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE)?"\n":($conf->global->ACCOUNTING_EXPORT_ENDLINE==1?"\n":"\r\n"); + $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n"); } /** @@ -125,7 +125,7 @@ class AccountancyExport */ private static function getFormatCode($type) { - $formatcode = array ( + $formatcode = array( self::$EXPORT_TYPE_CONFIGURABLE => 'csv', self::$EXPORT_TYPE_CEGID => 'cegid', self::$EXPORT_TYPE_COALA => 'coala', @@ -153,14 +153,14 @@ class AccountancyExport { global $conf, $langs; - return array ( + return array( 'param' => array( self::$EXPORT_TYPE_CONFIGURABLE => array( 'label' => $langs->trans('Modelcsv_configurable'), - 'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT)?'txt':$conf->global->ACCOUNTING_EXPORT_FORMAT, - 'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV)?',':$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV, - 'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE)?1:$conf->global->ACCOUNTING_EXPORT_ENDLINE, - 'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE)?'%d%m%Y':$conf->global->ACCOUNTING_EXPORT_DATE, + 'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ? 'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT, + 'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ? ',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV, + 'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE, + 'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE) ? '%d%m%Y' : $conf->global->ACCOUNTING_EXPORT_DATE, ), self::$EXPORT_TYPE_CEGID => array( 'label' => $langs->trans('Modelcsv_CEGID'), @@ -209,11 +209,11 @@ class AccountancyExport 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), ), - 'cr'=> array ( + 'cr'=> array( '1' => $langs->trans("Unix"), '2' => $langs->trans("Windows") ), - 'format' => array ( + 'format' => array( 'csv' => $langs->trans("csv"), 'txt' => $langs->trans("txt") ), @@ -231,13 +231,13 @@ class AccountancyExport public function export(&$TData, $formatexportset) { global $conf, $langs; - global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php + global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php // Define name of file to save $filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $type_export = 'general_ledger'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; switch ($formatexportset) { @@ -303,13 +303,13 @@ class AccountancyExport $separator = ";"; $end_line = "\n"; - print $date . $separator; - print $line->code_journal . $separator; - print length_accountg($line->numero_compte) . $separator; - print length_accounta($line->subledger_account) . $separator; - print $line->sens . $separator; - print price($line->montant) . $separator; - print $line->label_operation . $separator; + print $date.$separator; + print $line->code_journal.$separator; + print length_accountg($line->numero_compte).$separator; + print length_accounta($line->subledger_account).$separator; + print $line->sens.$separator; + print price($line->montant).$separator; + print $line->label_operation.$separator; print $line->doc_ref; print $end_line; } @@ -328,22 +328,22 @@ class AccountancyExport $separator = ";"; $end_line = "\n"; - print $line->code_journal . $separator; - print $date . $separator; - print $line->piece_num . $separator; - print length_accountg($line->numero_compte) . $separator; - print '' . $separator; - print $line->label_operation . $separator; - print $date . $separator; - if ($line->sens=='D') { - print price($line->montant) . $separator; - print '' . $separator; - }elseif ($line->sens=='C') { - print '' . $separator; - print price($line->montant) . $separator; + print $line->code_journal.$separator; + print $date.$separator; + print $line->piece_num.$separator; + print length_accountg($line->numero_compte).$separator; + print ''.$separator; + print $line->label_operation.$separator; + print $date.$separator; + if ($line->sens == 'D') { + print price($line->montant).$separator; + print ''.$separator; + }elseif ($line->sens == 'C') { + print ''.$separator; + print price($line->montant).$separator; } - print $line->doc_ref . $separator; - print $line->label_operation . $separator; + print $line->doc_ref.$separator; + print $line->label_operation.$separator; print $end_line; } } @@ -362,15 +362,15 @@ class AccountancyExport foreach ($objectLines as $line) { $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $separator; - print $line->code_journal . $separator; - print length_accountg($line->numero_compte) . $separator; - print $line->piece_num . $separator; - print $line->doc_ref . $separator; - print price($line->debit) . $separator; - print price($line->credit) . $separator; - print 'E' . $separator; - print length_accountg($line->subledger_account) . $separator; + print $date.$separator; + print $line->code_journal.$separator; + print length_accountg($line->numero_compte).$separator; + print $line->piece_num.$separator; + print $line->doc_ref.$separator; + print price($line->debit).$separator; + print price($line->credit).$separator; + print 'E'.$separator; + print length_accountg($line->subledger_account).$separator; print $end_line; } } @@ -389,26 +389,26 @@ class AccountancyExport $end_line = "\n"; foreach ($objectLines as $line) { - print $line->piece_num . $separator; + print $line->piece_num.$separator; $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $separator; + print $date.$separator; if (empty($line->subledger_account)) { - print 'G' . $separator; - print length_accounta($line->numero_compte) . $separator; + print 'G'.$separator; + print length_accounta($line->numero_compte).$separator; } else { if (substr($line->numero_compte, 0, 3) == '411') { - print 'C' . $separator; + print 'C'.$separator; } if (substr($line->numero_compte, 0, 3) == '401') { - print 'F' . $separator; + print 'F'.$separator; } - print length_accountg($line->subledger_account) . $separator; + print length_accountg($line->subledger_account).$separator; } - print price($line->debit) . $separator; - print price($line->credit) . $separator; - print dol_trunc($line->label_operation, 32) . $separator; + print price($line->debit).$separator; + print price($line->credit).$separator; + print dol_trunc($line->label_operation, 32).$separator; print $end_line; } } @@ -423,23 +423,23 @@ class AccountancyExport { global $conf; - $end_line ="\r\n"; + $end_line = "\r\n"; $i = 1; $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd foreach ($TData as $data) { $code_compta = $data->numero_compte; - if (! empty($data->subledger_account)) + if (!empty($data->subledger_account)) $code_compta = $data->subledger_account; - $Tab = array (); + $Tab = array(); $Tab['num_ecriture'] = str_pad($i, 5); $Tab['code_journal'] = str_pad($data->code_journal, 2); $Tab['date_ecriture'] = $date_ecriture; $Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); - $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . dol_string_unaccent($data->label_operation), 25), 25); + $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25); $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); $Tab['type_montant'] = str_pad($data->sens, 1); $Tab['vide'] = str_repeat(' ', 18); @@ -449,7 +449,7 @@ class AccountancyExport $Tab['end_line'] = $end_line; print implode($Tab); - $i ++; + $i++; } } @@ -463,17 +463,17 @@ class AccountancyExport { global $conf; - $end_line ="\r\n"; + $end_line = "\r\n"; //We should use dol_now function not time however this is wrong date to transfert in accounting //$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy //$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy foreach ($TData as $data) { $code_compta = $data->numero_compte; - if (! empty($data->subledger_account)) + if (!empty($data->subledger_account)) $code_compta = $data->subledger_account; - $Tab = array (); + $Tab = array(); $Tab['type_ligne'] = 'M'; $Tab['num_compte'] = str_pad(self::trunc($code_compta, 8), 8); $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2); @@ -484,19 +484,19 @@ class AccountancyExport //$Tab['date_ecriture'] = $date_ecriture; $Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y'); $Tab['filler'] = ' '; - $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 20), 20); + $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20); $Tab['sens'] = $data->sens; // C or D $Tab['signe_montant'] = '+'; //elarifr le montant doit etre en centimes sans point decimal ! - $Tab['montant'] = str_pad(abs($data->montant*100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount + $Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount // $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount $Tab['contrepartie'] = str_repeat(' ', 8); // elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting - if (! empty($data->date_echeance)) + if (!empty($data->date_echeance)) //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); - $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy + $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy else $Tab['date_echeance'] = '000000'; @@ -551,20 +551,20 @@ class AccountancyExport foreach ($objectLines as $line) { $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $line->id . $separator; - print $date . $separator; - print $line->code_journal . $separator; + print $line->id.$separator; + print $date.$separator; + print $line->code_journal.$separator; if (empty($line->subledger_account)) { - print $line->numero_compte . $separator; + print $line->numero_compte.$separator; } else { - print $line->subledger_account . $separator; + 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->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; print price2num(abs($line->montant)).$separator; print $line->sens.$separator; - print $date . $separator; + print $date.$separator; //print 'EUR'; print $end_line; } @@ -586,25 +586,25 @@ class AccountancyExport foreach ($objectLines as $line) { $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $line->piece_num . $separator; - print self::toAnsi($line->label_operation) . $separator; - print $date . $separator; - print self::toAnsi($line->label_operation) . $separator; + print $line->piece_num.$separator; + print self::toAnsi($line->label_operation).$separator; + print $date.$separator; + print self::toAnsi($line->label_operation).$separator; if (empty($line->subledger_account)) { - print length_accountg($line->numero_compte) . $separator; - print self::toAnsi($line->label_compte) . $separator; + print length_accountg($line->numero_compte).$separator; + print self::toAnsi($line->label_compte).$separator; } else { - print length_accounta($line->subledger_account) . $separator; - print self::toAnsi($line->subledger_label) . $separator; + print length_accounta($line->subledger_account).$separator; + print self::toAnsi($line->subledger_label).$separator; } - print self::toAnsi($line->doc_ref) . $separator; - print price($line->debit) . $separator; - print price($line->credit) . $separator; - print price($line->montant) . $separator; - print $line->sens . $separator; - print $line->lettering_code . $separator; + print self::toAnsi($line->doc_ref).$separator; + print price($line->debit).$separator; + print price($line->credit).$separator; + print price($line->montant).$separator; + print $line->sens.$separator; + print $line->lettering_code.$separator; print $line->code_journal; print $end_line; } @@ -625,17 +625,17 @@ class AccountancyExport foreach ($objectLines as $line) { $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - print $date . $separator; - print $line->code_journal . $separator; + print $date.$separator; + print $line->code_journal.$separator; if (empty($line->subledger_account)) { - print length_accountg($line->numero_compte) . $separator; + print length_accountg($line->numero_compte).$separator; } else { - print length_accounta($line->subledger_account) . $separator; + 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 $line->doc_ref.$separator; + print $line->label_operation.$separator; + print price($line->debit).$separator; + print price($line->credit).$separator; print $end_line; } @@ -668,7 +668,7 @@ class AccountancyExport $tab[] = price2num($line->montant); $tab[] = $line->code_journal; - print implode($separator, $tab) . $this->end_line; + print implode($separator, $tab).$this->end_line; } } @@ -683,23 +683,23 @@ class AccountancyExport $separator = "\t"; $end_line = "\n"; - print "JournalCode" . $separator; - print "JournalLib" . $separator; - print "EcritureNum" . $separator; - print "EcritureDate" . $separator; - print "CompteNum" . $separator; - print "CompteLib" . $separator; - print "CompAuxNum" . $separator; - print "CompAuxLib" . $separator; - print "PieceRef" . $separator; - print "PieceDate" . $separator; - print "EcritureLib" . $separator; - print "Debit" . $separator; - print "Credit" . $separator; - print "EcritureLet" . $separator; - print "DateLet" . $separator; - print "ValidDate" . $separator; - print "Montantdevise" . $separator; + print "JournalCode".$separator; + print "JournalLib".$separator; + print "EcritureNum".$separator; + print "EcritureDate".$separator; + print "CompteNum".$separator; + print "CompteLib".$separator; + print "CompAuxNum".$separator; + print "CompAuxLib".$separator; + print "PieceRef".$separator; + print "PieceDate".$separator; + print "EcritureLib".$separator; + print "Debit".$separator; + print "Credit".$separator; + print "EcritureLet".$separator; + print "DateLet".$separator; + print "ValidDate".$separator; + print "Montantdevise".$separator; print "Idevise"; print $end_line; @@ -709,55 +709,55 @@ class AccountancyExport $date_valid = dol_print_date($line->date_validated, '%d%m%Y'); // FEC:JournalCode - print $line->code_journal . $separator; + print $line->code_journal.$separator; // FEC:JournalLib - print $line->journal_label . $separator; + print $line->journal_label.$separator; // FEC:EcritureNum - print $line->piece_num . $separator; + print $line->piece_num.$separator; // FEC:EcritureDate - print $date_creation . $separator; + print $date_creation.$separator; // FEC:CompteNum - print $line->numero_compte . $separator; + print $line->numero_compte.$separator; // FEC:CompteLib - print $line->label_compte . $separator; + print $line->label_compte.$separator; // FEC:CompAuxNum - print $line->subledger_account . $separator; + print $line->subledger_account.$separator; // FEC:CompAuxLib - print $line->subledger_label . $separator; + print $line->subledger_label.$separator; // FEC:PieceRef - print $line->doc_ref . $separator; + print $line->doc_ref.$separator; // FEC:PieceDate - print $date_doc . $separator; + print $date_doc.$separator; // FEC:EcritureLib - print $line->label_operation . $separator; + print $line->label_operation.$separator; // FEC:Debit - print price2num($line->debit) . $separator; + print price2num($line->debit).$separator; // FEC:Credit - print price2num($line->credit) . $separator; + print price2num($line->credit).$separator; // FEC:EcritureLet - print $line->lettering_code . $separator; + print $line->lettering_code.$separator; // FEC:DateLet - print $line->date_lettering . $separator; + print $line->date_lettering.$separator; // FEC:ValidDate - print $date_valid . $separator; + print $date_valid.$separator; // FEC:Montantdevise - print $line->multicurrency_amount . $separator; + print $line->multicurrency_amount.$separator; // FEC:Idevise print $line->multicurrency_code; @@ -785,121 +785,121 @@ class AccountancyExport // 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); + $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 = false; + if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) { - $sammelBuchung= true; + $sammelBuchung = true; } - elseif ($aIndex+2 < $aSize && $objectLines[$aIndex+2]->piece_num == $line->piece_num) + elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) { - $sammelBuchung= true; + $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 + 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 = true; } //Blg - print $line->piece_num . $this->separator; + print $line->piece_num.$this->separator; // Datum $date = dol_print_date($line->doc_date, '%d.%m.%Y'); - print $date . $this->separator; + print $date.$this->separator; // Kto - print length_accountg($line->numero_compte) . $this->separator; + print length_accountg($line->numero_compte).$this->separator; // S/H if ($line->sens == 'D') { - print 'S' . $this->separator; + print 'S'.$this->separator; } else { - print 'H' . $this->separator; + print 'H'.$this->separator; } //Grp - print self::trunc($line->code_journal, 1) . $this->separator; + 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; + print length_accounta($thisPieceAccountNr).$this->separator; } else { - print "div" . $this->separator; + print "div".$this->separator; } } else { - print length_accounta($line->code_tiers) . $this->separator; + print length_accounta($line->code_tiers).$this->separator; } //SId print $this->separator; //SIdx - print "0" . $this->separator; + print "0".$this->separator; //KIdx - print "0" . $this->separator; + print "0".$this->separator; //BTyp - print "0" . $this->separator; + print "0".$this->separator; //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung if ($sammelBuchung) { - print "2" . $this->separator; + print "2".$this->separator; } else { - print "1" . $this->separator; + print "1".$this->separator; } // Code - print '""' . $this->separator; + print '""'.$this->separator; // Netto if ($line->montant >= 0) { - print $line->montant . $this->separator; + print $line->montant.$this->separator; } else { - print $line->montant*-1 . $this->separator; + print ($line->montant * -1).$this->separator; } // Steuer - print "0.00" . $this->separator; + print "0.00".$this->separator; // FW-Betrag - print "0.00" . $this->separator; + print "0.00".$this->separator; // Tx1 - $line1= self::toAnsi($line->label_compte, 29); + $line1 = self::toAnsi($line->label_compte, 29); if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) { - $line1= ""; + $line1 = ""; } - $line2= self::toAnsi($line->doc_ref, 29); + $line2 = self::toAnsi($line->doc_ref, 29); if (strlen($line1) == 0) { - $line1= $line2; - $line2= ""; + $line1 = $line2; + $line2 = ""; } if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) { - $line1= $line1 . ' / ' . $line2; - $line2= ""; + $line1 = $line1.' / '.$line2; + $line2 = ""; } - print '"' . self::toAnsi($line1). '"' . $this->separator; + print '"'.self::toAnsi($line1).'"'.$this->separator; // Tx2 - print '"' . self::toAnsi($line2). '"' . $this->separator; + print '"'.self::toAnsi($line2).'"'.$this->separator; //PkKey - print "0" . $this->separator; + print "0".$this->separator; //OpId print $this->separator; @@ -910,8 +910,8 @@ class AccountancyExport if ($line->piece_num !== $thisPieceNum) { - $thisPieceNum= $line->piece_num; - $thisPieceAccountNr= $line->numero_compte; + $thisPieceNum = $line->piece_num; + $thisPieceAccountNr = $line->numero_compte; } } } @@ -932,23 +932,23 @@ class AccountancyExport foreach ($objectLines as $line) { $date_document = dol_print_date($line->doc_date, '%Y%m%d'); - $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); // TYPE $type_enregistrement = 'E'; // For write movement - print $type_enregistrement . $separator; + print $type_enregistrement.$separator; // JNAL - print substr($line->code_journal, 0, 2) . $separator; + print substr($line->code_journal, 0, 2).$separator; // NECR - print $line->id . $separator; + print $line->id.$separator; // NPIE - print $line->piece_num . $separator; + print $line->piece_num.$separator; // DATP - print $date_document . $separator; + print $date_document.$separator; // LIBE - print $line->label_operation . $separator; + print $line->label_operation.$separator; // DATH - print $line->date_lim_reglement . $separator; + print $line->date_lim_reglement.$separator; // CNPI if ($line->doc_type == 'supplier_invoice') { if ($line->montant < 0) { @@ -965,7 +965,7 @@ class AccountancyExport } else { $nature_piece = ''; } - print $nature_piece . $separator; + print $nature_piece.$separator; // RACI /* if (! empty($line->subledger_account)) { @@ -983,28 +983,28 @@ class AccountancyExport */ print $separator; // deprecated CPTG & CPTA use instead // MONT - print price(abs($line->montant), 0, '', 1, 2) . $separator; + print price(abs($line->montant), 0, '', 1, 2).$separator; // CODC - print $line->sens . $separator; + print $line->sens.$separator; // CPTG - print length_accountg($line->numero_compte) . $separator; + print length_accountg($line->numero_compte).$separator; // DATE - print $date_creation . $separator; + print $date_creation.$separator; // CLET - print $line->lettering_code . $separator; + print $line->lettering_code.$separator; // DATL - print $line->date_lettering . $separator; + print $line->date_lettering.$separator; // CPTA - if (! empty($line->subledger_account)) { - print length_accounta($line->subledger_account) . $separator; + if (!empty($line->subledger_account)) { + print length_accounta($line->subledger_account).$separator; } else { print $separator; } // CNAT - if ($line->doc_type == 'supplier_invoice' && ! empty($line->subledger_account)) { - print 'F' . $separator; - } elseif ($line->doc_type == 'customer_invoice' && ! empty($line->subledger_account)) { - print 'C' . $separator; + if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) { + print 'F'.$separator; + } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) { + print 'C'.$separator; } else { print $separator; } @@ -1017,17 +1017,17 @@ class AccountancyExport // DATV print $separator; // REFD - print $line->doc_ref . $separator; + print $line->doc_ref.$separator; // CODH print $separator; // NSEQ print $separator; // MTDV - print '0' . $separator; + print '0'.$separator; // CODV print $separator; // TXDV - print '0' . $separator; + print '0'.$separator; // MOPM print $separator; // BONP @@ -1066,43 +1066,43 @@ class AccountancyExport /* * Charlemagne export need header */ - print $langs->transnoentitiesnoconv('Date') . $separator; - print self::trunc($langs->transnoentitiesnoconv('Journal'), 6) . $separator; - print self::trunc($langs->transnoentitiesnoconv('Account'), 15) . $separator; - print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60) . $separator; - print self::trunc($langs->transnoentitiesnoconv('Piece'), 20) . $separator; - print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60) . $separator; - print $langs->transnoentitiesnoconv('Amount') . $separator; - print 'S' . $separator; - print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 1', 15) . $separator; - print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 1', 60) . $separator; - print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 2', 15) . $separator; - print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 2', 60) . $separator; - print self::trunc($langs->transnoentitiesnoconv('Analytic') . ' 3', 15) . $separator; - print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel') . ' 3', 60) . $separator; + print $langs->transnoentitiesnoconv('Date').$separator; + print self::trunc($langs->transnoentitiesnoconv('Journal'), 6).$separator; + print self::trunc($langs->transnoentitiesnoconv('Account'), 15).$separator; + print self::trunc($langs->transnoentitiesnoconv('LabelAccount'), 60).$separator; + print self::trunc($langs->transnoentitiesnoconv('Piece'), 20).$separator; + print self::trunc($langs->transnoentitiesnoconv('LabelOperation'), 60).$separator; + print $langs->transnoentitiesnoconv('Amount').$separator; + print 'S'.$separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic').' 1', 15).$separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 1', 60).$separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic').' 2', 15).$separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 2', 60).$separator; + print self::trunc($langs->transnoentitiesnoconv('Analytic').' 3', 15).$separator; + print self::trunc($langs->transnoentitiesnoconv('AnalyticLabel').' 3', 60).$separator; print $end_line; - foreach($objectLines as $line) { + foreach ($objectLines as $line) { $date = dol_print_date($line->doc_date, '%Y%m%d'); - print $date . $separator; //Date + print $date.$separator; //Date - print self::trunc($line->code_journal, 6) . $separator; //Journal code + print self::trunc($line->code_journal, 6).$separator; //Journal code - if(!empty($line->subledger_account)) $account = $line->subledger_account; + if (!empty($line->subledger_account)) $account = $line->subledger_account; else $account = $line->numero_compte; - print self::trunc($account, 15) . $separator;//Account number + print self::trunc($account, 15).$separator; //Account number - print self::trunc($line->label_compte, 60) . $separator;//Account label - print self::trunc($line->doc_ref, 20) . $separator;//Piece - print self::trunc($line->label_operation, 60) . $separator;//Operation label - print price(abs($line->montant)) . $separator;//Amount - print $line->sens . $separator;//Direction - print $separator;//Analytic - print $separator;//Analytic - print $separator;//Analytic - print $separator;//Analytic - print $separator;//Analytic - print $separator;//Analytic + print self::trunc($line->label_compte, 60).$separator; //Account label + print self::trunc($line->doc_ref, 20).$separator; //Piece + print self::trunc($line->label_operation, 60).$separator; //Operation label + print price(abs($line->montant)).$separator; //Amount + print $line->sens.$separator; //Direction + print $separator; //Analytic + print $separator; //Analytic + print $separator; //Analytic + print $separator; //Analytic + print $separator; //Analytic + print $separator; //Analytic print $end_line; } } @@ -1129,10 +1129,10 @@ class AccountancyExport */ public static function toAnsi($str, $size = -1) { - $retVal= dol_string_nohtmltag($str, 1, 'Windows-1251'); + $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251'); if ($retVal >= 0 && $size >= 0) { - $retVal= mb_substr($retVal, 0, $size, 'Windows-1251'); + $retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); } return $retVal; } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index a80036b3b05..1fbed52b9e3 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -29,17 +29,17 @@ * \brief Page with expense reports journal */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page -$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","trips","errors")); +$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "trips", "errors")); $id_journal = GETPOST('id_journal', 'int'); $action = GETPOST('action', 'aZ09'); @@ -75,13 +75,13 @@ $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { $pastmonth = 12; - $pastmonthyear --; + $pastmonthyear--; } $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form +if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); @@ -91,62 +91,62 @@ $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; -$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; -$sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; -$sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author"; +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; +$sql .= " JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport"; +$sql .= " JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author"; $sql .= " WHERE er.fk_statut > 0"; $sql .= " AND erd.fk_code_ventilation > 0"; -$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy +$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy if ($date_start && $date_end) - $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; + $sql .= " AND er.date_debut >= '".$db->idate($date_start)."' AND er.date_debut <= '".$db->idate($date_end)."'"; // 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"; dol_syslog('accountancy/journal/expensereportsjournal.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { - $taber = array (); - $tabht = array (); - $tabtva = array (); - $def_tva = array (); - $tabttc = array (); - $tablocaltax1 = array (); - $tablocaltax2 = array (); - $tabuser = array (); + $taber = array(); + $tabht = array(); + $tabtva = array(); + $def_tva = array(); + $tabttc = array(); + $tablocaltax1 = array(); + $tablocaltax2 = array(); + $tabuser = array(); $num = $db->num_rows($result); // Variables - $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'; - $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; + $account_salary = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'; + $account_vat = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; $i = 0; - while ( $i < $num ) { + while ($i < $num) { $obj = $db->fetch_object($result); // Controls - $compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; + $compta_user = (!empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; $compta_fees = $obj->compte; - $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); - $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat); - $compta_localtax1 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); - $compta_localtax2 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); + $compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $account_vat); + $compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); + $compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); // Define array to display all VAT rates that use this accounting account $compta_tva - if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) + if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) { - $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); } $taber[$obj->rowid]["date"] = $db->jdate($obj->de); @@ -155,24 +155,24 @@ if ($result) { $taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid; // Avoid warnings - if (! isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0; - if (! isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0; - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; - if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; - if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; + if (!isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0; + if (!isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0; + if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc; $tabht[$obj->rowid][$compta_fees] += $obj->total_ht; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; - $tabuser[$obj->rowid] = array ( + $tabuser[$obj->rowid] = array( 'id' => $obj->uid, 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname), 'user_accountancy_code' => $obj->user_accountancy_account ); - $i ++; + $i++; } } else { dol_print_error($db); @@ -193,7 +193,7 @@ if ($action == 'writebookkeeping') { $db->begin(); // Thirdparty - if (! $errorforline) + if (!$errorforline) { foreach ($tabttc[$key] as $k => $mt) { if ($mt) { @@ -244,7 +244,7 @@ if ($action == 'writebookkeeping') { } // Fees - if (! $errorforline) + if (!$errorforline) { foreach ($tabht[$key] as $k => $mt) { if ($mt) { @@ -295,10 +295,10 @@ if ($action == 'writebookkeeping') { } // VAT - if (! $errorforline) + if (!$errorforline) { - $listoftax=array(0, 1, 2); - foreach($listoftax as $numtax) + $listoftax = array(0, 1, 2); + foreach ($listoftax as $numtax) { $arrayofvat = $tabtva; if ($numtax == 1) $arrayofvat = $tablocaltax1; @@ -362,7 +362,7 @@ if ($action == 'writebookkeeping') { setEventMessages('Try to insert a non balanced transaction in book for '.$val["ref"].'. Canceled. Surely a bug.', null, 'errors'); } - if (! $errorforline) + if (!$errorforline) { $db->commit(); } @@ -373,7 +373,7 @@ if ($action == 'writebookkeeping') { if ($error >= 10) { setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); - break; // Break in the foreach + break; // Break in the foreach } } } @@ -392,21 +392,21 @@ if ($action == 'writebookkeeping') { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - $action=''; + $action = ''; // Must reload data, so we make a redirect if (count($tabpay) != $error) { - $param='id_journal='.$id_journal; - $param.='&date_startday='.$date_startday; - $param.='&date_startmonth='.$date_startmonth; - $param.='&date_startyear='.$date_startyear; - $param.='&date_endday='.$date_endday; - $param.='&date_endmonth='.$date_endmonth; - $param.='&date_endyear='.$date_endyear; - $param.='&in_bookkeeping='.$in_bookkeeping; + $param = 'id_journal='.$id_journal; + $param .= '&date_startday='.$date_startday; + $param .= '&date_startmonth='.$date_startmonth; + $param .= '&date_startyear='.$date_startyear; + $param .= '&date_endday='.$date_endday; + $param .= '&date_endmonth='.$date_endmonth; + $param .= '&date_endyear='.$date_endyear; + $param .= '&in_bookkeeping='.$in_bookkeeping; - header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); exit; } } @@ -426,15 +426,15 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $filename = 'journal'; $type_export = 'journal'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; // CSV header line - print '"' . $langs->transnoentitiesnoconv("Date") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Piece") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("AccountAccounting") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("LabelOperation") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Debit") . '"' . $sep; - print '"' . $langs->transnoentitiesnoconv("Credit") . '"' . $sep; + print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Piece").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("LabelOperation").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Debit").'"'.$sep; + print '"'.$langs->transnoentitiesnoconv("Credit").'"'.$sep; print "\n"; foreach ($taber as $key => $val) { @@ -486,18 +486,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if (empty($action) || $action == 'view') { llxHeader('', $langs->trans("ExpenseReportsJournal")); - $nom = $langs->trans("ExpenseReportsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); + $nom = $langs->trans("ExpenseReportsJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); $nomlink = ''; $periodlink = ''; $exportlink = ''; - $builddate=dol_now(); - $description.= $langs->trans("DescJournalOnlyBindedVisible").'
'; + $builddate = dol_now(); + $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; - $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); - $varlink = 'id_journal=' . $id_journal; + $varlink = 'id_journal='.$id_journal; journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); @@ -508,13 +508,13 @@ if (empty($action) || $action == 'view') { } print '
'; - if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { - print ''; + print ''; } else { - if ($in_bookkeeping == 'notyet') print ''; - else print '' . $langs->trans("WriteBookKeeping") . ''; + if ($in_bookkeeping == 'notyet') print ''; + else print ''.$langs->trans("WriteBookKeeping").''; } print '
'; @@ -543,13 +543,13 @@ if (empty($action) || $action == 'view') { print '
'; print ""; print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print '"; - print '"; + print ""; + print ""; + print ""; + print ""; + print ""; + print '"; + print '"; print "\n"; $r = ''; @@ -572,8 +572,8 @@ if (empty($action) || $action == 'view') { if ($mt) { print ''; print ""; - print ""; - print ""; + print ""; + print ""; $userstatic->id = $tabuser[$key]['id']; $userstatic->name = $tabuser[$key]['name']; // Account @@ -590,9 +590,9 @@ if (empty($action) || $action == 'view') { print ''; $userstatic->id = $tabuser[$key]['id']; $userstatic->name = $tabuser[$key]['name']; - print ""; - print '"; - print '"; + print ""; + print '"; + print '"; print ""; } } @@ -604,8 +604,8 @@ if (empty($action) || $action == 'view') { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; - print ""; - print '"; - print '"; + print ""; + print '"; + print '"; print ""; } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 711a54f37a6..4d4368ede62 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -29,17 +29,17 @@ * \brief Page with purchases journal */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page -$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors")); +$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors")); $id_journal = GETPOST('id_journal', 'int'); $action = GETPOST('action', 'aZ09'); @@ -60,12 +60,12 @@ if ($user->socid > 0) accessforbidden(); $hookmanager->initHooks(array('purchasesjournal')); -$parameters=array(); +$parameters = array(); /* * Actions */ -$reshook=$hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks $accountingaccount = new AccountingAccount($db); @@ -80,13 +80,13 @@ $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { $pastmonth = 12; - $pastmonthyear --; + $pastmonthyear--; } $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form +if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); @@ -96,53 +96,53 @@ $sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_sup $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; -$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; -$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; +$sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; +$sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0"; $sql .= " AND fd.fk_code_ventilation > 0"; -$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; +$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")"; } if ($date_start && $date_end) - $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; + $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; // Already in bookkeeping or not if ($in_bookkeeping == 'already') { - $sql .= " AND f.rowid IN (SELECT fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; + $sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; } 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='supplier_invoice')"; + $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; } $sql .= " ORDER BY f.datef"; dol_syslog('accountancy/journal/purchasesjournal.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { - $tabfac = array (); - $tabht = array (); - $tabtva = array (); - $def_tva = array (); - $tabttc = array (); - $tablocaltax1 = array (); - $tablocaltax2 = array (); - $tabcompany = array (); + $tabfac = array(); + $tabht = array(); + $tabtva = array(); + $def_tva = array(); + $tabttc = array(); + $tablocaltax1 = array(); + $tablocaltax2 = array(); + $tabcompany = array(); $tabother = array(); $num = $db->num_rows($result); // Variables $cptfour = ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'; - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; + $cpttva = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : 'NotDefined'; $i = 0; - while ( $i < $num ) { + while ($i < $num) { $obj = $db->fetch_object($result); // Controls @@ -151,21 +151,21 @@ if ($result) { $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) - $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; + $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; else - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; + $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; } - $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); - $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); - $compta_localtax1 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); - $compta_localtax2 = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); - $compta_counterpart_tva_npr = (! empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined'; + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); + $compta_tva = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); + $compta_localtax1 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); + $compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); + $compta_counterpart_tva_npr = (!empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined'; // Define array to display all VAT rates that use this accounting account $compta_tva - if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) + if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) { - $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); } $line = new SupplierInvoiceLine($db); @@ -173,31 +173,31 @@ if ($result) { $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); $tabfac[$obj->rowid]["datereg"] = $db->jdate($obj->dlr); - $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; + $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier.' ('.$obj->ref.')'; $tabfac[$obj->rowid]["refsologest"] = $obj->ref; $tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier; $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->description; - $tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries) + $tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries) //$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; // Avoid warnings - if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; - if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; - if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; - if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; + if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; + if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; + if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; - if (! empty($line->tva_npr)) // Add an entry for counterpart + if (!empty($line->tva_npr)) // Add an entry for counterpart { $tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva; } $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2; - $tabcompany[$obj->rowid] = array ( + $tabcompany[$obj->rowid] = array( 'id' => $obj->socid, 'name' => $obj->name, 'code_fournisseur' => $obj->code_fournisseur, @@ -215,16 +215,16 @@ $errorforinvoice = array(); // Loop in invoices to detect lines with not binding lines foreach ($tabfac as $key => $val) { // Loop on each invoice $sql = "SELECT COUNT(fd.rowid) as nb"; - $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; - $sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0"; - $sql.= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; + $sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0"; + $sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj->nb > 0) { - $errorforinvoice[$key]='somelinesarenotbound'; + $errorforinvoice[$key] = 'somelinesarenotbound'; } } else dol_print_error($db); @@ -271,7 +271,7 @@ if ($action == 'writebookkeeping') { if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) { $replacedinvoice = 1; - $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. + $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. if ($alreadydispatched) $replacedinvoice = 2; } @@ -291,7 +291,7 @@ if ($action == 'writebookkeeping') { } // Thirdparty - if (! $errorforline) + if (!$errorforline) { foreach ($tabttc[$key] as $k => $mt) { $bookkeeping = new BookKeeping($db); @@ -473,7 +473,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; @@ -497,14 +497,14 @@ if ($action == 'writebookkeeping') { { $error++; $errorforline++; - $errorforinvoice[$key]='alreadyjournalized'; + $errorforinvoice[$key] = 'alreadyjournalized'; //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { $error++; $errorforline++; - $errorforinvoice[$key]='other'; + $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } @@ -513,15 +513,15 @@ if ($action == 'writebookkeeping') { } // Protection against a bug on lines before - if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit))) + if (!$errorforline && (price2num($totaldebit) != price2num($totalcredit))) { $error++; $errorforline++; - $errorforinvoice[$key]='amountsnotbalanced'; + $errorforinvoice[$key] = 'amountsnotbalanced'; setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors'); } - if (! $errorforline) + if (!$errorforline) { $db->commit(); } @@ -532,7 +532,7 @@ if ($action == 'writebookkeeping') { if ($error >= 10) { setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); - break; // Break in the foreach + break; // Break in the foreach } } } @@ -551,20 +551,20 @@ if ($action == 'writebookkeeping') { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - $action=''; + $action = ''; // Must reload data, so we make a redirect if (count($tabpay) != $error) { - $param='id_journal='.$id_journal; - $param.='&date_startday='.$date_startday; - $param.='&date_startmonth='.$date_startmonth; - $param.='&date_startyear='.$date_startyear; - $param.='&date_endday='.$date_endday; - $param.='&date_endmonth='.$date_endmonth; - $param.='&date_endyear='.$date_endyear; - $param.='&in_bookkeeping='.$in_bookkeeping; - header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); + $param = 'id_journal='.$id_journal; + $param .= '&date_startday='.$date_startday; + $param .= '&date_startmonth='.$date_startmonth; + $param .= '&date_startyear='.$date_startyear; + $param .= '&date_endday='.$date_endday; + $param .= '&date_endmonth='.$date_endmonth; + $param .= '&date_endyear='.$date_endyear; + $param .= '&in_bookkeeping='.$in_bookkeeping; + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); exit; } } @@ -581,7 +581,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $filename = 'journal'; $type_export = 'journal'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; $companystatic = new Fournisseur($db); $invoicestatic = new FactureFournisseur($db); @@ -610,7 +610,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) { $replacedinvoice = 1; - $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. + $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. if ($alreadydispatched) $replacedinvoice = 2; } @@ -623,18 +623,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! // Third party foreach ($tabttc[$key] as $k => $mt) { //if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["refsologest"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)). '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("Thirdparty") . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Thirdparty") . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep; - print '"' . $journal . '"' ; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["refsologest"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$langs->trans("Thirdparty").'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("Thirdparty").'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; //} } @@ -644,18 +644,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k, true); //if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["refsologest"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '""' . $sep; - print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep; - print '"' . $journal . '"' ; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["refsologest"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '""'.$sep; + print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; //} } @@ -669,18 +669,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["refsologest"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '""' . $sep; - print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep; - print '"' . $journal . '"' ; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["refsologest"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '""'.$sep; + print '"'.$langs->trans("VAT").' - '.$def_tva[$key].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; } } @@ -690,18 +690,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! { foreach ($tabother[$key] as $k => $mt) { if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["refsologest"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)). '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("Thirdparty") . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . ' NPR"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep; - print '"' . $journal . '"' ; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["refsologest"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$langs->trans("Thirdparty").'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").' NPR"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; } } @@ -713,23 +713,23 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if (empty($action) || $action == 'view') { llxHeader('', $langs->trans("PurchasesJournal")); - $nom = $langs->trans("PurchasesJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); + $nom = $langs->trans("PurchasesJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); $nomlink = ''; $periodlink = ''; $exportlink = ''; - $builddate=dol_now(); - $description.= $langs->trans("DescJournalOnlyBindedVisible").'
'; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $builddate = dol_now(); + $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description .= $langs->trans("DepositsAreNotIncluded"); } else { $description .= $langs->trans("DepositsAreIncluded"); } - $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); - $varlink = 'id_journal=' . $id_journal; + $varlink = 'id_journal='.$id_journal; journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); @@ -740,13 +740,13 @@ if (empty($action) || $action == 'view') { print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } print '
'; - if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { - print ''; + print ''; } else { - if ($in_bookkeeping == 'notyet') print ''; - else print '' . $langs->trans("WriteBookKeeping") . ''; + if ($in_bookkeeping == 'notyet') print ''; + else print ''.$langs->trans("WriteBookKeeping").''; } print '
'; @@ -775,13 +775,13 @@ if (empty($action) || $action == 'view') { print '
'; print "
" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")" . $langs->trans("AccountAccounting") . "" . $langs->trans("SubledgerAccount") . "" . $langs->trans("LabelOperation") . "' . $langs->trans("Debit") . "' . $langs->trans("Credit") . "".$langs->trans("Date")."".$langs->trans("Piece").' ('.$langs->trans("ExpenseReportRef").")".$langs->trans("AccountAccounting")."".$langs->trans("SubledgerAccount")."".$langs->trans("LabelOperation")."'.$langs->trans("Debit")."'.$langs->trans("Credit")."
" . $date . "" . $expensereportstatic->getNomUrl(1) . "".$date."".$expensereportstatic->getNomUrl(1)."" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $accountingaccount->label . "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "".$userstatic->getNomUrl(0, 'user', 16).' - '.$accountingaccount->label."'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
" . $date . "" . $expensereportstatic->getNomUrl(1) . "".$date."".$expensereportstatic->getNomUrl(1).""; $accountoshow = length_accounta($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT); @@ -624,9 +624,9 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print '" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("SubledgerAccount") . "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."'.($mt < 0 ? -price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
"; print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print '"; - print '"; + print ""; + print ""; + print ""; + print ""; + print ""; + print '"; + print '"; print "\n"; $r = ''; @@ -813,7 +813,7 @@ if (empty($action) || $action == 'view') { if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) { $replacedinvoice = 1; - $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. + $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. if ($alreadydispatched) $replacedinvoice = 2; } @@ -822,8 +822,8 @@ if (empty($action) || $action == 'view') { { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; print ""; - print '"; - print '"; + print '"; + print '"; print ""; } } @@ -960,8 +960,8 @@ if (empty($action) || $action == 'view') { if ($mt) { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; - print ""; - print '"; - print '"; + print ""; + print '"; + print '"; print ""; } } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 7781d612575..6043d2bf857 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -31,17 +31,17 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page -$langs->loadLangs(array("commercial", "compta","bills","other","accountancy","errors")); +$langs->loadLangs(array("commercial", "compta", "bills", "other", "accountancy", "errors")); $id_journal = GETPOST('id_journal', 'int'); $action = GETPOST('action', 'aZ09'); @@ -62,13 +62,13 @@ if ($user->socid > 0) accessforbidden(); $hookmanager->initHooks(array('sellsjournal')); -$parameters=array(); +$parameters = array(); /* * Actions */ -$reshook=$hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doActions', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks $accountingaccount = new AccountingAccount($db); @@ -83,13 +83,13 @@ $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { $pastmonth = 12; - $pastmonthyear --; + $pastmonthyear--; } $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form +if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); @@ -132,45 +132,45 @@ $sql .= " ORDER BY f.datef"; dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { - $tabfac = array (); - $tabht = array (); - $tabtva = array (); - $def_tva = array (); - $tabttc = array (); - $tablocaltax1 = array (); - $tablocaltax2 = array (); - $tabcompany = array (); + $tabfac = array(); + $tabht = array(); + $tabtva = array(); + $def_tva = array(); + $tabttc = array(); + $tablocaltax1 = array(); + $tablocaltax2 = array(); + $tabcompany = array(); $num = $db->num_rows($result); // Variables $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'; - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined'; + $cpttva = (!empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined'; $i = 0; - while ( $i < $num ) { + while ($i < $num) { $obj = $db->fetch_object($result); // Controls - $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; + $compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli; $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) - $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; + $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; else - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; + $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; } - $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); - $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); - $compta_localtax1 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); - $compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), $mysoc, $mysoc, 0); + $compta_tva = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); + $compta_localtax1 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); + $compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); // Define array to display all VAT rates that use this accounting account $compta_tva - if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code)) + if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) { - $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); } $line = new FactureLigne($db); @@ -196,29 +196,29 @@ if ($result) { $tabfac[$obj->rowid]["ref"] = $obj->ref; $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->label_compte; - $tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries) + $tabfac[$obj->rowid]["close_code"] = $obj->close_code; // close_code = 'replaced' for replacement invoices (not used in most european countries) //$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid; // Avoid warnings - if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; - if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; - if (! isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; - if (! isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; + if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; + if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; + if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; + if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; + if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; - if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR + if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio; $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio; - $tabcompany[$obj->rowid] = array ( + $tabcompany[$obj->rowid] = array( 'id' => $obj->socid, 'name' => $obj->name, 'code_client' => $obj->code_client, 'code_compta' => $compta_soc ); - $i ++; + $i++; } } else { dol_print_error($db); @@ -229,16 +229,16 @@ $errorforinvoice = array(); // Loop in invoices to detect lines with not binding lines foreach ($tabfac as $key => $val) { // Loop on each invoice $sql = "SELECT COUNT(fd.rowid) as nb"; - $sql.= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql.= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0"; - $sql.= " AND fd.total_ttc <> 0 AND fk_facture = ".$key; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0"; + $sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".$key; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj->nb > 0) { - $errorforinvoice[$key]='somelinesarenotbound'; + $errorforinvoice[$key] = 'somelinesarenotbound'; } } else dol_print_error($db); @@ -282,7 +282,7 @@ if ($action == 'writebookkeeping') { if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) { $replacedinvoice = 1; - $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. + $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. if ($alreadydispatched) $replacedinvoice = 2; } @@ -302,7 +302,7 @@ if ($action == 'writebookkeeping') { } // Thirdparty - if (! $errorforline) + if (!$errorforline) { foreach ($tabttc[$key] as $k => $mt) { $bookkeeping = new BookKeeping($db); @@ -367,7 +367,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->date_creation = $now; $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; @@ -392,14 +392,14 @@ if ($action == 'writebookkeeping') { { $error++; $errorforline++; - $errorforinvoice[$key]='alreadyjournalized'; + $errorforinvoice[$key] = 'alreadyjournalized'; //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { $error++; $errorforline++; - $errorforinvoice[$key]='other'; + $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } @@ -454,14 +454,14 @@ if ($action == 'writebookkeeping') { { $error++; $errorforline++; - $errorforinvoice[$key]='alreadyjournalized'; + $errorforinvoice[$key] = 'alreadyjournalized'; //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); } else { $error++; $errorforline++; - $errorforinvoice[$key]='other'; + $errorforinvoice[$key] = 'other'; setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } @@ -471,15 +471,15 @@ if ($action == 'writebookkeeping') { } // Protection against a bug on lines before - if (! $errorforline && (price2num($totaldebit) != price2num($totalcredit))) + if (!$errorforline && (price2num($totaldebit) != price2num($totalcredit))) { $error++; $errorforline++; - $errorforinvoice[$key]='amountsnotbalanced'; + $errorforinvoice[$key] = 'amountsnotbalanced'; setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors'); } - if (! $errorforline) + if (!$errorforline) { $db->commit(); } @@ -490,7 +490,7 @@ if ($action == 'writebookkeeping') { if ($error >= 10) { setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); - break; // Break in the foreach + break; // Break in the foreach } } } @@ -509,20 +509,20 @@ if ($action == 'writebookkeeping') { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - $action=''; + $action = ''; // Must reload data, so we make a redirect if (count($tabpay) != $error) { - $param='id_journal='.$id_journal; - $param.='&date_startday='.$date_startday; - $param.='&date_startmonth='.$date_startmonth; - $param.='&date_startyear='.$date_startyear; - $param.='&date_endday='.$date_endday; - $param.='&date_endmonth='.$date_endmonth; - $param.='&date_endyear='.$date_endyear; - $param.='&in_bookkeeping='.$in_bookkeeping; - header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:'')); + $param = 'id_journal='.$id_journal; + $param .= '&date_startday='.$date_startday; + $param .= '&date_startmonth='.$date_startmonth; + $param .= '&date_startyear='.$date_startyear; + $param .= '&date_endday='.$date_endday; + $param .= '&date_endmonth='.$date_endmonth; + $param .= '&date_endyear='.$date_endyear; + $param .= '&in_bookkeeping='.$in_bookkeeping; + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); exit; } } @@ -541,7 +541,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $filename = 'journal'; $type_export = 'journal'; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; $companystatic = new Client($db); $invoicestatic = new Facture($db); @@ -568,7 +568,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) { $replacedinvoice = 1; - $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. + $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. if ($alreadydispatched) $replacedinvoice = 2; } @@ -581,18 +581,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! // Third party foreach ($tabttc[$key] as $k => $mt) { //if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("Thirdparty") . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Thirdparty") . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . $journal . '"'; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER.'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$langs->trans("Thirdparty").'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Thirdparty").'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; //} } @@ -602,18 +602,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch(null, $k, true); //if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '""' . $sep; - print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"'; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '""'.$sep; + print '"'.utf8_decode(dol_trunc($accountingaccount->label, 32)).'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.dol_trunc($accountingaccount->label, 32).'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; //} } @@ -627,18 +627,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '""' . $sep; - print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . ' %"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"'; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '""'.$sep; + print '"'.$langs->trans("VAT").' - '.$def_tva[$key].' %"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; } } @@ -651,22 +651,22 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! if (empty($action) || $action == 'view') { llxHeader('', $langs->trans("SellsJournal")); - $nom = $langs->trans("SellsJournal") . ' | ' . $accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); + $nom = $langs->trans("SellsJournal").' | '.$accountingjournalstatic->getNomUrl(0, 1, 1, '', 1); $nomlink = ''; $periodlink = ''; $exportlink = ''; - $builddate=dol_now(); - $description.= $langs->trans("DescJournalOnlyBindedVisible").'
'; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + $builddate = dol_now(); + $description .= $langs->trans("DescJournalOnlyBindedVisible").'
'; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description .= $langs->trans("DepositsAreNotIncluded"); else $description .= $langs->trans("DepositsAreIncluded"); - $listofchoices=array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); - $period = $form->selectDate($date_start?$date_start:-1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end?$date_end:-1, 'date_end', 0, 0, 0, '', 1, 0); - $period .= ' - ' .$langs->trans("JournalizationInLedgerStatus").' '. $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); + $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); - $varlink = 'id_journal=' . $id_journal; + $varlink = 'id_journal='.$id_journal; journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); @@ -677,13 +677,13 @@ if (empty($action) || $action == 'view') { print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); } print '
'; - if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ''; if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { - print ''; + print ''; } else { - if ($in_bookkeeping == 'notyet') print ''; - else print '' . $langs->trans("WriteBookKeeping") . ''; + if ($in_bookkeeping == 'notyet') print ''; + else print ''.$langs->trans("WriteBookKeeping").''; } print '
'; @@ -712,13 +712,13 @@ if (empty($action) || $action == 'view') { print '
'; print "
" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")" . $langs->trans("AccountAccounting") . "" . $langs->trans("SubledgerAccount") . "" . $langs->trans("LabelOperation") . "' . $langs->trans("Debit") . "' . $langs->trans("Credit") . "".$langs->trans("Date")."".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")".$langs->trans("AccountAccounting")."".$langs->trans("SubledgerAccount")."".$langs->trans("LabelOperation")."'.$langs->trans("Debit")."'.$langs->trans("Credit")."
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; print $langs->trans("Replaced"); @@ -843,8 +843,8 @@ if (empty($action) || $action == 'view') { { print '
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; print ''.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).''; @@ -929,8 +929,8 @@ if (empty($action) || $action == 'view') { if ($mt) { print '
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; $accountoshow = length_accountg($k); @@ -944,10 +944,10 @@ if (empty($action) || $action == 'view') { print ""; print '"; - print $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:''); + print $companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); print "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "'.($mt >= 0 ? price($mt) : '')."'.($mt < 0 ? price(-$mt) : '')."
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; $accountoshow = length_accountg($k); @@ -974,9 +974,9 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; print '" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->ref_supplier . ' - ' . $langs->trans("VAT") . " NPR (counterpart)' . ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("VAT")." NPR (counterpart)'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
"; print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print '"; - print '"; + print ""; + print ""; + print ""; + print ""; + print ""; + print '"; + print '"; print "\n"; $r = ''; @@ -748,7 +748,7 @@ if (empty($action) || $action == 'view') { if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) { $replacedinvoice = 1; - $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. + $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. if ($alreadydispatched) $replacedinvoice = 2; } @@ -757,8 +757,8 @@ if (empty($action) || $action == 'view') { { print ''; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; print ""; - print ""; - print ""; + print ""; + print ""; // Account print "'; - print ""; - print '"; - print '"; + print '"; + print '"; print ""; } } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5d992b168d4..5006becb053 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -489,7 +489,7 @@ class AdherentType extends CommonObject { global $langs, $conf; - $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; + $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; @@ -506,7 +506,8 @@ class AdherentType extends CommonObject $this->ref = $obj->rowid; $this->label = $obj->label; $this->morphy = $obj->morphy; - $this->statut = $obj->statut; + $this->statut = $obj->status; // deprecated + $this->status = $obj->status; $this->duration = $obj->duration; $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); $this->duration_unit = substr($obj->duration, -1); @@ -668,14 +669,43 @@ class AdherentType extends CommonObject return $result; } - /** - * getLibStatut - * - * @return string Return status of a type of member - */ - public function getLibStatut() - { - return ''; + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of status (activity, closed) + * + * @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 of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + /** + * Return the label of a given status + * + * @param int $status Status id + * @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 Status label + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; + $langs->load('companies'); + + $statusType = 'status4'; + if ($status == 0) $statusType = 'status5'; + + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + $this->labelStatus[0] = $langs->trans("ActivityCeased"); + $this->labelStatus[1] = $langs->trans("InActivity"); + $this->labelStatusShort[0] = $langs->trans("ActivityCeased"); + $this->labelStatusShort[1] = $langs->trans("InActivity"); + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 67adb031427..dcd3d48d323 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -36,10 +36,10 @@ $hookmanager = new HookManager($db); $hookmanager->initHooks(array('membersindex')); // Load translation files required by the page -$langs->loadLangs(array("companies","members")); +$langs->loadLangs(array("companies", "members")); // Security check -$result=restrictedArea($user, 'adherent'); +$result = restrictedArea($user, 'adherent'); /* @@ -117,7 +117,7 @@ if ($result) while ($i < $num) { $objp = $db->fetch_object($result); - $MemberUpToDate[$objp->fk_adherent_type]=$objp->somme; + $MemberUpToDate[$objp->fk_adherent_type] = $objp->somme; $i++; } $db->free(); @@ -128,12 +128,12 @@ if ($result) print '
'; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search contact/address - if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire) + if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { - $listofsearchfields['search_member']=array('text'=>'Member'); + $listofsearchfields['search_member'] = array('text'=>'Member'); } if (count($listofsearchfields)) @@ -142,8 +142,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
'; print '
" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")" . $langs->trans("AccountAccounting") . "" . $langs->trans("SubledgerAccount") . "" . $langs->trans("LabelOperation") . "' . $langs->trans("Debit") . "' . $langs->trans("Credit") . "".$langs->trans("Date")."".$langs->trans("Piece").' ('.$langs->trans("InvoiceRef").")".$langs->trans("AccountAccounting")."".$langs->trans("SubledgerAccount")."".$langs->trans("LabelOperation")."'.$langs->trans("Debit")."'.$langs->trans("Credit")."
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; print $langs->trans("Replaced"); @@ -778,8 +778,8 @@ if (empty($action) || $action == 'view') { { print '
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; print ''.$langs->trans('ErrorInvoiceContainsLinesNotYetBoundedShort', $val['ref']).''; @@ -867,8 +867,8 @@ if (empty($action) || $action == 'view') { if ($mt) { print '
" . $date . "" . $invoicestatic->getNomUrl(1) . "".$date."".$invoicestatic->getNomUrl(1).""; $accountoshow = length_accountg($k); @@ -881,10 +881,10 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; print '" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ', $def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:''); + print "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").' '.join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : ''); print "' . ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "'.($mt < 0 ? price(-$mt) : '')."'.($mt >= 0 ? price($mt) : '')."
'; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -171,33 +171,33 @@ if ($conf->use_javascript_ajax) print ''; print ''; print ''; print '
'.$langs->trans("Search").'
'.$langs->trans("Statistics").'
'; - $SommeA=0; - $SommeB=0; - $SommeC=0; - $SommeD=0; - $total=0; - $dataval=array(); - $datalabels=array(); - $i=0; + $SommeA = 0; + $SommeB = 0; + $SommeC = 0; + $SommeD = 0; + $total = 0; + $dataval = array(); + $datalabels = array(); + $i = 0; foreach ($AdherentType as $key => $adhtype) { - $datalabels[]=array($i,$adhtype->getNomUrl(0, dol_size(16))); - $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; + $datalabels[] = array($i, $adhtype->getNomUrl(0, dol_size(16))); + $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->trans("MenuMembersNotUpToDate"), round($SommeB)); - $dataseries[]=array($langs->trans("MenuMembersUpToDate"), round($SommeC)); - $dataseries[]=array($langs->trans("MembersStatusResiliated"), round($SommeD)); - $dataseries[]=array($langs->trans("MembersStatusToValid"), round($SommeA)); + $dataseries = array(); + $dataseries[] = array($langs->trans("MenuMembersNotUpToDate"), round($SommeB)); + $dataseries[] = array($langs->trans("MenuMembersUpToDate"), round($SommeC)); + $dataseries[] = array($langs->trans("MembersStatusResiliated"), round($SommeD)); + $dataseries[] = array($langs->trans("MembersStatusToValid"), round($SommeA)); include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); @@ -207,11 +207,11 @@ if ($conf->use_javascript_ajax) $dolgraph->SetType(array('pie')); $dolgraph->setWidth('100%'); $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total?0:1); + print $dolgraph->show($total ? 0 : 1); print '
'.$langs->trans("Total").''; - print $SommeA+$SommeB+$SommeC+$SommeD; + print $SommeA + $SommeB + $SommeC + $SommeD; print '
'; print '
'; @@ -239,11 +239,11 @@ if ($result) 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; + $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++; } } @@ -275,7 +275,7 @@ foreach ($Total as $key=>$value) print "$key"; print "".$Number[$key].""; print "".price($value).""; - print "".price(price2num($value/$Number[$key], 'MT')).""; + print "".price(price2num($value / $Number[$key], 'MT')).""; print "\n"; $i++; } @@ -285,7 +285,7 @@ print ''; print ''.$langs->trans("Total").''; print "".$numb.""; print ''.price($tot).""; -print "".price(price2num($numb>0?($tot/$numb):0, 'MT')).""; +print "".price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT')).""; print "\n"; print "
"; print "
\n"; @@ -296,18 +296,18 @@ print '
'; /* * Latest modified members */ -$max=5; +$max = 5; $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql.= " a.tms as datem, datefin as date_end_subscription,"; -$sql.= " ta.rowid as typeid, ta.libelle as label, ta.subscription"; -$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; -$sql.= " WHERE a.entity IN (".getEntity('adherent').")"; -$sql.= " AND a.fk_adherent_type = ta.rowid"; -$sql.= $db->order("a.tms", "DESC"); -$sql.= $db->plimit($max, 0); +$sql .= " a.tms as datem, datefin as date_end_subscription,"; +$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; +$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; +$sql .= " AND a.fk_adherent_type = ta.rowid"; +$sql .= $db->order("a.tms", "DESC"); +$sql .= $db->plimit($max, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { print '
'; @@ -359,18 +359,18 @@ else /* * Last modified subscriptions */ -$max=5; +$max = 5; $sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql.= " datefin as date_end_subscription,"; -$sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; -$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; -$sql.= " WHERE a.entity IN (".getEntity('adherent').")"; -$sql.= " AND c.fk_adherent = a.rowid"; -$sql.= $db->order("c.tms", "DESC"); -$sql.= $db->plimit($max, 0); +$sql .= " datefin as date_end_subscription,"; +$sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; +$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; +$sql .= " AND c.fk_adherent = a.rowid"; +$sql .= $db->order("c.tms", "DESC"); +$sql .= $db->plimit($max, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { print '
'; @@ -386,25 +386,25 @@ if ($resql) { $obj = $db->fetch_object($resql); print ''; - $subscriptionstatic->id=$obj->cid; - $subscriptionstatic->ref=$obj->cid; - $staticmember->id=$obj->rowid; - $staticmember->lastname=$obj->lastname; - $staticmember->firstname=$obj->firstname; - if (! empty($obj->fk_soc)) { + $subscriptionstatic->id = $obj->cid; + $subscriptionstatic->ref = $obj->cid; + $staticmember->id = $obj->rowid; + $staticmember->lastname = $obj->lastname; + $staticmember->firstname = $obj->firstname; + if (!empty($obj->fk_soc)) { $staticmember->fk_soc = $obj->fk_soc; $staticmember->fetch_thirdparty(); - $staticmember->name=$staticmember->thirdparty->name; + $staticmember->name = $staticmember->thirdparty->name; } else { - $staticmember->name=$obj->company; + $staticmember->name = $obj->company; } - $staticmember->ref=$staticmember->getFullName($langs); + $staticmember->ref = $staticmember->getFullName($langs); print ''.$subscriptionstatic->getNomUrl(1).''; print ''.$staticmember->getNomUrl(1, 32, 'subscription').''; print ''.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).''; print ''.price($obj->subscription).''; //print ''.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).''; - print ''.dol_print_date($db->jdate($obj->datem?$obj->datem:$obj->datec), 'dayhour').''; + print ''.dol_print_date($db->jdate($obj->datem ? $obj->datem : $obj->datec), 'dayhour').''; print ''; $i++; } @@ -433,10 +433,10 @@ foreach ($AdherentType as $key => $adhtype) { print ''; print ''.$adhtype->getNomUrl(1, dol_size(32)).''; - print ''.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0?$MemberToValidate[$key]:'').' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).''; - print ''.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0) > 0) ? $MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):'').' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).''; - print ''.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).''; - print ''.(isset($MembersResiliated[$key]) && $MembersResiliated[$key]> 0 ?$MembersResiliated[$key]:'').' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).''; + print ''.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0 ? $MemberToValidate[$key] : '').' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).''; + print ''.(isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : '').' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).''; + print ''.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '').' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).''; + print ''.(isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '').' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).''; print "\n"; } print ''; diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index accf7de07b6..7581108dd12 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -32,8 +32,8 @@ $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("members"); -$total=0; -foreach($linkedObjectBlock as $key => $objectlink) +$total = 0; +foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''.$langs->trans("Subscription").''; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index d98dcd9f693..b1b18e3ed31 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -226,7 +226,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { //dol_fiche_head(''); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut, d.morphy"; + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut as status, d.morphy"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; @@ -280,6 +280,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') $membertype->id = $objp->rowid; $membertype->ref = $objp->rowid; $membertype->label = $objp->rowid; + $membertype->status = $objp->status; print ''; print ''; @@ -294,13 +295,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') print ''; print ''.yn($objp->subscription).''; print ''.yn($objp->vote).''; - print ''; - if (!empty($objp->statut)) { - print img_picto($langs->trans("InActivity"), 'statut4'); - } else { - print img_picto($langs->trans("ActivityCeased"), 'statut5'); - } - print ''; + print ''.$membertype->getLibStatut(5).''; if ($user->rights->adherent->configurer) print 'rowid.'">'.img_edit().''; else @@ -432,15 +427,7 @@ if ($rowid > 0) print ''; - print ''; - - // Morphy + // Morphy print ''; print ''; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 970d8675873..0ea6a932fe7 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -53,8 +53,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; - $value=(GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); + $code = $reg[1]; + $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); @@ -68,7 +68,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { - $code=$reg[1]; + $code = $reg[1]; if (dolibarr_del_const($db, $code, $conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); @@ -88,21 +88,21 @@ if ($action == 'set') } elseif ($action == 'specimen') // For orders { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $commande = new CommandeFournisseur($db); $commande->initAsSpecimen(); - $commande->thirdparty=$specimenthirdparty; + $commande->thirdparty = $specimenthirdparty; // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -171,18 +171,18 @@ elseif ($action == 'setdoc') * View */ -$formactions=new FormActions($db); -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$formactions = new FormActions($db); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"), $linkback, 'title_setup'); -$head=agenda_prepare_head(); +$head = agenda_prepare_head(); dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action'); @@ -196,15 +196,15 @@ dol_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action'); $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = 'action'"; -$sql.= " AND entity = ".$conf->entity; +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = 'action'"; +$sql .= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -239,22 +239,22 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + 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); + $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)); print ''."\n"; print "\n"; print "'; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip = ''.$langs->trans("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 ''; @@ -353,15 +353,15 @@ print ''."\n"; // AGENDA_DEFAULT_VIEW print ''."\n"; -$htmltext=$langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv("UserGUISetup")); +$htmltext = $langs->trans("ThisValueCanOverwrittenOnUserLevel", $langs->transnoentitiesnoconv("UserGUISetup")); print ''."\n"; print ''."\n"; print ''."\n"; -if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) +if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; print ''."\n"; diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 873f14ea68e..a6cf1db4ce7 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -45,15 +45,15 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setbarcodeproducton') { $barcodenumberingmodule = GETPOST('value', 'alpha'); - $res=dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); + $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') { - $res=dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity); + $res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity); } if ($action == 'setcoder') @@ -61,12 +61,12 @@ if ($action == 'setcoder') $coder = GETPOST('coder', 'alpha'); $code_id = GETPOST('code_id', 'alpha'); $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; - $sqlp.= " SET coder = '" . $coder."'"; - $sqlp.= " WHERE rowid = ". $code_id; - $sqlp.= " AND entity = ".$conf->entity; + $sqlp .= " SET coder = '".$coder."'"; + $sqlp .= " WHERE rowid = ".$code_id; + $sqlp .= " AND entity = ".$conf->entity; - $resql=$db->query($sqlp); - if (! $resql) dol_print_error($db); + $resql = $db->query($sqlp); + if (!$resql) dol_print_error($db); } elseif ($action == 'update') { @@ -130,33 +130,33 @@ elseif ($action == 'updateengine') $form = new Form($db); $formbarcode = new FormBarCode($db); -$help_url='EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra'; +$help_url = 'EN:Module_Barcode|FR:Module_Codes_Barre|ES:Módulo Código de barra'; llxHeader('', $langs->trans("BarcodeSetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BarcodeSetup"), $linkback, 'title_setup'); // Detect bar codes modules -$barcodelist=array(); +$barcodelist = array(); clearstatcache(); // Scan list of all barcode included provided by external modules -$dirbarcode=array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']); +$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']); -foreach($dirbarcode as $reldir) +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; + if (!is_dir($newdir)) continue; - $handle=@opendir($newdir); + $handle = @opendir($newdir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') { @@ -164,7 +164,7 @@ foreach($dirbarcode as $reldir) { if (preg_match('/(.*)\.modules\.php$/i', $file, $reg)) { - $filebis=$reg[1]; + $filebis = $reg[1]; // Loading encoding class require_once $newdir.$file; @@ -172,12 +172,12 @@ foreach($dirbarcode as $reldir) $module = new $classname($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) { - $barcodelist[$filebis]=$module->info(); + $barcodelist[$filebis] = $module->info(); } } } @@ -237,17 +237,17 @@ if ($resql) print ''; print ''; // Chemin du binaire genbarcode sous linux -if (! isset($_SERVER['WINDIR'])) +if (!isset($_SERVER['WINDIR'])) { print ''; print ''; print ''; print ''; @@ -342,7 +342,7 @@ if (! empty($conf->product->enabled)) } // Module thirdparty -if (! empty($conf->societe->enabled)) +if (!empty($conf->societe->enabled)) { print ''; print ''; @@ -375,7 +375,7 @@ if ($conf->product->enabled) print ''; print "\n"; - $dirbarcodenum=array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); + $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); foreach ($dirbarcodenum as $dirroot) { @@ -384,16 +384,16 @@ if ($conf->product->enabled) $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (preg_match('/^mod_barcode_product_.*php$/', $file)) { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); try { dol_include_once($dirroot.$file.'.php'); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -401,7 +401,7 @@ if ($conf->product->enabled) $modBarCode = new $file(); print ''; - print ''; print '\n"; @@ -419,7 +419,7 @@ if ($conf->product->enabled) print ''; } print ''; print "\n"; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 764db492959..3f064e22dfb 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'orders', 'other')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); @@ -56,14 +56,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder=GETPOST('maskconstorder', 'alpha'); - $maskorder=GETPOST('maskorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskorder = GETPOST('maskorder', 'alpha'); if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -75,20 +75,20 @@ if ($action == 'updateMask') elseif ($action == 'specimen') { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $commande = new Commande($db); $commande->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -164,9 +164,9 @@ elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') $draft = GETPOST("COMMANDE_DRAFT_WATERMARK"); $res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -178,13 +178,13 @@ elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') elseif ($action == 'set_ORDER_FREE_TEXT') { - $freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string + $freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -192,12 +192,12 @@ elseif ($action == 'set_ORDER_FREE_TEXT') { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action=="setshippableiconinlist") { +} elseif ($action == "setshippableiconinlist") { // Activate Set Shippable Icon In List $setshippableiconinlist = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) { + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -209,9 +209,9 @@ elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') { $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -226,9 +226,9 @@ elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') { $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -243,13 +243,13 @@ elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') * View */ -$form=new Form($db); +$form = new Form($db); -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", $langs->trans("OrdersSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); $head = order_admin_prepare_head(); @@ -282,18 +282,18 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -304,9 +304,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''."\n"; @@ -323,22 +323,22 @@ foreach ($dirmodels as $reldir) } print ''; - $commande=new Commande($db); + $commande = new Commande($db); $commande->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $commande->type=0; - $nextval=$module->getNextValue($mysoc, $commande); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $commande->type = 0; + $nextval = $module->getNextValue($mysoc, $commande); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -366,14 +366,14 @@ print load_fiche_titre($langs->trans("OrdersModelModule"), '', ''); // Load array def with activated templates $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -401,42 +401,42 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/commande".$valdir); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; print "\n"; print "\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print ''; print ''; print ''; print ''."\n"; print ''."\n"; @@ -450,28 +450,28 @@ print ''."\n"; print ''; +print ''; print ''."\n"; print ''; +print ''; print ''."\n"; print ''; +print ''; print ''."\n"; // Web print ''; +print ''; print ''."\n"; // Barcode -if (! empty($conf->barcode->enabled)) { +if (!empty($conf->barcode->enabled)) { print ''; + print ''; print ''; } @@ -480,7 +480,7 @@ print ''; print "\n"; -print ""; +print ""; print '\n"; -print ""; +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); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); print ''; @@ -526,18 +526,18 @@ print ''; print "\n"; print "\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print ''; print ''; print ''; print '\n"; print ''; // Use services duration -print ''; -print ''; +print ''; +print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Use duration -print ''; -print ''; +print ''; +print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // use date without hour -print ''; -print ''; +print ''; +print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index ea9197a80bb..6d08456a470 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -43,7 +43,7 @@ $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='delivery'; +$type = 'delivery'; /* @@ -54,13 +54,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstdelivery=GETPOST('maskconstdelivery', 'alpha'); - $maskdelivery=GETPOST('maskdelivery', 'alpha'); + $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); + $maskdelivery = GETPOST('maskdelivery', 'alpha'); if ($maskconstdelivery) $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -72,12 +72,12 @@ if ($action == 'updateMask') if ($action == 'set_DELIVERY_FREE_TEXT') { - $free=GETPOST('DELIVERY_FREE_TEXT', 'none'); // No alpha here, we want exact string - $res=dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity); + $free = GETPOST('DELIVERY_FREE_TEXT', 'none'); // No alpha here, we want exact string + $res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -89,20 +89,20 @@ if ($action == 'set_DELIVERY_FREE_TEXT') if ($action == 'specimen') { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $sending = new Livraison($db); $sending->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/livraison/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/livraison/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -176,13 +176,13 @@ if ($action == 'setmod') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", ""); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup'); print '
'; $head = expedition_admin_prepare_head(); @@ -214,11 +214,11 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; @@ -227,7 +227,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; @@ -237,11 +237,11 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''."\n"; @@ -256,21 +256,21 @@ foreach ($dirmodels as $reldir) } print ''; - $livraison=new Livraison($db); + $livraison = new Livraison($db); $livraison->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $livraison); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $livraison); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -297,19 +297,19 @@ print '
'; print load_fiche_titre($langs->trans("DeliveryOrderModel"), '', ''); // Defini tableau def de modele -$type="delivery"; +$type = "delivery"; $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -343,33 +343,33 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; // Info - $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip = ''.$langs->trans("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 ''; @@ -447,18 +447,18 @@ print ''; print ''; print "\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print ''; print ''; print ''; print ''; - if ($nbbyrow) print ''; + print ''; $nbphoto++; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 3e84c23dbc3..8795ca28af1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -38,7 +38,7 @@ class ActionComm extends CommonObject /** * @var string ID to identify managed object */ - public $element='action'; + public $element = 'action'; /** * @var string Name of table without prefix where object is stored @@ -294,6 +294,11 @@ class ActionComm extends CommonObject */ public $icalcolor; + /** + * @var string Extraparam + */ + public $extraparams; + /** * @var array Actions */ @@ -359,174 +364,174 @@ class ActionComm extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Check parameters - if (! isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 + if (!isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 { dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); - $this->errors[]='ErrorPropertyUserowneridNotDefined'; + $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; return -1; } // Clean parameters - $this->label=dol_trunc(trim($this->label), 128); - $this->location=dol_trunc(trim($this->location), 128); - $this->note=dol_htmlcleanlastbr(trim($this->note)); + $this->label = dol_trunc(trim($this->label), 128); + $this->location = dol_trunc(trim($this->location), 128); + $this->note = dol_htmlcleanlastbr(trim($this->note)); if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || ! is_numeric($this->priority)) $this->priority = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; if (empty($this->fulldayevent)) $this->fulldayevent = 0; if (empty($this->punctual)) $this->punctual = 0; if (empty($this->transparency)) $this->transparency = 0; if ($this->percentage > 100) $this->percentage = 100; //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if (! empty($this->datep) && ! empty($this->datef)) $this->durationp=($this->datef - $this->datep); // deprecated + if (!empty($this->datep) && !empty($this->datef)) $this->durationp = ($this->datef - $this->datep); // deprecated //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); - if (! empty($this->datep) && ! empty($this->datef) && $this->datep > $this->datef) $this->datef=$this->datep; + if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) $this->datef = $this->datep; //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; - if (! isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; + if (!isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; // For backward compatibility - if ($this->elementtype=='facture') $this->elementtype='invoice'; - if ($this->elementtype=='commande') $this->elementtype='order'; - if ($this->elementtype=='contrat') $this->elementtype='contract'; + if ($this->elementtype == 'facture') $this->elementtype = 'invoice'; + if ($this->elementtype == 'commande') $this->elementtype = 'order'; + if ($this->elementtype == 'contrat') $this->elementtype = 'contract'; - if (! is_array($this->userassigned) && ! empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array + if (!is_array($this->userassigned) && !empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array { - $tmpid=$this->userassigned; - $this->userassigned=array(); - $this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency); + $tmpid = $this->userassigned; + $this->userassigned = array(); + $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); } - $userownerid=$this->userownerid; - $userdoneid=$this->userdoneid; + $userownerid = $this->userownerid; + $userdoneid = $this->userdoneid; // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). - if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned)) + if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); - if (! $this->type_id || ! $this->type_code) + if (!$this->type_id || !$this->type_code) { - $key=empty($this->type_id)?$this->type_code:$this->type_id; + $key = empty($this->type_id) ? $this->type_code : $this->type_id; // Get id from code - $cactioncomm=new CActionComm($this->db); - $result=$cactioncomm->fetch($key); + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($key); if ($result > 0) { - $this->type_id=$cactioncomm->id; - $this->type_code=$cactioncomm->code; + $this->type_id = $cactioncomm->id; + $this->type_code = $cactioncomm->code; } elseif ($result == 0) { - $this->error='Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; + $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; return -1; } else { - $this->error=$cactioncomm->error; + $this->error = $cactioncomm->error; return -1; } } - $code = empty($this->code)?$this->type_code:$this->code; + $code = empty($this->code) ? $this->type_code : $this->code; // Check parameters - if (! $this->type_id) + if (!$this->type_id) { - $this->error="ErrorWrongParameters"; + $this->error = "ErrorWrongParameters"; return -1; } $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm"; - $sql.= "(datec,"; - $sql.= "datep,"; - $sql.= "datep2,"; - $sql.= "durationp,"; // deprecated - $sql.= "fk_action,"; - $sql.= "code,"; - $sql.= "fk_soc,"; - $sql.= "fk_project,"; - $sql.= "note,"; - $sql.= "fk_contact,"; - $sql.= "fk_user_author,"; - $sql.= "fk_user_action,"; - $sql.= "fk_user_done,"; - $sql.= "label,percent,priority,fulldayevent,location,punctual,"; - $sql.= "transparency,"; - $sql.= "fk_element,"; - $sql.= "elementtype,"; - $sql.= "entity,"; - $sql.= "extraparams,"; + $sql .= "(datec,"; + $sql .= "datep,"; + $sql .= "datep2,"; + $sql .= "durationp,"; // deprecated + $sql .= "fk_action,"; + $sql .= "code,"; + $sql .= "fk_soc,"; + $sql .= "fk_project,"; + $sql .= "note,"; + $sql .= "fk_contact,"; + $sql .= "fk_user_author,"; + $sql .= "fk_user_action,"; + $sql .= "fk_user_done,"; + $sql .= "label,percent,priority,fulldayevent,location,punctual,"; + $sql .= "transparency,"; + $sql .= "fk_element,"; + $sql .= "elementtype,"; + $sql .= "entity,"; + $sql .= "extraparams,"; // Fields emails - $sql.= "email_msgid,"; - $sql.= "email_from,"; - $sql.= "email_sender,"; - $sql.= "email_to,"; - $sql.= "email_tocc,"; - $sql.= "email_tobcc,"; - $sql.= "email_subject,"; - $sql.= "errors_to"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."', "; - $sql.= (strval($this->datep)!=''?"'".$this->db->idate($this->datep)."'":"null").", "; - $sql.= (strval($this->datef)!=''?"'".$this->db->idate($this->datef)."'":"null").", "; - $sql.= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '')?"'".$this->db->escape($this->durationp)."'":"null").", "; // deprecated - $sql.= (isset($this->type_id)?$this->type_id:"null").","; - $sql.= ($code?("'".$code."'"):"null").", "; - $sql.= ((isset($this->socid) && $this->socid > 0) ? $this->socid:"null").", "; - $sql.= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project:"null").", "; - $sql.= " '".$this->db->escape($this->note_private?$this->note_private:$this->note)."', "; - $sql.= ((isset($this->contactid) && $this->contactid > 0) ? $this->contactid:"null").", "; - $sql.= (isset($user->id) && $user->id > 0 ? $user->id:"null").", "; - $sql.= ($userownerid>0 ? $userownerid:"null").", "; - $sql.= ($userdoneid>0 ? $userdoneid:"null").", "; - $sql.= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."','".$this->db->escape($this->punctual)."', "; - $sql.= "'".$this->db->escape($this->transparency)."', "; - $sql.= (! empty($this->fk_element)?$this->fk_element:"null").", "; - $sql.= (! empty($this->elementtype)?"'".$this->db->escape($this->elementtype)."'":"null").", "; - $sql.= $conf->entity.","; - $sql.= (! empty($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").", "; + $sql .= "email_msgid,"; + $sql .= "email_from,"; + $sql .= "email_sender,"; + $sql .= "email_to,"; + $sql .= "email_tocc,"; + $sql .= "email_tobcc,"; + $sql .= "email_subject,"; + $sql .= "errors_to"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."', "; + $sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", "; + $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; + $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated + $sql .= (isset($this->type_id) ? $this->type_id : "null").","; + $sql .= ($code ? ("'".$code."'") : "null").", "; + $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; + $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; + $sql .= " '".$this->db->escape($this->note_private ? $this->note_private : $this->note)."', "; + $sql .= ((isset($this->contactid) && $this->contactid > 0) ? $this->contactid : "null").", "; + $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; + $sql .= ($userownerid > 0 ? $userownerid : "null").", "; + $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; + $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."','".$this->db->escape($this->punctual)."', "; + $sql .= "'".$this->db->escape($this->transparency)."', "; + $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; + $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; + $sql .= $conf->entity.","; + $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; // Fields emails - $sql.= (! empty($this->email_msgid)?"'".$this->db->escape($this->email_msgid)."'":"null").", "; - $sql.= (! empty($this->email_from)?"'".$this->db->escape($this->email_from)."'":"null").", "; - $sql.= (! empty($this->email_sender)?"'".$this->db->escape($this->email_sender)."'":"null").", "; - $sql.= (! empty($this->email_to)?"'".$this->db->escape($this->email_to)."'":"null").", "; - $sql.= (! empty($this->email_tocc)?"'".$this->db->escape($this->email_tocc)."'":"null").", "; - $sql.= (! empty($this->email_tobcc)?"'".$this->db->escape($this->email_tobcc)."'":"null").", "; - $sql.= (! empty($this->email_subject)?"'".$this->db->escape($this->email_subject)."'":"null").", "; - $sql.= (! empty($this->errors_to)?"'".$this->db->escape($this->errors_to)."'":"null"); - $sql.= ")"; + $sql .= (!empty($this->email_msgid) ? "'".$this->db->escape($this->email_msgid)."'" : "null").", "; + $sql .= (!empty($this->email_from) ? "'".$this->db->escape($this->email_from)."'" : "null").", "; + $sql .= (!empty($this->email_sender) ? "'".$this->db->escape($this->email_sender)."'" : "null").", "; + $sql .= (!empty($this->email_to) ? "'".$this->db->escape($this->email_to)."'" : "null").", "; + $sql .= (!empty($this->email_tocc) ? "'".$this->db->escape($this->email_tocc)."'" : "null").", "; + $sql .= (!empty($this->email_tobcc) ? "'".$this->db->escape($this->email_tobcc)."'" : "null").", "; + $sql .= (!empty($this->email_subject) ? "'".$this->db->escape($this->email_subject)."'" : "null").", "; + $sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null"); + $sql .= ")"; dol_syslog(get_class($this)."::add", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); // Now insert assignedusers - if (! $error) + if (!$error) { - foreach($this->userassigned as $key => $val) + foreach ($this->userassigned as $key => $val) { - if (! is_array($val)) // For backward compatibility when val=id + if (!is_array($val)) // For backward compatibility when val=id { - $val=array('id'=>$val); + $val = array('id'=>$val); } - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } @@ -538,27 +543,27 @@ class ActionComm extends CommonObject { foreach ($this->socpeopleassigned as $id => $Tab) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } } - if (! $error) + if (!$error) { - $action='create'; + $action = 'create'; // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -566,15 +571,15 @@ class ActionComm extends CommonObject } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_CREATE', $user); + $result = $this->call_trigger('ACTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -588,7 +593,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -604,8 +609,8 @@ class ActionComm extends CommonObject { global $db, $conf, $hookmanager; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); $this->db->begin(); @@ -619,26 +624,26 @@ class ActionComm extends CommonObject //$this->fetch_userassigned(); $this->fetchResources(); - $this->id=0; + $this->id = 0; // Create clone - $this->context['createfromclone']='createfromclone'; - $result=$this->create($fuser); + $this->context['createfromclone'] = 'createfromclone'; + $result = $this->create($fuser); if ($result < 0) $error++; - if (! $error) + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$objFrom); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } // Call trigger - $result=$this->call_trigger('ACTION_CLONE', $fuser); + $result = $this->call_trigger('ACTION_CLONE', $fuser); if ($result < 0) { $error++; } // End call triggers } @@ -646,7 +651,7 @@ class ActionComm extends CommonObject unset($this->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -671,38 +676,38 @@ class ActionComm extends CommonObject global $langs; $sql = "SELECT a.id,"; - $sql.= " a.id as ref,"; - $sql.= " a.ref_ext,"; - $sql.= " a.datep,"; - $sql.= " a.datep2,"; - $sql.= " a.durationp,"; // deprecated - $sql.= " a.datec,"; - $sql.= " a.tms as datem,"; - $sql.= " a.code, a.label, a.note,"; - $sql.= " a.fk_soc,"; - $sql.= " a.fk_project,"; - $sql.= " a.fk_user_author, a.fk_user_mod,"; - $sql.= " a.fk_user_action, a.fk_user_done,"; - $sql.= " a.fk_contact, a.percent as percentage,"; - $sql.= " a.fk_element as elementid, a.elementtype,"; - $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; - $sql.= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; - $sql.= " s.nom as socname,"; - $sql.= " u.firstname, u.lastname as lastname"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; - $sql.= " WHERE "; - if ($ref) $sql.= " a.id=".$ref; // No field ref, we use id - elseif ($ref_ext) $sql.= " a.ref_ext='".$this->db->escape($ref_ext)."'"; - else $sql.= " a.id=".$id; + $sql .= " a.id as ref,"; + $sql .= " a.ref_ext,"; + $sql .= " a.datep,"; + $sql .= " a.datep2,"; + $sql .= " a.durationp,"; // deprecated + $sql .= " a.datec,"; + $sql .= " a.tms as datem,"; + $sql .= " a.code, a.label, a.note,"; + $sql .= " a.fk_soc,"; + $sql .= " a.fk_project,"; + $sql .= " a.fk_user_author, a.fk_user_mod,"; + $sql .= " a.fk_user_action, a.fk_user_done,"; + $sql .= " a.fk_contact, a.percent as percentage,"; + $sql .= " a.fk_element as elementid, a.elementtype,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; + $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; + $sql .= " s.nom as socname,"; + $sql .= " u.firstname, u.lastname as lastname"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + $sql .= " WHERE "; + if ($ref) $sql .= " a.id=".$ref; // No field ref, we use id + elseif ($ref_ext) $sql .= " a.ref_ext='".$this->db->escape($ref_ext)."'"; + else $sql .= " a.id=".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num) { $obj = $this->db->fetch_object($resql); @@ -716,12 +721,12 @@ class ActionComm extends CommonObject $this->type_code = $obj->type_code; $this->type_color = $obj->type_color; $this->type_picto = $obj->type_picto; - $transcode=$langs->trans("Action".$obj->type_code); - $this->type = (($transcode!="Action".$obj->type_code) ? $transcode : $obj->type_label); - $transcode=$langs->trans("Action".$obj->type_code.'Short'); - $this->type_short = (($transcode!="Action".$obj->type_code.'Short') ? $transcode : ''); + $transcode = $langs->trans("Action".$obj->type_code); + $this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label); + $transcode = $langs->trans("Action".$obj->type_code.'Short'); + $this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : ''); - $this->code = $obj->code; + $this->code = $obj->code; $this->label = $obj->label; $this->datep = $this->db->jdate($obj->datep); $this->datef = $this->db->jdate($obj->datep2); @@ -729,38 +734,38 @@ class ActionComm extends CommonObject $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); - $this->note = $obj->note; - $this->note_private = $obj->note; - $this->percentage = $obj->percentage; + $this->note = $obj->note; + $this->note_private = $obj->note; + $this->percentage = $obj->percentage; - $this->authorid = $obj->fk_user_author; - $this->usermodid = $obj->fk_user_mod; + $this->authorid = $obj->fk_user_author; + $this->usermodid = $obj->fk_user_mod; if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning - $this->author->id = $obj->fk_user_author; // deprecated - $this->author->firstname = $obj->firstname; // deprecated - $this->author->lastname = $obj->lastname; // deprecated + $this->author->id = $obj->fk_user_author; // deprecated + $this->author->firstname = $obj->firstname; // deprecated + $this->author->lastname = $obj->lastname; // deprecated if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning - $this->usermod->id = $obj->fk_user_mod; // deprecated + $this->usermod->id = $obj->fk_user_mod; // deprecated - $this->userownerid = $obj->fk_user_action; - $this->userdoneid = $obj->fk_user_done; + $this->userownerid = $obj->fk_user_action; + $this->userdoneid = $obj->fk_user_done; $this->priority = $obj->priority; $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->transparency = $obj->transparency; - $this->punctual = $obj->punctual; // deprecated + $this->punctual = $obj->punctual; // deprecated - $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->contactid = $obj->fk_contact; // To have fetch_contact method working - $this->fk_project = $obj->fk_project; // To have fetch_projet method working + $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working + $this->contactid = $obj->fk_contact; // To have fetch_contact method working + $this->fk_project = $obj->fk_project; // To have fetch_projet method working //$this->societe->id = $obj->fk_soc; // deprecated //$this->contact->id = $obj->fk_contact; // deprecated - $this->fk_element = $obj->elementid; - $this->elementid = $obj->elementid; - $this->elementtype = $obj->elementtype; + $this->fk_element = $obj->elementid; + $this->elementid = $obj->elementid; + $this->elementtype = $obj->elementtype; $this->fetchResources(); } @@ -768,7 +773,7 @@ class ActionComm extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -782,18 +787,18 @@ class ActionComm extends CommonObject */ public function fetchResources() { - $sql ='SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; - $sql.=' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; - $sql.=' WHERE fk_actioncomm = '.$this->id; - $sql.=" AND element_type IN ('user', 'socpeople')"; - $resql=$this->db->query($sql); + $sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; + $sql .= ' WHERE fk_actioncomm = '.$this->id; + $sql .= " AND element_type IN ('user', 'socpeople')"; + $resql = $this->db->query($sql); if ($resql) { - $this->userassigned=array(); - $this->socpeopleassigned=array(); + $this->userassigned = array(); + $this->socpeopleassigned = array(); // If owner is known, we must but id first into list - if ($this->userownerid > 0) $this->userassigned[$this->userownerid]=array('id'=>$this->userownerid); // Set first so will be first into list. + if ($this->userownerid > 0) $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); // Set first so will be first into list. while ($obj = $this->db->fetch_object($resql)) { @@ -801,11 +806,11 @@ class ActionComm extends CommonObject { switch ($obj->element_type) { case 'user': - $this->userassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); - if (empty($this->userownerid)) $this->userownerid=$obj->fk_element; // If not defined (should not happened, we fix this) + $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); + if (empty($this->userownerid)) $this->userownerid = $obj->fk_element; // If not defined (should not happened, we fix this) break; case 'socpeople': - $this->socpeopleassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); + $this->socpeopleassigned[$obj->fk_element] = array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); break; } } @@ -923,15 +928,15 @@ class ActionComm extends CommonObject if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_DELETE', $user); + $result = $this->call_trigger('ACTION_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -945,7 +950,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -960,70 +965,70 @@ class ActionComm extends CommonObject */ public function update($user, $notrigger = 0) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; // Clean parameters - $this->label=trim($this->label); - $this->note=trim($this->note); + $this->label = trim($this->label); + $this->note = trim($this->note); if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || ! is_numeric($this->priority)) $this->priority = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; if (empty($this->transparency)) $this->transparency = 0; if (empty($this->fulldayevent)) $this->fulldayevent = 0; if ($this->percentage > 100) $this->percentage = 100; //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if ($this->datep && $this->datef) $this->durationp=($this->datef - $this->datep); // deprecated + if ($this->datep && $this->datef) $this->durationp = ($this->datef - $this->datep); // deprecated //if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); - if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef=$this->datep; + if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef = $this->datep; //if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; if ($this->fk_project < 0) $this->fk_project = 0; // Check parameters if ($this->percentage == 0 && $this->userdoneid > 0) { - $this->error="ErrorCantSaveADoneUserWithZeroPercentage"; + $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; return -1; } - $socid=(($this->socid > 0)?$this->socid:0); - $contactid=(($this->contactid > 0)?$this->contactid:0); - $userownerid=($this->userownerid?$this->userownerid:0); - $userdoneid=($this->userdoneid?$this->userdoneid:0); + $socid = (($this->socid > 0) ? $this->socid : 0); + $contactid = (($this->contactid > 0) ? $this->contactid : 0); + $userownerid = ($this->userownerid ? $this->userownerid : 0); + $userdoneid = ($this->userdoneid ? $this->userdoneid : 0); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; - $sql.= " SET percent = '".$this->db->escape($this->percentage)."'"; - if ($this->type_id > 0) $sql.= ", fk_action = '".$this->db->escape($this->type_id)."'"; - $sql.= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'":"null"); - $sql.= ", datep = ".(strval($this->datep)!='' ? "'".$this->db->idate($this->datep)."'" : 'null'); - $sql.= ", datep2 = ".(strval($this->datef)!='' ? "'".$this->db->idate($this->datef)."'" : 'null'); - $sql.= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->db->escape($this->durationp)."'":"null"); // deprecated - $sql.= ", note = '".$this->db->escape($this->note_private?$this->note_private:$this->note)."'"; - $sql.= ", fk_project =". ($this->fk_project > 0 ? $this->fk_project:"null"); - $sql.= ", fk_soc =". ($socid > 0 ? $socid:"null"); - $sql.= ", fk_contact =". ($contactid > 0 ? $contactid:"null"); - $sql.= ", priority = '".$this->db->escape($this->priority)."'"; - $sql.= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; - $sql.= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'":"null"); - $sql.= ", transparency = '".$this->db->escape($this->transparency)."'"; - $sql.= ", fk_user_mod = ".$user->id; - $sql.= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'":"null"); - $sql.= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'":"null"); - if (! empty($this->fk_element)) $sql.= ", fk_element=".($this->fk_element?$this->db->escape($this->fk_element):"null"); - if (! empty($this->elementtype)) $sql.= ", elementtype=".($this->elementtype?"'".$this->db->escape($this->elementtype)."'":"null"); - $sql.= " WHERE id=".$this->id; + $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; + if ($this->type_id > 0) $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); + $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); + $sql .= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'".$this->db->escape($this->durationp)."'" : "null"); // deprecated + $sql .= ", note = '".$this->db->escape($this->note_private ? $this->note_private : $this->note)."'"; + $sql .= ", fk_project =".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", fk_soc =".($socid > 0 ? $socid : "null"); + $sql .= ", fk_contact =".($contactid > 0 ? $contactid : "null"); + $sql .= ", priority = '".$this->db->escape($this->priority)."'"; + $sql .= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; + $sql .= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'" : "null"); + $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; + $sql .= ", fk_user_mod = ".$user->id; + $sql .= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'" : "null"); + $sql .= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'" : "null"); + if (!empty($this->fk_element)) $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); + if (!empty($this->elementtype)) $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); + $sql .= " WHERE id=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); if ($this->db->query($sql)) { - $action='update'; + $action = 'update'; // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -1031,25 +1036,25 @@ class ActionComm extends CommonObject } // Now insert assignedusers - if (! $error) + if (!$error) { - $sql ="DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'"; $resql = $this->db->query($sql); - foreach($this->userassigned as $key => $val) + foreach ($this->userassigned as $key => $val) { - if (! is_array($val)) // For backward compatibility when val=id + if (!is_array($val)) // For backward compatibility when val=id { - $val=array('id'=>$val); + $val = array('id'=>$val); } - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } @@ -1057,35 +1062,35 @@ class ActionComm extends CommonObject if (!$error) { - $sql ="DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'socpeople'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'socpeople'"; $resql = $this->db->query($sql); if (!empty($this->socpeopleassigned)) { foreach (array_keys($this->socpeopleassigned) as $id) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_MODIFY', $user); + $result = $this->call_trigger('ACTION_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1100,7 +1105,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1123,31 +1128,31 @@ class ActionComm extends CommonObject { global $conf, $langs; - $resarray=array(); + $resarray = array(); dol_syslog(get_class()."::getActions", LOG_DEBUG); $sql = "SELECT a.id"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; - if (! empty($socid)) $sql.= " AND a.fk_soc = ".$socid; - if (! empty($elementtype)) + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + if (!empty($socid)) $sql .= " AND a.fk_soc = ".$socid; + if (!empty($elementtype)) { - if ($elementtype == 'project') $sql.= ' AND a.fk_project = '.$fk_element; - else $sql.= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; + if ($elementtype == 'project') $sql .= ' AND a.fk_project = '.$fk_element; + else $sql .= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; } - if (! empty($filter)) $sql.= $filter; - if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); - $sql.=$db->plimit($limit, 0); + if (!empty($filter)) $sql .= $filter; + if ($sortorder && $sortfield) $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($limit, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { - for($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { $obj = $db->fetch_object($resql); $actioncommstatic = new ActionComm($db); @@ -1237,16 +1242,16 @@ class ActionComm extends CommonObject public function info($id) { $sql = 'SELECT '; - $sql.= ' a.id,'; - $sql.= ' datec,'; - $sql.= ' tms as datem,'; - $sql.= ' fk_user_author,'; - $sql.= ' fk_user_mod'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql.= ' WHERE a.id = '.$id; + $sql .= ' a.id,'; + $sql .= ' datec,'; + $sql .= ' tms as datem,'; + $sql .= ' fk_user_author,'; + $sql .= ' fk_user_mod'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + $sql .= ' WHERE a.id = '.$id; dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -1257,7 +1262,7 @@ class ActionComm extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_mod) { @@ -1266,8 +1271,8 @@ class ActionComm extends CommonObject $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); - if (! empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); + $this->date_creation = $this->db->jdate($obj->datec); + if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); } $this->db->free($result); } @@ -1307,57 +1312,57 @@ class ActionComm extends CommonObject if ($mode == 0) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo').' (0%)'; elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; } elseif ($mode == 1) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - elseif ($percent==0) return $langs->trans('StatusActionToDo'); + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo'); elseif ($percent > 0 && $percent < 100) return $percent.'%'; elseif ($percent >= 100) return $langs->trans('StatusActionDone'); } elseif ($mode == 2) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); - elseif ($percent==0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo'); - elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '. $percent.'%'; + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo'); + elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '.$percent.'%'; elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6').' '.$langs->trans('StatusActionDone'); } elseif ($mode == 3) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)', 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)', 'statut1'); elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)', 'statut3'); elseif ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone').' (100%)', 'statut6'); } elseif ($mode == 4) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); - elseif ($percent==0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)'; elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6').' '.$langs->trans('StatusActionDone').' (100%)'; } elseif ($mode == 5) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return $langs->trans('StatusActionDone').' '.img_picto($langs->trans('StatusActionDone'), 'statut6'); } elseif ($mode == 6) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%) '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%) '.img_picto($langs->trans('StatusActionDone'), 'statut6'); } elseif ($mode == 7) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6'); } @@ -1382,7 +1387,7 @@ class ActionComm extends CommonObject { global $conf, $langs, $user, $hookmanager, $action; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id)) { @@ -1390,45 +1395,45 @@ class ActionComm extends CommonObject } $label = $this->label; - if (empty($label)) $label=$this->libelle; // For backward compatibility + if (empty($label)) $label = $this->libelle; // For backward compatibility - $result=''; + $result = ''; // Set label of type $labeltype = ''; if ($this->type_code) { - $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; + $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code) ? $langs->transnoentities("Action".$this->type_code) : $this->type_label; } if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); } - $tooltip = '' . $langs->trans('ShowAction') . ''; - if (! empty($this->ref)) - $tooltip .= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($label)) - $tooltip .= '
' . $langs->trans('Title') . ': ' . $label; - if (! empty($labeltype)) - $tooltip .= '
' . $langs->trans('Type') . ': ' . $labeltype; - if (! empty($this->location)) - $tooltip .= '
' . $langs->trans('Location') . ': ' . $this->location; - if (! empty($this->note)) - $tooltip .= '
' . $langs->trans('Note') . ': ' . (dol_textishtml($this->note) ? str_replace(array("\r","\n"), "", $this->note) : str_replace(array("\r","\n"), '
', $this->note)); - $linkclose=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) + $tooltip = ''.$langs->trans('ShowAction').''; + if (!empty($this->ref)) + $tooltip .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($label)) + $tooltip .= '
'.$langs->trans('Title').': '.$label; + if (!empty($labeltype)) + $tooltip .= '
'.$langs->trans('Type').': '.$labeltype; + if (!empty($this->location)) + $tooltip .= '
'.$langs->trans('Location').': '.$this->location; + if (!empty($this->note)) + $tooltip .= '
'.$langs->trans('Note').': '.(dol_textishtml($this->note) ? str_replace(array("\r", "\n"), "", $this->note) : str_replace(array("\r", "\n"), '
', $this->note)); + $linkclose = ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowAction"); - $linkclose.=' alt="'.dol_escape_htmltag($tooltip, 1).'"'; + $label = $langs->trans("ShowAction"); + $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($tooltip, 1).'"'; - $linkclose.=' class="'.$classname.' classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"'; + $linkclose .= ' class="'.$classname.' classfortooltip"'; /* $hookmanager->initHooks(array('actiondao')); @@ -1437,24 +1442,24 @@ class ActionComm extends CommonObject $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); */ } - else $linkclose.=' class="'.$classname.'"'; + else $linkclose .= ' class="'.$classname.'"'; - $url=''; - if ($option=='birthday') + $url = ''; + if ($option == 'birthday') $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; if ($option == 'nolink') { $linkstart = ''; @@ -1463,38 +1468,38 @@ class ActionComm extends CommonObject if ($withpicto == 2) { - $libelle=$label; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$labeltype; - $libelleshort=''; + $libelle = $label; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; + $libelleshort = ''; } else { - $libelle=(empty($this->libelle)?$label:$this->libelle.(($label && $label != $this->libelle)?' '.$label:'')); - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle=$labeltype; - if ($maxlength < 0) $libelleshort=$this->ref; - else $libelleshort=dol_trunc($libelle, $maxlength); + $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; + if ($maxlength < 0) $libelleshort = $this->ref; + else $libelleshort = dol_trunc($libelle, $maxlength); } if ($withpicto) { - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () { if ($labeltype) { - $libelle.=(preg_match('/'.preg_quote($labeltype, '/').'/', $libelle)?'':' ('.$langs->transnoentities("Action".$this->type_code).')'); + $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')'); } } } - $result.=$linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'class="'.(($withpicto != 2) ? 'paddingright ' : '').'valigntextbottom"':'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); - $result.=$libelleshort; - $result.=$linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), ($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'valigntextbottom"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip ? 0 : 1); + $result .= $libelleshort; + $result .= $linkend; global $action; $hookmanager->initHooks(array('actiondao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -1562,11 +1567,11 @@ class ActionComm extends CommonObject global $hookmanager; // phpcs:enable - global $conf,$langs,$dolibarr_main_url_root,$mysoc; + global $conf, $langs, $dolibarr_main_url_root, $mysoc; - require_once DOL_DOCUMENT_ROOT ."/core/lib/xcal.lib.php"; - require_once DOL_DOCUMENT_ROOT ."/core/lib/date.lib.php"; - require_once DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/xcal.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); @@ -1574,21 +1579,21 @@ class ActionComm extends CommonObject if (empty($format)) return -1; // Clean parameters - if (! $filename) + if (!$filename) { - $extension='vcs'; - if ($format == 'ical') $extension='ics'; - $filename=$format.'.'.$extension; + $extension = 'vcs'; + if ($format == 'ical') $extension = 'ics'; + $filename = $format.'.'.$extension; } // Create dir and define output file (definitive and temporary) - $result=dol_mkdir($conf->agenda->dir_temp); - $outputfile=$conf->agenda->dir_temp.'/'.$filename; + $result = dol_mkdir($conf->agenda->dir_temp); + $outputfile = $conf->agenda->dir_temp.'/'.$filename; - $result=0; + $result = 0; - $buildfile=true; - $login='';$logina='';$logind='';$logint=''; + $buildfile = true; + $login = ''; $logina = ''; $logind = ''; $logint = ''; $now = dol_now(); @@ -1813,7 +1818,7 @@ class ActionComm extends CommonObject dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); dol_delete_file($outputfiletmp, 0, 1); $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToCreateFile", $outputfile); + $this->error = $langs->trans("ErrorFailToCreateFile", $outputfile); } } @@ -1831,32 +1836,32 @@ class ActionComm extends CommonObject { global $user; - $now=dol_now(); + $now = dol_now(); // Initialise parametres - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; - $this->type_code='AC_OTH'; - $this->code='AC_SPECIMEN_CODE'; - $this->label='Label of event Specimen'; - $this->datec=$now; - $this->datem=$now; - $this->datep=$now; - $this->datef=$now; - $this->author=$user; - $this->usermod=$user; - $this->usertodo=$user; - $this->fulldayevent=0; - $this->punctual=0; - $this->percentage=0; - $this->location='Location'; - $this->transparency=1; // 1 means opaque - $this->priority=1; + $this->type_code = 'AC_OTH'; + $this->code = 'AC_SPECIMEN_CODE'; + $this->label = 'Label of event Specimen'; + $this->datec = $now; + $this->datem = $now; + $this->datep = $now; + $this->datef = $now; + $this->author = $user; + $this->usermod = $user; + $this->usertodo = $user; + $this->fulldayevent = 0; + $this->punctual = 0; + $this->percentage = 0; + $this->location = 'Location'; + $this->transparency = 1; // 1 means opaque + $this->priority = 1; $this->note = 'Note'; - $this->userownerid=$user->id; - $this->userassigned[$user->id]=array('id'=>$user->id, 'transparency'=> 1); + $this->userownerid = $user->id; + $this->userassigned[$user->id] = array('id'=>$user->id, 'transparency'=> 1); return 1; } @@ -1904,7 +1909,7 @@ class ActionComm extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. { diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 9fcb3e0b307..86b0e0f4595 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -476,7 +476,7 @@ if ($object->id > 0) print ''; // Label - print ''; + print ''; // Amount print ''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; print ''."\n"; } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'.$langs->trans("Status").''; - if (!empty($object->statut)) { - print img_picto($langs->trans('TypeStatusActive'), 'statut4').' '.$langs->trans("InActivity"); - } else { - print img_picto($langs->trans('TypeStatusInactive'), 'statut5').' '.$langs->trans("ActivityCeased"); - } - print '
'.$langs->trans("MemberNature").''.$object->getmorphylib($object->morphy).'
"; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; require_once $dir.$file; @@ -301,11 +301,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); print '
'.$form->textwithpicto($langs->trans("AGENDA_DEFAULT_VIEW"), $htmltext).' '."\n"; -$tmplist=array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); +$tmplist = array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser")); print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW); print '
'; if ($obj->coder && $obj->coder != -1) { - $result=0; + $result = 0; - foreach($dirbarcode as $reldir) + 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; + if (!is_dir($newdir)) continue; - $result=@include_once $newdir.$obj->coder.'.modules.php'; + $result = @include_once $newdir.$obj->coder.'.modules.php'; if ($result) break; } if ($result) @@ -259,9 +259,9 @@ 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); + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); //print $url; print ''; } @@ -317,13 +317,13 @@ print ' 
'.$langs->trans("GenbarcodeLocation").''; print ''; - if (! empty($conf->global->GENBARCODE_LOCATION) && ! @file_exists($conf->global->GENBARCODE_LOCATION)) + if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION)) { $langs->load("errors"); print '
'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).''; @@ -332,7 +332,7 @@ if (! isset($_SERVER['WINDIR'])) } // Module products -if (! empty($conf->product->enabled)) +if (!empty($conf->product->enabled)) { print '
'.$langs->trans("SetDefaultBarcodeTypeProducts").'
'.$langs->trans("SetDefaultBarcodeTypeThirdParties").''.$langs->trans("ShortInfo").'
'.(isset($modBarCode->name)?$modBarCode->name:$modBarCode->nom)."\n"; + print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; print $modBarCode->info($langs); print ''.$modBarCode->getExample($langs)."'; - $s=$modBarCode->getToolTip($langs, null, -1); + $s = $modBarCode->getToolTip($langs, null, -1); print $form->textwithpicto('', $s, 1); print '
'; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -528,18 +528,18 @@ print ''.$langs->trans("Value").' 
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='ORDER_FREE_TEXT'; +$variablename = 'ORDER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -547,7 +547,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print '
'; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index bdfb783ce12..357d53df1c3 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -37,52 +37,52 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -$action=GETPOST('action', 'aZ09'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'admincompany'; // To manage different context of search +$action = GETPOST('action', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search // Load translation files required by the page $langs->loadLangs(array('admin', 'companies')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$error=0; +$error = 0; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('admincompany','globaladmin')); +$hookmanager->initHooks(array('admincompany', 'globaladmin')); /* * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) -|| ($action == 'updateedit') ) +if (($action == 'update' && !GETPOST("cancel", 'alpha')) +|| ($action == 'updateedit')) { - $tmparray=getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0); - if (! empty($tmparray['id'])) + $tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0); + if (!empty($tmparray['id'])) { - $mysoc->country_id =$tmparray['id']; - $mysoc->country_code =$tmparray['code']; - $mysoc->country_label=$tmparray['label']; + $mysoc->country_id = $tmparray['id']; + $mysoc->country_code = $tmparray['code']; + $mysoc->country_label = $tmparray['label']; - $s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label; + $s = $mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity); activateModulesRequiredByCountry($mysoc->country_code); } - $tmparray=getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0); - if (! empty($tmparray['id'])) + $tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0); + if (!empty($tmparray['id'])) { - $mysoc->state_id =$tmparray['id']; - $mysoc->state_code =$tmparray['code']; - $mysoc->state_label=$tmparray['label']; + $mysoc->state_id = $tmparray['id']; + $mysoc->state_code = $tmparray['code']; + $mysoc->state_label = $tmparray['label']; - $s=$mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label; + $s = $mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label; dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", $s, 'chaine', 0, '', $conf->entity); } else @@ -105,28 +105,28 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", GETPOST("note", 'none'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alpha'), 'chaine', 0, '', $conf->entity); - $dirforimage=$conf->mycompany->dir_output.'/logos/'; + $dirforimage = $conf->mycompany->dir_output.'/logos/'; $arrayofimages = array('logo', 'logo_squarred'); - foreach($arrayofimages as $varforimage) + foreach ($arrayofimages as $varforimage) { if ($_FILES[$varforimage]["tmp_name"]) { $reg = array(); if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { - $original_file=$reg[1]; + $original_file = $reg[1]; - $isimage=image_format_supported($original_file); + $isimage = image_format_supported($original_file); if ($isimage >= 0) { dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); - if (! is_dir($dirforimage)) + if (!is_dir($dirforimage)) { dol_mkdir($dirforimage); } - $result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); + $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); if ($result > 0) { $constant = "MAIN_INFO_SOCIETE_LOGO"; @@ -144,7 +144,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) { - $imgThumbSmall = $reg[1]; // Save only basename + $imgThumbSmall = $reg[1]; // Save only basename dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); } else dol_syslog($imgThumbSmall); @@ -153,7 +153,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) $imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality); if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) { - $imgThumbMini = $reg[1]; // Save only basename + $imgThumbMini = $reg[1]; // Save only basename dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); } else dol_syslog($imgThumbMini); @@ -162,7 +162,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) { $error++; $langs->load("errors"); - $tmparray=explode(':', $result); + $tmparray = explode(':', $result); setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors'); } else @@ -201,12 +201,12 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) $usevat = GETPOST("optiontva", 'aZ09'); $uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09'); $uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09'); - if ($uselocaltax1 == 'localtax1on' && ! $usevat) + if ($uselocaltax1 == 'localtax1on' && !$usevat) { setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors'); $error++; } - if ($uselocaltax2 == 'localtax2on' && ! $usevat) + if ($uselocaltax2 == 'localtax2on' && !$usevat) { setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors'); $error++; @@ -216,9 +216,9 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity); - if($_POST["optionlocaltax1"]=="localtax1on") + if ($_POST["optionlocaltax1"] == "localtax1on") { - if(!isset($_REQUEST['lt1'])) + if (!isset($_REQUEST['lt1'])) { dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity); } @@ -228,9 +228,9 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) } dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity); } - if($_POST["optionlocaltax2"]=="localtax2on") + if ($_POST["optionlocaltax2"] == "localtax2on") { - if(!isset($_REQUEST['lt2'])) + if (!isset($_REQUEST['lt2'])) { dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity); } @@ -241,7 +241,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity); } - if (! $error) + if (!$error) { $db->commit(); } @@ -250,7 +250,7 @@ if ( ($action == 'update' && ! GETPOST("cancel", 'alpha')) $db->rollback(); } - if ($action != 'updateedit' && ! $error) + if ($action != 'updateedit' && !$error) { header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -261,7 +261,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb { if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"])) { - $isimage=image_format_supported($_GET["file"]); + $isimage = image_format_supported($_GET["file"]); // Create thumbs of logo if ($isimage > 0) @@ -278,7 +278,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality); if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) { - $imgThumbSmall = $reg[1]; // Save only basename + $imgThumbSmall = $reg[1]; // Save only basename dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); } else dol_syslog($imgThumbSmall); @@ -287,7 +287,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality); if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) { - $imgThumbMini = $reg[1]; // Save only basename + $imgThumbMini = $reg[1]; // Save only basename dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); } else dol_syslog($imgThumbMini); @@ -328,11 +328,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred') $logofilenamebis = $mysoc->logo; } - $logofile=$conf->mycompany->dir_output.'/logos/'.$logofilename; + $logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename; if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logofile); dolibarr_del_const($db, $constant, $conf->entity); - if ($action == 'removelogosquarred') $mysoc->logo_squarred=''; - else $mysoc->logo=''; + if ($action == 'removelogosquarred') $mysoc->logo_squarred = ''; + else $mysoc->logo = ''; $logofilename = $mysoc->logo_small; $logofilenamebis = $mysoc->logo_squarred_small; @@ -342,11 +342,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred') $logofilenamebis = $mysoc->logo_small; } - $logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename; + $logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename; if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logosmallfile); dolibarr_del_const($db, $constant."_SMALL", $conf->entity); - if ($action == 'removelogosquarred') $mysoc->logo_squarred_small=''; - else $mysoc->logo_small=''; + if ($action == 'removelogosquarred') $mysoc->logo_squarred_small = ''; + else $mysoc->logo_small = ''; $logofilename = $mysoc->logo_mini; $logofilenamebis = $mysoc->logo_squarred_mini; @@ -356,11 +356,11 @@ if ($action == 'removelogo' || $action == 'removelogosquarred') $logofilenamebis = $mysoc->logo_mini; } - $logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename; + $logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename; if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logominifile); dolibarr_del_const($db, $constant."_MINI", $conf->entity); - if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini=''; - else $mysoc->logo_mini=''; + if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini = ''; + else $mysoc->logo_mini = ''; } @@ -368,14 +368,14 @@ if ($action == 'removelogo' || $action == 'removelogosquarred') * View */ -$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $wikihelp); -$form=new Form($db); -$formother=new FormOther($db); -$formcompany=new FormCompany($db); +$form = new Form($db); +$formother = new FormOther($db); +$formcompany = new FormCompany($db); -$countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; +$countrynotdefined = ''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); @@ -434,11 +434,11 @@ print '
'; -$state_id=0; -if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) +$state_id = 0; +if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) { - $tmp=explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); - $state_id=$tmp[0]; + $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); + $state_id = $tmp[0]; } $formcompany->select_departement($state_id, $mysoc->country_code, 'state_id'); print '
'; -print '
'; -print '
'; -print '
'; -print '
'; - print '
 
'; print ""; print ""; @@ -687,7 +687,7 @@ print "
"; print "
'; print ""; print ""; @@ -711,20 +711,20 @@ if ($mysoc->useLocalTax(1)) print "\n"; // Note: When option is not set, it must not appears as set on on, because there is no default value for this option - print ""; + print ""; print '"; + print ""; print ''."\n"; @@ -260,21 +260,21 @@ foreach ($dirmodels as $reldir) } print ''; - $contract=new Contrat($db); + $contract = new Contrat($db); $contract->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $contract); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $contract); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -302,14 +302,14 @@ print load_fiche_titre($langs->trans("TemplatePDFContracts"), '', ''); // Defini tableau def des modeles $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -337,42 +337,42 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/contract".$valdir); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; print ''; print "\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print ''."\n"; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 14fc247a540..b9e89450d33 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -37,13 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'interventions', 'other')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='ficheinter'; +$type = 'ficheinter'; /* @@ -54,13 +54,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst=GETPOST('maskconst', 'alpha'); - $maskvalue=GETPOST('maskvalue', 'alpha'); + $maskconst = GETPOST('maskconst', 'alpha'); + $maskvalue = GETPOST('maskvalue', 'alpha'); if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -72,20 +72,20 @@ if ($action == 'updateMask') elseif ($action == 'specimen') // For fiche inter { - $modele= GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $inter = new Fichinter($db); $inter->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -158,12 +158,12 @@ elseif ($action == 'setmod') elseif ($action == 'set_FICHINTER_FREE_TEXT') { - $freetext= GETPOST('FICHINTER_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('FICHINTER_FREE_TEXT', 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -175,12 +175,12 @@ elseif ($action == 'set_FICHINTER_FREE_TEXT') elseif ($action == 'set_FICHINTER_DRAFT_WATERMARK') { - $draft= GETPOST('FICHINTER_DRAFT_WATERMARK', 'alpha'); + $draft = GETPOST('FICHINTER_DRAFT_WATERMARK', 'alpha'); $res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -195,9 +195,9 @@ elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') $val = GETPOST('FICHINTER_PRINT_PRODUCTS', 'alpha'); $res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -252,17 +252,17 @@ elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader(); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("InterventionsSetup"), $linkback, 'title_setup'); -$head=fichinter_admin_prepare_head(); +$head = fichinter_admin_prepare_head(); dol_fiche_head($head, 'ficheinter', $langs->trans("Interventions"), -1, 'intervention'); @@ -290,7 +290,7 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) { @@ -304,7 +304,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; @@ -314,9 +314,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''."\n"; @@ -331,21 +331,21 @@ foreach ($dirmodels as $reldir) } print ''; - $ficheinter=new Fichinter($db); + $ficheinter = new Fichinter($db); $ficheinter->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $ficheinter); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $ficheinter); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } print '
global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."
global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."'; print ''; print ""; - $example=$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code); - print ($example!="LocalTax1IsUsedExample"?"\n":""); - if(! isOnlyOneLocalTax(1)) + $example = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code); + print ($example != "LocalTax1IsUsedExample" ? "\n" : ""); + if (!isOnlyOneLocalTax(1)) { print ''; } - $opcions=array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"),$langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"),$langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc")); + $opcions = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc")); print '\n"; - print ""; + print ""; print '\n"; print "
".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."
: '; $formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1"); print '
'.$langs->trans("CalcLocaltax").': '; print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1); @@ -733,12 +733,12 @@ if ($mysoc->useLocalTax(1)) print "
global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code)."
global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code)."'; print ""; print ""; - $example=$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code); - print ($example!="LocalTax1IsNotUsedExample"?"\n":""); + $example = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code); + print ($example != "LocalTax1IsNotUsedExample" ? "\n" : ""); print "
".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."
"; print "
"; @@ -755,13 +755,13 @@ if ($mysoc->useLocalTax(2)) // Note: When option is not set, it must not appears as set on on, because there is no default value for this option - print "
global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."
global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."'; print ''; print ""; - $example=$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code); - print ($example!="LocalTax2IsUsedExample"?"\n":""); - if(! isOnlyOneLocalTax(2)) + $example = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code); + print ($example != "LocalTax2IsUsedExample" ? "\n" : ""); + if (!isOnlyOneLocalTax(2)) { print '\n"; - print ""; + print ""; print '\n"; print "
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."
: '; $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); @@ -774,12 +774,12 @@ if ($mysoc->useLocalTax(2)) print "
global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code)."
global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code)."'; print ""; print ""; - $example=$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code); - print ($example!="LocalTax2IsNotUsedExample"?"\n":""); + $example = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code); + print ($example != "LocalTax2IsNotUsedExample" ? "\n" : ""); print "
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."
".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."
"; print "
"; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 2938f97feef..907d56333b4 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","errors","contracts")); +$langs->loadLangs(array("admin", "errors", "contracts")); if (!$user->admin) accessforbidden(); @@ -37,11 +37,11 @@ $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='contract'; +$type = 'contract'; if (empty($conf->global->CONTRACT_ADDON)) { - $conf->global->CONTRACT_ADDON='mod_contract_serpis'; + $conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; } @@ -54,12 +54,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { $maskconst = GETPOST('maskconstcontract', 'alpha'); - $maskvalue = GETPOST('maskcontract', 'alpha'); + $maskvalue = GETPOST('maskcontract', 'alpha'); if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -71,20 +71,20 @@ if ($action == 'updateMask') elseif ($action == 'specimen') // For contract { - $modele= GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $contract = new Contrat($db); $contract->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -157,15 +157,15 @@ elseif ($action == 'setmod') elseif ($action == 'set_other') { - $freetext= GETPOST('CONTRACT_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('CONTRACT_FREE_TEXT', 'none'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - $draft= GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha'); + $draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res1 > 0 || ! $res2 > 0) $error++; + if (!$res1 > 0 || !$res2 > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -180,16 +180,16 @@ elseif ($action == 'set_other') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader(); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ContractsSetup"), $linkback, 'title_setup'); -$head=contract_admin_prepare_head(); +$head = contract_admin_prepare_head(); dol_fiche_head($head, 'contract', $langs->trans("Contracts"), -1, 'contract'); @@ -219,18 +219,18 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -241,9 +241,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print '
'; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -466,16 +466,16 @@ print ''.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print '
'; -$variablename='CONTRACT_FREE_TEXT'; +$variablename = 'CONTRACT_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -483,7 +483,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print '
'; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; @@ -371,17 +371,17 @@ print '

'; print load_fiche_titre($langs->trans("TemplatePDFInterventions"), '', ''); // Defini tableau def des modeles -$type='ficheinter'; +$type = 'ficheinter'; $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -413,36 +413,36 @@ foreach ($dirmodels as $reldir) if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print '
'; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -477,15 +477,15 @@ foreach ($dirmodels as $reldir) print ''; print $form->textwithpicto('', $htmltooltip, -1, 0); print ''.$langs->trans("Value").' 
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='FICHINTER_FREE_TEXT'; +$variablename = 'FICHINTER_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -545,7 +545,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print '
'; @@ -580,50 +580,50 @@ print '' print "
'; print $langs->trans("UseServicesDurationOnFichinter"); print ''; -print 'global->FICHINTER_USE_SERVICE_DURATION?' checked':'') . '>'; +print 'global->FICHINTER_USE_SERVICE_DURATION ? ' checked' : '').'>'; print ''; -print ''; +print ''; print '
'; print $langs->trans("UseDurationOnFichinter"); print ''; -print 'global->FICHINTER_WITHOUT_DURATION?' checked':'') . '>'; +print 'global->FICHINTER_WITHOUT_DURATION ? ' checked' : '').'>'; print ''; -print ''; +print ''; print '
'; print $langs->trans("UseDateWithoutHourOnFichinter"); print ''; -print 'global->FICHINTER_DATE_WITHOUT_HOUR?' checked':'') . '>'; +print 'global->FICHINTER_DATE_WITHOUT_HOUR ? ' checked' : '').'>'; print ''; -print ''; +print ''; print '
'; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -404,10 +404,10 @@ foreach ($dirmodels as $reldir) print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); print ''.$langs->trans("Value").' 
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='DELIVERY_FREE_TEXT'; +$variablename = 'DELIVERY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -466,7 +466,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print '
'; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index d459de3707b..c52f899a03f 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -111,6 +111,8 @@ if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $ * View */ +$form = new Form($db); + $linuxlike=1; if (preg_match('/^win/i', PHP_OS)) $linuxlike=0; if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0; @@ -139,8 +141,6 @@ $listofmethods['swiftmailer']='Swift Mailer socket library'; if ($action == 'edit') { - $form=new Form($db); - if ($conf->use_javascript_ajax) { print "\n".''; // Checkbox to select from free text -print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; +print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; print '
'; -if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)) +if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; print '
'; print '
'; $form->select_produits(GETPOST('productid'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); @@ -385,9 +385,9 @@ if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lir print '
'; } -if (! empty($user->rights->societe->lire)) +if (!empty($user->rights->societe->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; print '
'; print '
'; print $form->select_company(GETPOST('socid'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); @@ -435,7 +435,7 @@ print '
'; print '
'; -print '
'; +print '
'; print ''; print '
'; diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index cec6410b7b6..234aeceb2a6 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -67,12 +67,12 @@ class BlockedLogAuthority $this->signature = $block_static->getSignature(); - $blocks = $block_static->getLog('all', 0, 0, 'rowid', 'ASC') ; + $blocks = $block_static->getLog('all', 0, 0, 'rowid', 'ASC'); $this->blockchain = ''; - foreach($blocks as &$b) { - $this->blockchain.=$b->signature; + foreach ($blocks as &$b) { + $this->blockchain .= $b->signature; } return $this->blockchain; @@ -98,7 +98,7 @@ class BlockedLogAuthority public function checkBlockchain($hash) { - return ($hash === $this->getBlockchainHash() ); + return ($hash === $this->getBlockchainHash()); } /** @@ -110,7 +110,7 @@ class BlockedLogAuthority public function addBlock($block) { - $this->blockchain.=$block; + $this->blockchain .= $block; } /** @@ -122,14 +122,14 @@ class BlockedLogAuthority public function checkBlock($block) { - if(strlen($block)!=64) return false; + if (strlen($block) != 64) return false; $blocks = str_split($this->blockchain, 64); - if(!in_array($block, $blocks)) { + if (!in_array($block, $blocks)) { return true; } - else{ + else { return false; } } @@ -151,44 +151,44 @@ class BlockedLogAuthority if (empty($id) && empty($signature)) { - $this->error='BadParameter'; + $this->error = 'BadParameter'; return -1; } $langs->load("blockedlog"); $sql = "SELECT b.rowid, b.signature, b.blockchain, b.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b"; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b"; - if ($id) $sql.= " WHERE b.rowid = ". $id; - elseif($signature)$sql.= " WHERE b.signature = '". $this->db->escape($signature) ."'" ; + if ($id) $sql .= " WHERE b.rowid = ".$id; + elseif ($signature)$sql .= " WHERE b.signature = '".$this->db->escape($signature)."'"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->signature = $obj->signature; - $this->blockchain = $obj->blockchain; + $this->signature = $obj->signature; + $this->blockchain = $obj->blockchain; - $this->tms = $this->db->jdate($obj->tms); + $this->tms = $this->db->jdate($obj->tms); return 1; } else { - $this->error=$langs->trans("RecordNotFound"); + $this->error = $langs->trans("RecordNotFound"); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -202,23 +202,23 @@ class BlockedLogAuthority public function create($user) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; dol_syslog(get_class($this).'::create', LOG_DEBUG); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog_authority ("; - $sql.= " signature,"; - $sql.= " blockchain"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->signature)."',"; - $sql.= "'".$this->db->escape($this->blockchain)."'"; - $sql.= ")"; + $sql .= " signature,"; + $sql .= " blockchain"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->signature)."',"; + $sql .= "'".$this->db->escape($this->blockchain)."'"; + $sql .= ")"; $res = $this->db->query($sql); if ($res) @@ -241,7 +241,7 @@ class BlockedLogAuthority } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -256,19 +256,19 @@ class BlockedLogAuthority public function update($user) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; dol_syslog(get_class($this).'::create', LOG_DEBUG); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."blockedlog_authority SET "; - $sql.= " blockchain='".$this->db->escape($this->blockchain)."'"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " blockchain='".$this->db->escape($this->blockchain)."'"; + $sql .= " WHERE rowid=".$this->id; $res = $this->db->query($sql); if ($res) @@ -279,7 +279,7 @@ class BlockedLogAuthority } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -296,7 +296,7 @@ class BlockedLogAuthority //TODO create cron task on activation - if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { + if (empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { $this->error = $langs->trans('NoAuthorityURLDefined'); return -2; } @@ -307,14 +307,14 @@ class BlockedLogAuthority $blocks = $block_static->getLog('not_certified', 0, 0, 'rowid', 'ASC'); - $signature=$block_static->getSignature(); + $signature = $block_static->getSignature(); - foreach($blocks as &$block) { + foreach ($blocks as &$block) { $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; $res = file_get_contents($url); - echo $block->signature.' '.$url. ' '.$res.'
'; - if($res === 'blockalreadyadded' || $res === 'blockadded') { + echo $block->signature.' '.$url.' '.$res.'
'; + if ($res === 'blockalreadyadded' || $res === 'blockadded') { $block->setCertified(); } else { diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 14dbd9941b7..3c6f7563590 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -115,7 +115,7 @@ class BlockedLog public $ref_object = ''; public $object_data = null; - public $user_fullname=''; + public $user_fullname = ''; /** * Array of tracked event codes @@ -138,14 +138,14 @@ class BlockedLog $this->trackedevents = array(); - if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='logBILL_VALIDATE'; - if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='logBILL_DELETE'; - if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='logBILL_SENTBYMAIL'; - if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BlockedLogBillDownload'; - if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BlockedLogBillPreview'; + if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE'] = 'logBILL_VALIDATE'; + if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE'] = 'logBILL_DELETE'; + if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL'] = 'logBILL_SENTBYMAIL'; + if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD'] = 'BlockedLogBillDownload'; + if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW'] = 'BlockedLogBillPreview'; - if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='logPAYMENT_CUSTOMER_CREATE'; - if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='logPAYMENT_CUSTOMER_DELETE'; + if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE'] = 'logPAYMENT_CUSTOMER_CREATE'; + if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE'] = 'logPAYMENT_CUSTOMER_DELETE'; /* Supplier if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate'; @@ -158,12 +158,12 @@ class BlockedLog if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate'; */ - if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE']='logDON_VALIDATE'; - if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='logDON_DELETE'; + if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE'] = 'logDON_VALIDATE'; + if ($conf->don->enabled) $this->trackedevents['DON_DELETE'] = 'logDON_DELETE'; //if ($conf->don->enabled) $this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL'; - if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE']='logDONATION_PAYMENT_CREATE'; - if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE']='logDONATION_PAYMENT_DELETE'; + if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE'] = 'logDONATION_PAYMENT_CREATE'; + if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE'] = 'logDONATION_PAYMENT_DELETE'; /* if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate'; @@ -171,18 +171,18 @@ class BlockedLog if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate'; */ - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE']='logMEMBER_SUBSCRIPTION_CREATE'; - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY']='logMEMBER_SUBSCRIPTION_MODIFY'; - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE']='logMEMBER_SUBSCRIPTION_DELETE'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE'] = 'logMEMBER_SUBSCRIPTION_CREATE'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY'] = 'logMEMBER_SUBSCRIPTION_MODIFY'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE'] = 'logMEMBER_SUBSCRIPTION_DELETE'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE']='logPAYMENT_VARIOUS_CREATE'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY']='logPAYMENT_VARIOUS_MODIFY'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE']='logPAYMENT_VARIOUS_DELETE'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE'] = 'logPAYMENT_VARIOUS_CREATE'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = 'logPAYMENT_VARIOUS_MODIFY'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE'] = 'logPAYMENT_VARIOUS_DELETE'; // $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all POS modules - $moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || ! empty($conf->global->BANK_ENABLE_POS_CASHCONTROL)); - if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE']='logCASHCONTROL_VALIDATE'; + $moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL)); + if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE'] = 'logCASHCONTROL_VALIDATE'; } /** @@ -193,102 +193,102 @@ class BlockedLog { global $langs; - if($this->element === 'facture') { + if ($this->element === 'facture') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - if($this->element === 'invoice_supplier') { + if ($this->element === 'invoice_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $object = new FactureFournisseur($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment') { + elseif ($this->element === 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $object = new Paiement($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_supplier') { + elseif ($this->element === 'payment_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; $object = new PaiementFourn($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_donation') { + elseif ($this->element === 'payment_donation') { require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; $object = new PaymentDonation($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_various') { + elseif ($this->element === 'payment_various') { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; $object = new PaymentVarious($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'don' || $this->element === 'donation') { + elseif ($this->element === 'don' || $this->element === 'donation') { require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $object = new Don($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'subscription') { + elseif ($this->element === 'subscription') { require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $object = new Subscription($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'cashcontrol') { + elseif ($this->element === 'cashcontrol') { require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; $object = new CashControl($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } @@ -318,16 +318,16 @@ class BlockedLog { global $langs, $cachedUser; - if(empty($cachedUser))$cachedUser=array(); + if (empty($cachedUser))$cachedUser = array(); - if(empty($cachedUser[$this->fk_user])) { - $u=new User($this->db); - if($u->fetch($this->fk_user)>0) { + if (empty($cachedUser[$this->fk_user])) { + $u = new User($this->db); + if ($u->fetch($this->fk_user) > 0) { $cachedUser[$this->fk_user] = $u; } } - if(!empty($cachedUser[$this->fk_user])) { + if (!empty($cachedUser[$this->fk_user])) { return $cachedUser[$this->fk_user]->getNomUrl(1); } @@ -354,25 +354,25 @@ class BlockedLog // action $this->action = $action; // amount - $this->amounts= $amounts; + $this->amounts = $amounts; // date if ($object->element == 'payment' || $object->element == 'payment_supplier') { $this->date_object = $object->datepaye; } - elseif ($object->element=='payment_salary') + elseif ($object->element == 'payment_salary') { $this->date_object = $object->datev; } elseif ($object->element == 'payment_donation' || $object->element == 'payment_various') { - $this->date_object = $object->datepaid?$object->datepaid:$object->datep; + $this->date_object = $object->datepaid ? $object->datepaid : $object->datep; } - elseif ($object->element=='subscription') + elseif ($object->element == 'subscription') { $this->date_object = $object->dateh; } - elseif ($object->element=='cashcontrol') + elseif ($object->element == 'cashcontrol') { $this->date_object = $object->date_creation; } @@ -380,7 +380,7 @@ class BlockedLog $this->date_object = $object->date; } // ref - $this->ref_object = ((! empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases + $this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases // type of object $this->element = $object->element; // id of object @@ -388,11 +388,11 @@ class BlockedLog // Set object_data - $this->object_data=new stdClass(); + $this->object_data = new stdClass(); // Add fields to exclude $arrayoffieldstoexclude = array( - 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','last_main_doc','civility_id','contact','contact_id', - 'table_element_line','ismultientitymanaged','isextrafieldmanaged', + 'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id', + 'table_element_line', 'ismultientitymanaged', 'isextrafieldmanaged', 'linkedObjectsIds', 'linkedObjects', 'fk_delivery_address', @@ -402,48 +402,48 @@ class BlockedLog // Add more fields to exclude depending on object type if ($this->element == 'cashcontrol') { $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( - 'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code', - 'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2', - 'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id', - 'fk_incoterms','label_incoterms','location_incoterms','lines') + 'name', 'lastname', 'firstname', 'region', 'region_id', 'region_code', 'state', 'state_id', 'state_code', 'country', 'country_id', 'country_code', + 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2', + 'barcode_type', 'barcode_type_code', 'barcode_type_label', 'barcode_type_coder', 'mode_reglement_id', 'cond_reglement_id', 'mode_reglement', 'cond_reglement', 'shipping_method_id', + 'fk_incoterms', 'label_incoterms', 'location_incoterms', 'lines') ); } // Add thirdparty info if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty(); - if (! empty($object->thirdparty)) + if (!empty($object->thirdparty)) { $this->object_data->thirdparty = new stdClass(); - foreach($object->thirdparty as $key=>$value) + foreach ($object->thirdparty as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' - ))) continue; // Discard if not into a dedicated list + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->thirdparty->{$key} = $value; } } // Add company info - if (! empty($mysoc)) + if (!empty($mysoc)) { $this->object_data->mycompany = new stdClass(); - foreach($mysoc as $key=>$value) + foreach ($mysoc as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' - ))) continue; // Discard if not into a dedicated list + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->mycompany->{$key} = $value; } } // Add user info - if (! empty($user)) + if (!empty($user)) { $this->fk_user = $user->id; $this->user_fullname = $user->getFullName($langs); @@ -452,25 +452,25 @@ class BlockedLog // Field specific to object if ($this->element == 'facture') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'ref','ref_client','ref_supplier','date','datef','datev','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public','lines' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'datev', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public', 'lines' + ))) continue; // Discard if not into a dedicated list if ($key == 'lines') { - $lineid=0; - foreach($value as $tmpline) // $tmpline is object FactureLine + $lineid = 0; + foreach ($value as $tmpline) // $tmpline is object FactureLine { $lineid++; - foreach($tmpline as $keyline => $valueline) + foreach ($tmpline as $keyline => $valueline) { - if (! in_array($keyline, array( - 'ref','multicurrency_code','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','qty','product_type','vat_src_code','tva_tx','info_bits','localtax1_tx','localtax2_tx','total_ht','total_tva','total_ttc','total_localtax1','total_localtax2' - ))) continue; // Discard if not into a dedicated list + if (!in_array($keyline, array( + 'ref', 'multicurrency_code', 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'qty', 'product_type', 'vat_src_code', 'tva_tx', 'info_bits', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2' + ))) continue; // Discard if not into a dedicated list - if (! is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass(); + if (!is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass(); $this->object_data->invoiceline[$lineid]->{$keyline} = $valueline; } @@ -479,43 +479,43 @@ class BlockedLog elseif (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } elseif ($this->element == 'invoice_supplier') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'ref','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public' + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various') { - $datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep); - $paymenttypeid = $object->paiementid?$object->paiementid:($object->paymenttype?$object->paymenttype:$object->type_payment); + $datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep); + $paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment); $this->object_data->ref = $object->ref; $this->object_data->date = $datepayment; $this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code'); - $this->object_data->payment_num = ($object->num_paiement?$object->num_paiement:$object->num_payment); + $this->object_data->payment_num = ($object->num_paiement ? $object->num_paiement : $object->num_payment); //$this->object_data->fk_account = $object->fk_account; $this->object_data->note = $object->note; //var_dump($this->object_data);exit; - $totalamount=0; + $totalamount = 0; - if (! is_array($object->amounts) && $object->amount) + if (!is_array($object->amounts) && $object->amount) { - $object->amounts=array($object->id => $object->amount); + $object->amounts = array($object->id => $object->amount); } - $paymentpartnumber=0; - foreach($object->amounts as $objid => $amount) + $paymentpartnumber = 0; + foreach ($object->amounts as $objid => $amount) { if (empty($amount)) continue; @@ -543,7 +543,7 @@ class BlockedLog $tmpobject = new PaymentVarious($this->db); } - if (! is_object($tmpobject)) + if (!is_object($tmpobject)) { continue; } @@ -561,12 +561,12 @@ class BlockedLog $paymentpart = new stdClass(); $paymentpart->amount = $amount; - if (! in_array($this->element, array('payment_donation', 'payment_various'))) + if (!in_array($this->element, array('payment_donation', 'payment_various'))) { $result = $tmpobject->fetch_thirdparty(); if ($result == 0) { - $this->error='Failed to fetch thirdparty for object with id '.$tmpobject->id; + $this->error = 'Failed to fetch thirdparty for object with id '.$tmpobject->id; $this->errors[] = $this->error; dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR); return -1; @@ -610,43 +610,43 @@ class BlockedLog } } - $paymentpartnumber++; // first payment will be 1 + $paymentpartnumber++; // first payment will be 1 $this->object_data->payment_part[$paymentpartnumber] = $paymentpart; } } $this->object_data->amount = $totalamount; - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } - elseif($this->element == 'payment_salary') + elseif ($this->element == 'payment_salary') { $this->object_data->amounts = array($object->amount); - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } - elseif($this->element == 'subscription') + elseif ($this->element == 'subscription') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'id','datec','dateh','datef','fk_adherent','amount','import_key','statut','note' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'id', 'datec', 'dateh', 'datef', 'fk_adherent', 'amount', 'import_key', 'statut', 'note' + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } else // Generic case { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } return 1; @@ -667,59 +667,59 @@ class BlockedLog if (empty($id)) { - $this->error='BadParameter'; + $this->error = 'BadParameter'; return -1; } $langs->load("blockedlog"); $sql = "SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,"; - $sql.= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; - if ($id) $sql.= " WHERE b.rowid = ". $id; + $sql .= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data"; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; + if ($id) $sql .= " WHERE b.rowid = ".$id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->entity = $obj->entity; + $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_creation = $this->db->jdate($obj->date_creation); $this->tms = $this->db->jdate($obj->tms); $this->amounts = (double) $obj->amounts; - $this->action = $obj->action; + $this->action = $obj->action; $this->element = $obj->element; - $this->fk_object = $obj->fk_object; - $this->date_object = $this->db->jdate($obj->date_object); - $this->ref_object = $obj->ref_object; + $this->fk_object = $obj->fk_object; + $this->date_object = $this->db->jdate($obj->date_object); + $this->ref_object = $obj->ref_object; - $this->fk_user = $obj->fk_user; - $this->user_fullname = $obj->user_fullname; + $this->fk_user = $obj->fk_user; + $this->user_fullname = $obj->user_fullname; - $this->object_data = $this->dolDecodeBlockedData($obj->object_data); + $this->object_data = $this->dolDecodeBlockedData($obj->object_data); $this->signature = $obj->signature; - $this->signature_line = $obj->signature_line; + $this->signature_line = $obj->signature_line; $this->certified = ($obj->certified == 1); return 1; } else { - $this->error=$langs->trans("RecordNotFound"); + $this->error = $langs->trans("RecordNotFound"); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -739,7 +739,7 @@ class BlockedLog //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $aaa = unserialize($data); //$aaa = unserialize($data); - } catch(Exception $e) { + } catch (Exception $e) { //print $e->getErrs); } return $aaa; @@ -755,7 +755,7 @@ class BlockedLog { $res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id); - if($res===false) return false; + if ($res === false) return false; return true; } @@ -770,82 +770,82 @@ class BlockedLog public function create($user, $forcesignature = '') { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; // Clean data - $this->amounts=(double) $this->amounts; + $this->amounts = (double) $this->amounts; dol_syslog(get_class($this).'::create action='.$this->action.' fk_user='.$this->fk_user.' user_fullname='.$this->user_fullname, LOG_DEBUG); // Check parameters/properties - if (! isset($this->amounts)) // amount can be 0 for some events (like when module is disabled) + if (!isset($this->amounts)) // amount can be 0 for some events (like when module is disabled) { - $this->error=$langs->trans("BlockLogNeedAmountsValue"); + $this->error = $langs->trans("BlockLogNeedAmountsValue"); dol_syslog($this->error, LOG_WARNING); return -1; } if (empty($this->element)) { - $this->error=$langs->trans("BlockLogNeedElement"); + $this->error = $langs->trans("BlockLogNeedElement"); dol_syslog($this->error, LOG_WARNING); return -2; } if (empty($this->action)) { - $this->error=$langs->trans("BadParameterWhenCallingCreateOfBlockedLog"); + $this->error = $langs->trans("BadParameterWhenCallingCreateOfBlockedLog"); dol_syslog($this->error, LOG_WARNING); return -3; } - if (empty($this->fk_user)) $this->user_fullname='(Anonymous)'; + if (empty($this->fk_user)) $this->user_fullname = '(Anonymous)'; $this->date_creation = dol_now(); $this->db->begin(); - $previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done + $previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done $keyforsignature = $this->buildKeyForSignature(); - $this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull - $this->signature = dol_hash($previoushash . $keyforsignature, '5'); + $this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull + $this->signature = dol_hash($previoushash.$keyforsignature, '5'); if ($forcesignature) $this->signature = $forcesignature; //var_dump($keyforsignature);var_dump($previoushash);var_dump($this->signature_line);var_dump($this->signature); $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; - $sql.= " date_creation,"; - $sql.= " action,"; - $sql.= " amounts,"; - $sql.= " signature,"; - $sql.= " signature_line,"; - $sql.= " element,"; - $sql.= " fk_object,"; - $sql.= " date_object,"; - $sql.= " ref_object,"; - $sql.= " object_data,"; - $sql.= " certified,"; - $sql.= " fk_user,"; - $sql.= " user_fullname,"; - $sql.= " entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($this->date_creation)."',"; - $sql.= "'".$this->db->escape($this->action)."',"; - $sql.= $this->amounts.","; - $sql.= "'".$this->db->escape($this->signature)."',"; - $sql.= "'".$this->db->escape($this->signature_line)."',"; - $sql.= "'".$this->db->escape($this->element)."',"; - $sql.= $this->fk_object.","; - $sql.= "'".$this->db->idate($this->date_object)."',"; - $sql.= "'".$this->db->escape($this->ref_object)."',"; - $sql.= "'".$this->db->escape(serialize($this->object_data))."',"; - $sql.= "0,"; - $sql.= $this->fk_user.","; - $sql.= "'".$this->db->escape($this->user_fullname)."',"; - $sql.= ($this->entity ? $this->entity : $conf->entity); - $sql.= ")"; + $sql .= " date_creation,"; + $sql .= " action,"; + $sql .= " amounts,"; + $sql .= " signature,"; + $sql .= " signature_line,"; + $sql .= " element,"; + $sql .= " fk_object,"; + $sql .= " date_object,"; + $sql .= " ref_object,"; + $sql .= " object_data,"; + $sql .= " certified,"; + $sql .= " fk_user,"; + $sql .= " user_fullname,"; + $sql .= " entity"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($this->date_creation)."',"; + $sql .= "'".$this->db->escape($this->action)."',"; + $sql .= $this->amounts.","; + $sql .= "'".$this->db->escape($this->signature)."',"; + $sql .= "'".$this->db->escape($this->signature_line)."',"; + $sql .= "'".$this->db->escape($this->element)."',"; + $sql .= $this->fk_object.","; + $sql .= "'".$this->db->idate($this->date_object)."',"; + $sql .= "'".$this->db->escape($this->ref_object)."',"; + $sql .= "'".$this->db->escape(serialize($this->object_data))."',"; + $sql .= "0,"; + $sql .= $this->fk_user.","; + $sql .= "'".$this->db->escape($this->user_fullname)."',"; + $sql .= ($this->entity ? $this->entity : $conf->entity); + $sql .= ")"; $res = $this->db->query($sql); if ($res) @@ -868,7 +868,7 @@ class BlockedLog } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -891,8 +891,8 @@ class BlockedLog // Recalculate hash $keyforsignature = $this->buildKeyForSignature(); - $signature_line = dol_hash($keyforsignature, '5'); // Not really usefull - $signature = dol_hash($previoushash . $keyforsignature, '5'); + $signature_line = dol_hash($keyforsignature, '5'); // Not really usefull + $signature = dol_hash($previoushash.$keyforsignature, '5'); //var_dump($previoushash); var_dump($keyforsignature); var_dump($signature_line); var_dump($signature); $res = ($signature === $this->signature); @@ -929,13 +929,13 @@ class BlockedLog { global $conf; - $previoussignature=''; + $previoussignature = ''; $sql = "SELECT rowid, signature FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity=".$conf->entity; - if ($beforeid) $sql.= " AND rowid < ".(int) $beforeid; - $sql.=" ORDER BY rowid DESC LIMIT 1"; - $sql.=($withlock ? " FOR UPDATE ": ""); + $sql .= " WHERE entity=".$conf->entity; + if ($beforeid) $sql .= " AND rowid < ".(int) $beforeid; + $sql .= " ORDER BY rowid DESC LIMIT 1"; + $sql .= ($withlock ? " FOR UPDATE " : ""); $resql = $this->db->query($sql); if ($resql) { @@ -981,38 +981,38 @@ class BlockedLog global $conf, $cachedlogs; /* $cachedlogs allow fastest search */ - if (empty($cachedlogs)) $cachedlogs=array(); + if (empty($cachedlogs)) $cachedlogs = array(); - if ($element=='all') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + if ($element == 'all') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity; } - elseif ($element=='not_certified') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + elseif ($element == 'not_certified') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 0"; } - elseif ($element=='just_certified') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + elseif ($element == 'just_certified') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 1"; } - else{ - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + else { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND element='".$element."' AND fk_object=".(int) $fk_object; } - if ($search_fk_user > 0) $sql.=natural_search("fk_user", $search_fk_user, 2); - if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'"; - if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'"; - if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref); - if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1); - if ($search_code != '' && $search_code != '-1') $sql.=natural_search("action", $search_code, 3); + if ($search_fk_user > 0) $sql .= natural_search("fk_user", $search_fk_user, 2); + if ($search_start > 0) $sql .= " AND date_creation >= '".$this->db->idate($search_start)."'"; + if ($search_end > 0) $sql .= " AND date_creation <= '".$this->db->idate($search_end)."'"; + if ($search_ref != '') $sql .= natural_search("ref_object", $search_ref); + if ($search_amount != '') $sql .= natural_search("amounts", $search_amount, 1); + if ($search_code != '' && $search_code != '-1') $sql .= natural_search("action", $search_code, 3); - $sql.=$this->db->order($sortfield, $sortorder); - $sql.=$this->db->plimit($limit+1); // We want more, because we will stop into loop later with error if we reach max + $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit + 1); // We want more, because we will stop into loop later with error if we reach max $res = $this->db->query($sql); - if($res) { - $results=array(); + if ($res) { + $results = array(); $i = 0; while ($obj = $this->db->fetch_object($res)) @@ -1026,7 +1026,7 @@ class BlockedLog if (!isset($cachedlogs[$obj->rowid])) { - $b=new BlockedLog($this->db); + $b = new BlockedLog($this->db); $b->fetch($obj->rowid); $cachedlogs[$obj->rowid] = $b; @@ -1048,7 +1048,7 @@ class BlockedLog */ public function getSignature() { - global $db,$conf,$mysoc; + global $db, $conf, $mysoc; if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -1059,7 +1059,7 @@ class BlockedLog dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine', 0, 'Numeric Unique Fingerprint', $conf->entity); - $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT=$fingerprint; + $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint; } return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; @@ -1079,12 +1079,12 @@ class BlockedLog $result = false; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity = ".$conf->entity; - if ($ignoresystem) $sql.=" AND action not in ('MODULE_SET','MODULE_RESET')"; - $sql.= $this->db->plimit(1); + $sql .= " WHERE entity = ".$conf->entity; + if ($ignoresystem) $sql .= " AND action not in ('MODULE_SET','MODULE_RESET')"; + $sql .= $this->db->plimit(1); $res = $this->db->query($sql); - if ($res!==false) + if ($res !== false) { $obj = $this->db->fetch_object($res); if ($obj) $result = true; diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index d892c1df0e6..6fffbd3ed52 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($langs) || ! is_object($langs)) +if (empty($langs) || !is_object($langs)) { print "Error, template page can't be called as URL"; exit; @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array("main","bills","cashdesk")); +$langs->loadLangs(array("main", "bills", "cashdesk")); ?> @@ -45,18 +45,18 @@ $societe = new Societe($db); $societe->fetch($thirdpartyid); /** end add Ditto */ -$tab = (! empty($_SESSION['poscart'])?$_SESSION['poscart']:array()); +$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); -$tab_size=count($tab); +$tab_size = count($tab); if ($tab_size <= 0) print '
'.$langs->trans("NoArticle").'

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

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

'."\n"); - if ( $tab[$i]['remise_percent'] > 0 ) { + if ($tab[$i]['remise_percent'] > 0) { $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; } else { $remise_percent = ''; diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index fcbd95e8f29..4bc66eff4ad 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -17,14 +17,14 @@ */ // Protection to avoid direct call of template -if (empty($langs) || ! is_object($langs)) +if (empty($langs) || !is_object($langs)) { print "Error, template page can't be called as URL"; exit; } // Load translation files required by the page -$langs->loadLangs(array("main","bills","banks")); +$langs->loadLangs(array("main", "bills", "banks")); // Object $form must de defined @@ -53,30 +53,30 @@ else { case 'ESP': echo $langs->trans("Cash"); - $filtre='courant=2'; + $filtre = 'courant=2'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]; break; case 'CB': echo $langs->trans("CreditCard"); - $filtre='courant=1'; + $filtre = 'courant=1'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]; break; case 'CHQ': echo $langs->trans("Cheque"); - $filtre='courant=1'; + $filtre = 'courant=1'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]; break; case 'DIF': echo $langs->trans("Reported"); - $filtre='courant=1 OR courant=2'; - $selected=''; + $filtre = 'courant=1 OR courant=2'; + $selected = ''; break; default: - $filtre='courant=1 OR courant=2'; - $selected=''; + $filtre = 'courant=1 OR courant=2'; + $selected = ''; } ?> @@ -103,7 +103,7 @@ if ( $obj_facturation->montantRendu() ) {

trans("BankToPay"). "
"; + echo $langs->trans("BankToPay")."
"; $form->select_comptes($selected, 'cashdeskbank', 0, $filtre); ?>

diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 0e71f52a955..47110da8a92 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -76,11 +76,12 @@ class Categories extends DolibarrApi * Return an array with category informations * * @param int $id ID of category + * @param bool $include_childs Include child categories list (true or false) * @return array|mixed data without useless information * * @throws RestException */ - public function get($id) + public function get($id, $include_childs = false) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -95,6 +96,17 @@ class Categories extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + if ($include_childs) { + $cats = $this->category->get_filles(); + if (!is_array($cats)) { + throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors)); + } + $this->category->childs = []; + foreach ($cats as $cat) { + $this->category->childs[] = $this->_cleanObjectDatas($cat); + } + } + return $this->_cleanObjectDatas($this->category); } @@ -270,6 +282,58 @@ class Categories extends DolibarrApi ); } + /** + * List categories of an object + * + * Get the list of categories linked to an object + * + * @param int $id Object ID + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @return array Array of category objects + * + * @throws RestException + * + * @url GET /object/{type}/{id} + */ + public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + { + if (!in_array($type, [ + Categorie::TYPE_PRODUCT, + Categorie::TYPE_CONTACT, + Categorie::TYPE_CUSTOMER, + Categorie::TYPE_SUPPLIER, + Categorie::TYPE_MEMBER + ])) { + throw new RestException(401); + } + + if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } + + $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); + + if( ! is_array($categories)) { + if ($categories == 0) { + throw new RestException(404, 'No category found for this object'); + } + throw new RestException(500, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors)); + } + return $categories; + } + /** * Link an object to a category by id * @@ -297,12 +361,31 @@ class Categories extends DolibarrApi throw new RestException(404, 'category not found'); } - // TODO Add all types - if ($type === "product") { + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -358,12 +441,31 @@ class Categories extends DolibarrApi throw new RestException(404, 'category not found'); } - // TODO Add all types - if ($type === "product") { + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -419,12 +521,31 @@ class Categories extends DolibarrApi throw new RestException(404, 'category not found'); } - // TODO Add all types - if ($type === "product") { + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -478,12 +599,31 @@ class Categories extends DolibarrApi throw new RestException(404, 'category not found'); } - // TODO Add all types - if ($type === "product") { + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index e30d758eb14..525ee23c8bf 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -110,7 +110,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'socpeople', 'user' => 'user', - 'account' => 'account', // old key for bank_account + 'account' => 'account', // old key for bank_account 'bank_account' => 'account', 'project' => 'project', 'warehouse'=> 'warehouse', @@ -129,7 +129,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'contact', 'user' => 'user', - 'account' => 'account', // old key for bank_account + 'account' => 'account', // old key for bank_account 'bank_account'=> 'account', 'project' => 'project', 'warehouse'=> 'warehouse', @@ -248,25 +248,30 @@ class Categorie extends CommonObject /** * Load category into memory from database * - * @param int $id Id of category - * @param string $label Label of category - * @param string $type Type of category ('product', '...') or (0, 1, ...) + * @param int $id Id of category + * @param string $label Label of category + * @param string $type Type of category ('product', '...') or (0, 1, ...) + * @param string $ref_ext External reference of object * @return int <0 if KO, >0 if OK */ - public function fetch($id, $label = '', $type = null) + public function fetch($id, $label = '', $type = null, $ref_ext = '') { global $conf; // Check parameters - if (empty($id) && empty($label)) return -1; + if (empty($id) && empty($label) && empty($ref_ext)) return -1; if (!is_numeric($type)) $type = $this->MAP_ID[$type]; - $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type"; + $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; if ($id > 0) { $sql .= " WHERE rowid = ".$id; } + elseif (!empty($ref_ext)) + { + $sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'"; + } else { $sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; @@ -290,6 +295,7 @@ class Categorie extends CommonObject $this->socid = $res['fk_soc']; $this->visible = $res['visible']; $this->type = $res['type']; + $this->ref_ext = $res['ref_ext']; $this->entity = $res['entity']; // Retreive all extrafield @@ -342,6 +348,7 @@ class Categorie extends CommonObject $this->description = trim($this->description); $this->color = trim($this->color); $this->import_key = trim($this->import_key); + $this->ref_ext = trim($this->ref_ext); if (empty($this->visible)) $this->visible = 0; $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); @@ -367,6 +374,7 @@ class Categorie extends CommonObject $sql .= " visible,"; $sql .= " type,"; $sql .= " import_key,"; + $sql .= " ref_ext,"; $sql .= " entity"; $sql .= ") VALUES ("; $sql .= $this->db->escape($this->fk_parent).","; @@ -380,6 +388,7 @@ class Categorie extends CommonObject $sql .= "'".$this->db->escape($this->visible)."',"; $sql .= $this->db->escape($type).","; $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').","; + $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').","; $sql .= $this->db->escape($conf->entity); $sql .= ")"; @@ -454,6 +463,7 @@ class Categorie extends CommonObject // Clean parameters $this->label = trim($this->label); $this->description = trim($this->description); + $this->ref_ext = trim($this->ref_ext); $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); $this->visible = ($this->visible != "" ? intval($this->visible) : 0); @@ -469,6 +479,7 @@ class Categorie extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; $sql .= " SET label = '".$this->db->escape($this->label)."',"; $sql .= " description = '".$this->db->escape($this->description)."',"; + $sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',"; $sql .= " color = '".$this->db->escape($this->color)."'"; if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { @@ -861,29 +872,29 @@ class Categorie extends CommonObject $sub_type = $type; $subcol_name = "fk_".$type; - if ($type=="customer") { - $sub_type="societe"; - $subcol_name="fk_soc"; + if ($type == "customer") { + $sub_type = "societe"; + $subcol_name = "fk_soc"; } - if ($type=="supplier") { - $sub_type="fournisseur"; - $subcol_name="fk_soc"; + if ($type == "supplier") { + $sub_type = "fournisseur"; + $subcol_name = "fk_soc"; } - if ($type=="contact") { - $subcol_name="fk_socpeople"; + if ($type == "contact") { + $subcol_name = "fk_socpeople"; } $idoftype = array_search($type, self::$MAP_ID_TO_CODE); $sql = "SELECT s.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; - $sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; - $sql.= ' WHERE s.entity IN ('.getEntity('category').')'; - $sql.= ' AND s.type='.$idoftype; - $sql.= ' AND s.rowid = sub.fk_categorie'; - $sql.= ' AND sub.'.$subcol_name.' = '.$id; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as s"; + $sql .= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; + $sql .= ' WHERE s.entity IN ('.getEntity('category').')'; + $sql .= ' AND s.type='.$idoftype; + $sql .= ' AND s.rowid = sub.fk_categorie'; + $sql .= ' AND sub.'.$subcol_name.' = '.$id; - $sql.= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); $offset = 0; $nbtotalofrecords = ''; @@ -905,13 +916,13 @@ class Categorie extends CommonObject } $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; + $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -926,6 +937,7 @@ class Categorie extends CommonObject $categories[$i]['description'] = $category_static->description; $categories[$i]['color'] = $category_static->color; $categories[$i]['socid'] = $category_static->socid; + $categories[$i]['ref_ext'] = $category_static->ref_ext; $categories[$i]['visible'] = $category_static->visible; $categories[$i]['type'] = $category_static->type; $categories[$i]['entity'] = $category_static->entity; @@ -1090,6 +1102,7 @@ class Categorie extends CommonObject $this->cats[$obj->rowid]['description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description; $this->cats[$obj->rowid]['color'] = $obj->color; $this->cats[$obj->rowid]['visible'] = $obj->visible; + $this->cats[$obj->rowid]['ref_ext'] = $obj->ref_ext; $i++; } } @@ -1644,8 +1657,8 @@ class Categorie extends CommonObject if (is_array($file['name']) && count($file['name']) > 0) { $nbfile = count($file['name']); - for ($i = 0; $i <= $nbfile; $i ++) { - $originImage = $dir . $file['name'][$i]; + for ($i = 0; $i <= $nbfile; $i++) { + $originImage = $dir.$file['name'][$i]; // Cree fichier en taille origine dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 5dbd6e68c47..2556c2d2084 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; $langs->loadlangs(array('categories', 'bills')); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref'); -$type=GETPOST('type'); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref'); +$type = GETPOST('type'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); -if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if ($id == "") { @@ -66,7 +66,7 @@ if ($id > 0) * Actions */ -if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->id) { $file = $_FILES['userfile']; @@ -74,15 +74,15 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sen { foreach ($file['name'] as $i => $name) { - if(empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i]) ) + if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) { - setEventMessage($file['name'][$i] .' : '. $langs->trans(empty($file['tmp_name'][$i])? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); + setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]); } } } - if(!empty($file['tmp_name'])) { + if (!empty($file['tmp_name'])) { $object->add_photo($upload_dir, $file); } } @@ -110,15 +110,15 @@ $formother = new FormOther($db); if ($object->id) { - if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); - elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); - elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); - elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); - elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); - elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); - elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); - elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort"); - else $title=$langs->trans("Category"); + if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort"); + elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort"); + elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort"); + elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort"); + elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); + elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); + elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); + elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); + else $title = $langs->trans("Category"); $head = categories_prepare_head($object, $type); @@ -181,7 +181,7 @@ if ($object->id) if ($action != 'ajout_photo' && $user->rights->categorie->creer) { - if (! empty($conf->global->MAIN_UPLOAD_DOC)) + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { print ''; print $langs->trans("AddPhoto").''; @@ -198,23 +198,23 @@ if ($object->id) /* * Ajouter une photo */ - if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC)) + if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) { // Affiche formulaire upload - $formfile=new FormFile($db); + $formfile = new FormFile($db); $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type, $langs->trans("AddPhoto"), 1, '', $user->rights->categorie->creer, 50, $object, '', false, '', 0); } // Affiche photos if ($action != 'ajout_photo') { - $nbphoto=0; - $nbbyrow=5; + $nbphoto = 0; + $nbbyrow = 5; $maxWidth = 160; $maxHeight = 120; - $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category') . $object->id ."/photos/"; + $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/"; $dir = $upload_dir.'/'.$pdir; $listofphoto = $object->liste_photos($dir); @@ -229,22 +229,22 @@ if ($object->id) $nbphoto++; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '
'; + if ($nbbyrow) print ''; print ''; // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine if ($obj['photo_vignette']) { - $filename=$obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } // Nom affiche - $viewfilename=$obj['photo']; + $viewfilename = $obj['photo']; // Taille de l'image $object->get_image_size($dir.$filename); @@ -274,7 +274,7 @@ if ($object->id) // Ferme tableau while ($nbphoto % $nbbyrow) { - print '  '; if ($action == 'editshipping') { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'shipping_method_id'); + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 67ec7414e7c..9c589c4ae3d 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -35,7 +35,7 @@ class FormAdvTargetEmailing extends Form /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * Constructor @@ -62,15 +62,15 @@ class FormAdvTargetEmailing extends Form $options_array = array(); $sql = "SELECT code, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_prospectlevel"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; - dol_syslog(get_class($this) . '::multiselectProspectionStatus sql=' . $sql, LOG_DEBUG); + dol_syslog(get_class($this).'::multiselectProspectionStatus sql='.$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $level = $langs->trans($obj->code); @@ -78,7 +78,7 @@ class FormAdvTargetEmailing extends Form $level = $langs->trans($obj->label); $options_array[$obj->code] = $level; - $i ++; + $i++; } } else { dol_print_error($this->db); @@ -102,16 +102,16 @@ class FormAdvTargetEmailing extends Form $out = ''; $countryArray = array(); - $label = array (); + $label = array(); $options_array = array(); $sql = "SELECT rowid, code as code_iso, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_country"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_country"; $sql .= " WHERE active = 1 AND code<>''"; $sql .= " ORDER BY code ASC"; - dol_syslog(get_class($this) . "::select_country sql=" . $sql); + dol_syslog(get_class($this)."::select_country sql=".$sql); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -123,9 +123,9 @@ class FormAdvTargetEmailing extends Form $obj = $this->db->fetch_object($resql); $countryArray [$i] ['rowid'] = $obj->rowid; $countryArray [$i] ['code_iso'] = $obj->code_iso; - $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv("Country" . $obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); + $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); $label[$i] = $countryArray[$i]['label']; - $i ++; + $i++; } array_multisort($label, SORT_ASC, $countryArray); @@ -133,7 +133,7 @@ class FormAdvTargetEmailing extends Form foreach ($countryArray as $row) { $label = dol_trunc($row['label'], $maxlength, 'middle'); if ($row['code_iso']) - $label .= ' (' . $row['code_iso'] . ')'; + $label .= ' ('.$row['code_iso'].')'; $options_array[$row['rowid']] = $label; } @@ -158,23 +158,23 @@ class FormAdvTargetEmailing extends Form global $conf; - $options_array = array (); + $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 . ")"; + $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.")"; $sql_usr .= " AND u2.rowid = sc.fk_user "; - if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) $sql_usr .= " AND u2.statut<>0 "; $sql_usr .= " ORDER BY name ASC"; // print $sql_usr;exit; $resql_usr = $this->db->query($sql_usr); if ($resql_usr) { - while ( $obj_usr = $this->db->fetch_object($resql_usr) ) { - $label = $obj_usr->firstname . " " . $obj_usr->name . " (" . $obj_usr->login . ')'; + while ($obj_usr = $this->db->fetch_object($resql_usr)) { + $label = $obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')'; $options_array [$obj_usr->rowid] = $label; } @@ -196,11 +196,11 @@ class FormAdvTargetEmailing extends Form public function multiselectselectLanguage($htmlname = '', $selected_array = array()) { - global $conf,$langs; + global $conf, $langs; - $options_array = array (); + $options_array = array(); - $langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); + $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); foreach ($langs_available as $key => $value) { @@ -222,7 +222,7 @@ class FormAdvTargetEmailing extends Form */ public function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array()) { - $options_array=array(); + $options_array = array(); if (is_array($sqlqueryparam)) { @@ -238,39 +238,39 @@ class FormAdvTargetEmailing extends Form if (count($InfoFieldList) >= 3) { if (strpos($InfoFieldList [3], 'extra.') !== false) { - $keyList = 'main.' . $InfoFieldList [2] . ' as rowid'; + $keyList = 'main.'.$InfoFieldList [2].' as rowid'; } else { - $keyList = $InfoFieldList [2] . ' as rowid'; + $keyList = $InfoFieldList [2].' as rowid'; } } - $sql = 'SELECT ' . $keyList . ', ' . $InfoFieldList [1]; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList [0]; - if (! empty($InfoFieldList [3])) { + $sql = 'SELECT '.$keyList.', '.$InfoFieldList [1]; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList [0]; + if (!empty($InfoFieldList [3])) { // We have to join on extrafield table if (strpos($InfoFieldList [3], 'extra') !== false) { - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList [0] . '_extrafields as extra'; - $sql .= ' WHERE extra.fk_object=main.' . $InfoFieldList [2] . ' AND ' . $InfoFieldList [3]; + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList [0].'_extrafields as extra'; + $sql .= ' WHERE extra.fk_object=main.'.$InfoFieldList [2].' AND '.$InfoFieldList [3]; } else { - $sql .= ' WHERE ' . $InfoFieldList [3]; + $sql .= ' WHERE '.$InfoFieldList [3]; } } - if (! empty($InfoFieldList[1])) { + if (!empty($InfoFieldList[1])) { $sql .= " ORDER BY nom"; } // $sql.= ' WHERE entity = '.$conf->entity; - dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; if ($num) { - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $labeltoshow = dol_trunc($obj->$InfoFieldList [1], 90); - $options_array[$obj->rowid]=$labeltoshow; - $i ++; + $options_array[$obj->rowid] = $labeltoshow; + $i++; } } $this->db->free($resql); @@ -289,17 +289,17 @@ class FormAdvTargetEmailing extends Form */ public function multiselectCivility($htmlname = 'civilite_id', $selected_array = array()) { - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->load("dict"); - $options_array=array(); + $options_array = array(); $sql = "SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX."c_civility"; - $sql.= " WHERE active = 1"; + $sql .= " WHERE active = 1"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -310,10 +310,10 @@ class FormAdvTargetEmailing extends Form { $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:'')); + $label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : '')); - $options_array[$obj->code]=$label; + $options_array[$obj->code] = $label; $i++; } @@ -340,7 +340,7 @@ class FormAdvTargetEmailing extends Form { global $conf, $langs; - $form=new Form($this->db); + $form = new Form($this->db); $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0, '', 0, 295); return $return; } @@ -379,16 +379,16 @@ class FormAdvTargetEmailing extends Form */ public function multiselectCategories($htmlname = '', $selected_array = array(), $type = 0) { - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->load("dict"); - $options_array=array(); + $options_array = array(); $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE type=".$type; + $sql .= " WHERE type=".$type; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -399,7 +399,7 @@ class FormAdvTargetEmailing extends Form { $obj = $this->db->fetch_object($resql); - $options_array[$obj->rowid]=$obj->label; + $options_array[$obj->rowid] = $obj->label; $i++; } @@ -429,32 +429,32 @@ class FormAdvTargetEmailing extends Form $out = ''; $sql = "SELECT c.rowid, c.name, c.fk_element"; - $sql .= " FROM " . MAIN_DB_PREFIX . "advtargetemailing as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as c"; $sql .= " WHERE type_element='$type_element'"; $sql .= " ORDER BY c.name"; - dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $out .= ''; if ($showempty) $out .= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) { - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $label = $obj->name; if (empty($label)) { - $label=$obj->fk_element; + $label = $obj->fk_element; } if ($selected > 0 && $selected == $obj->rowid) { - $out .= ''; + $out .= ''; } else { - $out .= ''; + $out .= ''; } - $i ++; + $i++; } } $out .= ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 57cff121010..ec29e4e5240 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -28,7 +28,7 @@ * \ingroup bank * \brief File of class to manage bank accounts */ -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -92,7 +92,7 @@ class Account extends CommonObject * Does it need to be conciliated? * @var int */ - public $rappro=1; + public $rappro = 1; /** * Webpage @@ -315,18 +315,18 @@ class Account extends CommonObject { // phpcs:enable $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; - $sql.= "fk_bank"; - $sql.= ", url_id"; - $sql.= ", url"; - $sql.= ", label"; - $sql.= ", type"; - $sql.= ") VALUES ("; - $sql.= "'".$line_id."'"; - $sql.= ", '".$url_id."'"; - $sql.= ", '".$url."'"; - $sql.= ", '".$this->db->escape($label)."'"; - $sql.= ", '".$type."'"; - $sql.= ")"; + $sql .= "fk_bank"; + $sql .= ", url_id"; + $sql .= ", url"; + $sql .= ", label"; + $sql .= ", type"; + $sql .= ") VALUES ("; + $sql .= "'".$line_id."'"; + $sql .= ", '".$url_id."'"; + $sql .= ", '".$url."'"; + $sql .= ", '".$this->db->escape($label)."'"; + $sql .= ", '".$type."'"; + $sql .= ")"; dol_syslog(get_class($this)."::add_url_line", LOG_DEBUG); if ($this->db->query($sql)) @@ -336,7 +336,7 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -357,20 +357,20 @@ class Account extends CommonObject $lines = array(); // Check parameters - if (! empty($fk_bank) && (! empty($url_id) || ! empty($type))) + if (!empty($fk_bank) && (!empty($url_id) || !empty($type))) { - $this->error="ErrorBadParameter"; + $this->error = "ErrorBadParameter"; return -1; } $sql = "SELECT fk_bank, url_id, url, label, type"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_url"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_url"; if ($fk_bank > 0) { - $sql.= " WHERE fk_bank = ".$fk_bank; + $sql .= " WHERE fk_bank = ".$fk_bank; } - else { $sql.= " WHERE url_id = ".$url_id." AND type = '".$type."'"; + else { $sql .= " WHERE url_id = ".$url_id." AND type = '".$type."'"; } - $sql.= " ORDER BY type, label"; + $sql .= " ORDER BY type, label"; dol_syslog(get_class($this)."::get_url", LOG_DEBUG); $result = $this->db->query($sql); @@ -420,25 +420,25 @@ class Account extends CommonObject { // Deprecation warning if (is_numeric($oper)) { - dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING); + dol_syslog(__METHOD__.": using numeric operations is deprecated", LOG_WARNING); } // Clean parameters - $emetteur=trim($emetteur); - $banque=trim($banque); + $emetteur = trim($emetteur); + $banque = trim($banque); - $now=dol_now(); + $now = dol_now(); if (is_numeric($oper)) // Clean operation to have a code instead of a rowid { $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; - $sql.= " WHERE id=".$oper; - $sql.= " AND entity IN (".getEntity('c_paiement').")"; - $resql=$this->db->query($sql); + $sql .= " WHERE id=".$oper; + $sql .= " AND entity IN (".getEntity('c_paiement').")"; + $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $oper=$obj->code; + $obj = $this->db->fetch_object($resql); + $oper = $obj->code; } else { @@ -448,19 +448,19 @@ class Account extends CommonObject } // Check parameters - if (! $oper) + if (!$oper) { - $this->error="oper not defined"; + $this->error = "oper not defined"; return -1; } - if (! $this->rowid) + if (!$this->rowid) { - $this->error="this->rowid not defined"; + $this->error = "this->rowid not defined"; return -2; } if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ') { - $this->error="ErrorCashAccountAcceptsOnlyCashMoney"; + $this->error = "ErrorCashAccountAcceptsOnlyCashMoney"; return -3; } @@ -492,7 +492,7 @@ class Account extends CommonObject } if ($accline->insert() > 0) { - if ($categorie>0) { + if ($categorie > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; $sql .= "lineid, fk_categ"; $sql .= ") VALUES ("; @@ -525,32 +525,32 @@ class Account extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs,$conf, $hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; // Clean parameters - if (! $this->min_allowed) $this->min_allowed=0; - if (! $this->min_desired) $this->min_desired=0; - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + if (!$this->min_allowed) $this->min_allowed = 0; + if (!$this->min_desired) $this->min_desired = 0; + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Check parameters if (empty($this->country_id)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } if (empty($this->ref)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } if (empty($this->date_solde)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateInitialBalance")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateInitialBalance")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } @@ -558,67 +558,67 @@ class Account extends CommonObject // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; - $now=dol_now(); + $now = dol_now(); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account ("; - $sql.= "datec"; - $sql.= ", ref"; - $sql.= ", label"; - $sql.= ", entity"; - $sql.= ", account_number"; - $sql.= ", fk_accountancy_journal"; - $sql.= ", bank"; - $sql.= ", code_banque"; - $sql.= ", code_guichet"; - $sql.= ", number"; - $sql.= ", cle_rib"; - $sql.= ", bic"; - $sql.= ", iban_prefix"; - $sql.= ", domiciliation"; - $sql.= ", proprio"; - $sql.= ", owner_address"; - $sql.= ", currency_code"; - $sql.= ", rappro"; - $sql.= ", min_allowed"; - $sql.= ", min_desired"; - $sql.= ", comment"; - $sql.= ", state_id"; - $sql.= ", fk_pays"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", '".$this->db->escape($this->ref)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->escape($this->account_number)."'"; - $sql.= ", ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); - $sql.= ", '".$this->db->escape($this->bank)."'"; - $sql.= ", '".$this->db->escape($this->code_banque)."'"; - $sql.= ", '".$this->db->escape($this->code_guichet)."'"; - $sql.= ", '".$this->db->escape($this->number)."'"; - $sql.= ", '".$this->db->escape($this->cle_rib)."'"; - $sql.= ", '".$this->db->escape($this->bic)."'"; - $sql.= ", '".$this->db->escape($this->iban)."'"; - $sql.= ", '".$this->db->escape($this->domiciliation)."'"; - $sql.= ", '".$this->db->escape($this->proprio)."'"; - $sql.= ", '".$this->db->escape($this->owner_address)."'"; - $sql.= ", '".$this->db->escape($this->currency_code)."'"; - $sql.= ", ".$this->rappro; - $sql.= ", ".price2num($this->min_allowed); - $sql.= ", ".price2num($this->min_desired); - $sql.= ", '".$this->db->escape($this->comment)."'"; - $sql.= ", ".($this->state_id>0?$this->state_id:"null"); - $sql.= ", ".$this->country_id; - $sql.= ")"; + $sql .= "datec"; + $sql .= ", ref"; + $sql .= ", label"; + $sql .= ", entity"; + $sql .= ", account_number"; + $sql .= ", fk_accountancy_journal"; + $sql .= ", bank"; + $sql .= ", code_banque"; + $sql .= ", code_guichet"; + $sql .= ", number"; + $sql .= ", cle_rib"; + $sql .= ", bic"; + $sql .= ", iban_prefix"; + $sql .= ", domiciliation"; + $sql .= ", proprio"; + $sql .= ", owner_address"; + $sql .= ", currency_code"; + $sql .= ", rappro"; + $sql .= ", min_allowed"; + $sql .= ", min_desired"; + $sql .= ", comment"; + $sql .= ", state_id"; + $sql .= ", fk_pays"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."'"; + $sql .= ", '".$this->db->escape($this->ref)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", '".$this->db->escape($this->account_number)."'"; + $sql .= ", ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); + $sql .= ", '".$this->db->escape($this->bank)."'"; + $sql .= ", '".$this->db->escape($this->code_banque)."'"; + $sql .= ", '".$this->db->escape($this->code_guichet)."'"; + $sql .= ", '".$this->db->escape($this->number)."'"; + $sql .= ", '".$this->db->escape($this->cle_rib)."'"; + $sql .= ", '".$this->db->escape($this->bic)."'"; + $sql .= ", '".$this->db->escape($this->iban)."'"; + $sql .= ", '".$this->db->escape($this->domiciliation)."'"; + $sql .= ", '".$this->db->escape($this->proprio)."'"; + $sql .= ", '".$this->db->escape($this->owner_address)."'"; + $sql .= ", '".$this->db->escape($this->currency_code)."'"; + $sql .= ", ".$this->rappro; + $sql .= ", ".price2num($this->min_allowed); + $sql .= ", ".price2num($this->min_desired); + $sql .= ", '".$this->db->escape($this->comment)."'"; + $sql .= ", ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ", ".$this->country_id; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account"); - $result=$this->update($user, 1); + $result = $this->update($user, 1); if ($result > 0) { $accline = new AccountLine($this->db); @@ -637,16 +637,16 @@ class Account extends CommonObject $this->errors = $accline->errors; } - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BANKACCOUNT_CREATE', $user); + $result = $this->call_trigger('BANKACCOUNT_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -660,16 +660,16 @@ class Account extends CommonObject { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorBankLabelAlreadyExists"); + $this->error = $langs->trans("ErrorBankLabelAlreadyExists"); $error++; } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $error++; } } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -677,7 +677,7 @@ class Account extends CommonObject else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -690,63 +690,63 @@ class Account extends CommonObject */ public function update(User $user, $notrigger = 0) { - global $langs,$conf, $hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; $this->db->begin(); // Clean parameters - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Check parameters if (empty($this->country_id)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } if (empty($this->ref)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } - if (! $this->label) $this->label = "???"; + if (!$this->label) $this->label = "???"; $sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET "; - $sql.= " ref = '".$this->db->escape($this->ref)."'"; - $sql.= ",label = '".$this->db->escape($this->label)."'"; + $sql .= " ref = '".$this->db->escape($this->ref)."'"; + $sql .= ",label = '".$this->db->escape($this->label)."'"; - $sql.= ",courant = ".$this->courant; - $sql.= ",clos = ".$this->clos; - $sql.= ",rappro = ".$this->rappro; - $sql.= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null"); - $sql.= ",account_number = '".$this->db->escape($this->account_number)."'"; - $sql.= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); - $sql.= ",bank = '".$this->db->escape($this->bank)."'"; - $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; - $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; - $sql.= ",number='".$this->db->escape($this->number)."'"; - $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; - $sql.= ",bic='".$this->db->escape($this->bic)."'"; - $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; - $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; - $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; - $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql .= ",courant = ".$this->courant; + $sql .= ",clos = ".$this->clos; + $sql .= ",rappro = ".$this->rappro; + $sql .= ",url = ".($this->url ? "'".$this->db->escape($this->url)."'" : "null"); + $sql .= ",account_number = '".$this->db->escape($this->account_number)."'"; + $sql .= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); + $sql .= ",bank = '".$this->db->escape($this->bank)."'"; + $sql .= ",code_banque='".$this->db->escape($this->code_banque)."'"; + $sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; + $sql .= ",number='".$this->db->escape($this->number)."'"; + $sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; + $sql .= ",bic='".$this->db->escape($this->bic)."'"; + $sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'"; + $sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; + $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; + $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - $sql.= ",currency_code = '".$this->db->escape($this->currency_code)."'"; + $sql .= ",currency_code = '".$this->db->escape($this->currency_code)."'"; - $sql.= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null"); - $sql.= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null"); - $sql.= ",comment = '".$this->db->escape($this->comment)."'"; + $sql .= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null"); + $sql .= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null"); + $sql .= ",comment = '".$this->db->escape($this->comment)."'"; - $sql.= ",state_id = ".($this->state_id>0?$this->state_id:"null"); - $sql.= ",fk_pays = ".$this->country_id; + $sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ",fk_pays = ".$this->country_id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); @@ -755,17 +755,17 @@ class Account extends CommonObject // Actions on extra fields (by external module or standard code) if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BANKACCOUNT_UPDATE', $user); + $result = $this->call_trigger('BANKACCOUNT_UPDATE', $user); if ($result < 0) $error++; // End call triggers } @@ -773,11 +773,11 @@ class Account extends CommonObject else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -785,7 +785,7 @@ class Account extends CommonObject else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -800,11 +800,11 @@ class Account extends CommonObject public function update_bban(User $user = null) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; // Clean parameters - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -812,27 +812,27 @@ class Account extends CommonObject dol_syslog(get_class($this)."::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban"); // Check parameters - if (! $this->ref) + if (!$this->ref) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->trans("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->trans("Ref")); return -2; } $sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET "; - $sql.= " bank = '".$this->db->escape($this->bank)."'"; - $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; - $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; - $sql.= ",number='".$this->db->escape($this->number)."'"; - $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; - $sql.= ",bic='".$this->db->escape($this->bic)."'"; - $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; - $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; - $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; - $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - $sql.= ",state_id = ".($this->state_id>0?$this->state_id:"null"); - $sql.= ",fk_pays = ".$this->country_id; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND entity = ".$conf->entity; + $sql .= " bank = '".$this->db->escape($this->bank)."'"; + $sql .= ",code_banque='".$this->db->escape($this->code_banque)."'"; + $sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; + $sql .= ",number='".$this->db->escape($this->number)."'"; + $sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; + $sql .= ",bic='".$this->db->escape($this->bic)."'"; + $sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'"; + $sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; + $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; + $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ",fk_pays = ".$this->country_id; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::update_bban", LOG_DEBUG); @@ -843,7 +843,7 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); return -1; } @@ -863,26 +863,26 @@ class Account extends CommonObject if (empty($id) && empty($ref)) { - $this->error="ErrorBadParameters"; + $this->error = "ErrorBadParameters"; return -1; } $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,"; - $sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; - $sql.= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; - $sql.= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; - $sql.= " ba.min_allowed, ba.min_desired, ba.comment,"; - $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.= " 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.= " WHERE ba.entity IN (".getEntity($this->element).")"; - if ($id) $sql.= " AND ba.rowid = ".$id; - if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'"; + $sql .= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; + $sql .= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; + $sql .= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; + $sql .= " ba.min_allowed, ba.min_desired, ba.comment,"; + $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 .= " 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 .= " WHERE ba.entity IN (".getEntity($this->element).")"; + if ($id) $sql .= " AND ba.rowid = ".$id; + if ($ref) $sql .= " AND ba.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -926,7 +926,7 @@ class Account extends CommonObject $this->accountancy_journal = $obj->accountancy_journal; $this->currency_code = $obj->currency_code; - $this->account_currency_code = $obj->currency_code; + $this->account_currency_code = $obj->currency_code; $this->min_allowed = $obj->min_allowed; $this->min_desired = $obj->min_desired; $this->comment = $obj->comment; @@ -947,8 +947,8 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror; - $this->errors[]=$this->error; + $this->error = $this->db->lasterror; + $this->errors[] = $this->error; return -1; } } @@ -966,12 +966,12 @@ class Account extends CommonObject public function setCategories($categories) { // Handle single category - if (! is_array($categories)) { + if (!is_array($categories)) { $categories = array($categories); } // Get current categories - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_ACCOUNT, 'id'); @@ -985,7 +985,7 @@ class Account extends CommonObject } // Process - foreach($to_del as $del) { + foreach ($to_del as $del) { if ($c->fetch($del) > 0) { $c->del_type($this, Categorie::TYPE_ACCOUNT); } @@ -1009,15 +1009,15 @@ class Account extends CommonObject { global $conf; - $error=0; + $error = 0; $this->db->begin(); // Delete link between tag and bank account - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; - $sql.= " WHERE fk_account = ".$this->id; + $sql .= " WHERE fk_account = ".$this->id; $resql = $this->db->query($sql); if (!$resql) @@ -1027,10 +1027,10 @@ class Account extends CommonObject } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); @@ -1039,7 +1039,7 @@ class Account extends CommonObject // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1054,7 +1054,7 @@ class Account extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1115,16 +1115,16 @@ class Account extends CommonObject public function can_be_deleted() { // phpcs:enable - $can_be_deleted=false; + $can_be_deleted = false; $sql = "SELECT COUNT(rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account=".$this->id; $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - if ($obj->nb <= 1) $can_be_deleted=true; // Juste le solde + $obj = $this->db->fetch_object($resql); + if ($obj->nb <= 1) $can_be_deleted = true; // Juste le solde } else { dol_print_error($this->db); @@ -1151,24 +1151,24 @@ class Account extends CommonObject */ public function solde($option = 0) { - $solde=0; + $solde = 0; $sql = "SELECT sum(amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account = ".$this->id; - if ($option == 1) $sql.= " AND dateo <= '".$this->db->idate(dol_now())."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account = ".$this->id; + if ($option == 1) $sql .= " AND dateo <= '".$this->db->idate(dol_now())."'"; $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { - $obj=$this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); $solde = $obj->amount; } $this->db->free($resql); } else { - $this->errors[]=$this->db->lasterror; + $this->errors[] = $this->db->lasterror; return -1; } @@ -1228,7 +1228,7 @@ class Account extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1287,14 +1287,14 @@ class Account extends CommonObject return 0; } - $nb=0; + $nb = 0; $sql = "SELECT COUNT(ba.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE ba.rappro > 0 and ba.clos = 0"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE ba.rappro > 0 and ba.clos = 0"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql .= " AND ba.courant != 2"; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1319,23 +1319,23 @@ class Account extends CommonObject { global $conf, $langs, $user; - $result=''; - $label = '' . $langs->trans("ShowAccount") . ''; - $label .= '
' . $langs->trans('BankAccount') . ': ' . $this->label; - $label .= '
' . $langs->trans('AccountNumber') . ': ' . $this->number; - $label .= '
' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code; + $result = ''; + $label = ''.$langs->trans("ShowAccount").''; + $label .= '
'.$langs->trans('BankAccount').': '.$this->label; + $label .= '
'.$langs->trans('AccountNumber').': '.$this->number; + $label .= '
'.$langs->trans("AccountCurrency").': '.$this->currency_code; if (empty($user->rights->banque->lire) || !empty($user->socid)) { $option = 'nolink'; } - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $langs->load("accountancy"); - $label .= '
' . $langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); - $label .= '
' . $langs->trans('AccountancyJournal') . ': ' . $this->accountancy_journal; + $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); + $label .= '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; } $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; @@ -1352,9 +1352,9 @@ class Account 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_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 = 'ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); $result .= $linkend; return $result; @@ -1384,13 +1384,13 @@ class Account extends CommonObject */ public function verif() { - require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; $this->error_number = 0; // Call function to check BAN - if (! checkIbanForAccount($this) || ! checkSwiftForAccount($this)) + if (!checkIbanForAccount($this) || !checkSwiftForAccount($this)) { $this->error_number = 12; $this->error_message = 'IBANSWIFTControlError'; @@ -1421,26 +1421,26 @@ class Account extends CommonObject global $mysoc; // We return country code of bank account - if (! empty($this->country_code)) return $this->country_code; + if (!empty($this->country_code)) return $this->country_code; // For backward compatibility, we try to guess country from other information - if (! empty($this->iban)) + if (!empty($this->iban)) { // If IBAN defined, we can know country of account from it if (preg_match("/^([a-zA-Z][a-zA-Z])/i", $this->iban, $reg)) return $reg[1]; } // If this class is linked to a third party - if (! empty($this->socid)) + if (!empty($this->socid)) { - require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; - $company=new Societe($this->db); - $result=$company->fetch($this->socid); - if (! empty($company->country_code)) return $company->country_code; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $company = new Societe($this->db); + $result = $company->fetch($this->socid); + if (!empty($company->country_code)) return $company->country_code; } // We return country code of managed company - if (! empty($mysoc->country_code)) return $mysoc->country_code; + if (!empty($mysoc->country_code)) return $mysoc->country_code; return ''; } @@ -1455,10 +1455,10 @@ class Account extends CommonObject */ public function useDetailedBBAN() { - $country_code=$this->getCountryCode(); + $country_code = $this->getCountryCode(); - if (in_array($country_code, array('FR','ES','GA','IT','NC'))) return 1; // France, Spain, Gabon, ... - Not valid for CH - if (in_array($country_code, array('AU','BE','CA','DE','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, England... + if (in_array($country_code, array('FR', 'ES', 'GA', 'IT', 'NC'))) return 1; // France, Spain, Gabon, ... - Not valid for CH + if (in_array($country_code, array('AU', 'BE', 'CA', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) return 2; // Australia, England... return 0; } @@ -1469,41 +1469,41 @@ class Account extends CommonObject */ public function needIBAN() { - $country_code=$this->getCountryCode(); + $country_code = $this->getCountryCode(); - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta + $country_code_in_EEC = array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom //'CH', // Switzerland - No. Swizerland in not in EEC ); @@ -1541,23 +1541,23 @@ class Account extends CommonObject $detailedBBAN = $this->useDetailedBBAN(); if ($detailedBBAN == 0) { - $fieldarray= array( + $fieldarray = array( 'BankAccountNumber' ); } elseif ($detailedBBAN == 2) { - $fieldarray= array( + $fieldarray = array( 'BankCode', 'BankAccountNumber' ); } else { - $fieldarray=self::getAccountNumberOrder(); + $fieldarray = self::getAccountNumberOrder(); } //if ($this->needIBAN()) { // return always IBAN and BIC (this was old behaviour) if ($includeibanbic) { - $fieldarray[]='IBAN'; - $fieldarray[]='BIC'; + $fieldarray[] = 'IBAN'; + $fieldarray[] = 'BIC'; } //} @@ -1647,7 +1647,7 @@ class AccountLine extends CommonObject /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var DoliDB Database handler. @@ -1657,12 +1657,12 @@ class AccountLine extends CommonObject /** * @var string ID to identify managed object */ - public $element='bank'; + public $element = 'bank'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='bank'; + public $table_element = 'bank'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -1724,10 +1724,10 @@ class AccountLine extends CommonObject */ public $fk_type; - public $rappro; // Is it conciliated - public $num_releve; // If conciliated, what is bank statement - public $num_chq; // Num of cheque - public $bank_chq; // Bank of cheque + public $rappro; // Is it conciliated + public $num_releve; // If conciliated, what is bank statement + public $num_chq; // Num of cheque + public $bank_chq; // Bank of cheque /** * @var int ID of cheque receipt @@ -1739,7 +1739,7 @@ class AccountLine extends CommonObject */ public $fk_account; - public $bank_account_label; // Label of bank account + public $bank_account_label; // Label of bank account /** * Issuer @@ -1773,55 +1773,55 @@ class AccountLine extends CommonObject if (empty($rowid) && empty($ref) && empty($num)) return -1; $sql = "SELECT b.rowid, b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,"; - $sql.= " b.fk_user_author, b.fk_user_rappro,"; - $sql.= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,"; - $sql.= " b.fk_bordereau, b.banque, b.emetteur,"; + $sql .= " b.fk_user_author, b.fk_user_rappro,"; + $sql .= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,"; + $sql .= " b.fk_bordereau, b.banque, b.emetteur,"; //$sql.= " b.author"; // Is this used ? - $sql.= " ba.ref as bank_account_ref, ba.label as bank_account_label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($num) $sql.= " AND b.num_chq='".$this->db->escape($num)."'"; - elseif ($ref) $sql.= " AND b.rowid='".$this->db->escape($ref)."'"; - else $sql.= " AND b.rowid=".$rowid; + $sql .= " ba.ref as bank_account_ref, ba.label as bank_account_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($num) $sql .= " AND b.num_chq='".$this->db->escape($num)."'"; + elseif ($ref) $sql .= " AND b.rowid='".$this->db->escape($ref)."'"; + else $sql .= " AND b.rowid=".$rowid; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $ret=0; + $ret = 0; $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->rowid = $obj->rowid; - $this->ref = $obj->rowid; + $this->ref = $obj->rowid; $this->datec = $obj->datec; $this->datev = $obj->datev; $this->dateo = $obj->dateo; - $this->amount = $obj->amount; + $this->amount = $obj->amount; $this->label = $obj->label; $this->note = $obj->note; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_rappro = $obj->fk_user_rappro; - $this->fk_type = $obj->fk_type; // Type of transaction - $this->rappro = $obj->rappro; - $this->num_releve = $obj->num_releve; + $this->fk_type = $obj->fk_type; // Type of transaction + $this->rappro = $obj->rappro; + $this->num_releve = $obj->num_releve; - $this->num_chq = $obj->num_chq; - $this->bank_chq = $obj->banque; - $this->fk_bordereau = $obj->fk_bordereau; + $this->num_chq = $obj->num_chq; + $this->bank_chq = $obj->banque; + $this->fk_bordereau = $obj->fk_bordereau; - $this->fk_account = $obj->fk_account; + $this->fk_account = $obj->fk_account; $this->bank_account_ref = $obj->bank_account_ref; $this->bank_account_label = $obj->bank_account_label; - $ret=1; + $ret = 1; } $this->db->free($result); return $ret; @@ -1858,7 +1858,7 @@ class AccountLine extends CommonObject $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", ".price2num($this->amount); - $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author :"null"); + $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author : "null"); $sql .= ", ".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null"); $sql .= ", '".$this->db->escape($this->fk_account)."'"; $sql .= ", '".$this->db->escape($this->fk_type)."'"; @@ -1889,19 +1889,19 @@ class AccountLine extends CommonObject */ public function delete(User $user = null) { - $nbko=0; + $nbko = 0; if ($this->rappro) { // Protection to avoid any delete of consolidated lines - $this->error="ErrorDeleteNotPossibleLineIsConsolidated"; + $this->error = "ErrorDeleteNotPossibleLineIsConsolidated"; return -1; } $this->db->begin(); // Delete urls - $result=$this->delete_urls($user); + $result = $this->delete_urls($user); if ($result < 0) { $nbko++; @@ -1910,14 +1910,14 @@ class AccountLine extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".(int) $this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".(int) $this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; - if (! $nbko) + if (!$nbko) { $this->db->commit(); return 1; @@ -1940,12 +1940,12 @@ class AccountLine extends CommonObject public function delete_urls(User $user = null) { // phpcs:enable - $nbko=0; + $nbko = 0; if ($this->rappro) { // Protection to avoid any delete of consolidated lines - $this->error="ErrorDeleteNotPossibleLineIsConsolidated"; + $this->error = "ErrorDeleteNotPossibleLineIsConsolidated"; return -1; } @@ -1954,9 +1954,9 @@ class AccountLine extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".(int) $this->rowid; dol_syslog(get_class($this)."::delete_urls", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; - if (! $nbko) + if (!$nbko) { $this->db->commit(); return 1; @@ -1981,10 +1981,10 @@ class AccountLine extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " amount = ".price2num($this->amount).","; - $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " dateo='".$this->db->idate($this->dateo)."'"; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " amount = ".price2num($this->amount).","; + $sql .= " datev='".$this->db->idate($this->datev)."',"; + $sql .= " dateo='".$this->db->idate($this->dateo)."'"; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1996,7 +1996,7 @@ class AccountLine extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2014,39 +2014,39 @@ class AccountLine extends CommonObject public function update_conciliation(User $user, $cat, $conciliated = 1) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $this->db->begin(); // Check statement field - if (! empty($conf->global->BANK_STATEMENT_REGEX_RULE)) + if (!empty($conf->global->BANK_STATEMENT_REGEX_RULE)) { - if (! preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve)) + if (!preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve)) { - $this->errors[]=$langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE); + $this->errors[] = $langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE); return -1; } } $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " rappro = ".$conciliated; - $sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'"; - if ($conciliated) $sql.= ", fk_user_rappro = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " rappro = ".$conciliated; + $sql .= ", num_releve = '".$this->db->escape($this->num_releve)."'"; + if ($conciliated) $sql .= ", fk_user_rappro = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_conciliation", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if (! empty($cat)) + if (!empty($cat)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; - $sql.= "lineid"; - $sql.= ", fk_categ"; - $sql.= ") VALUES ("; - $sql.= $this->id; - $sql.= ", ".$cat; - $sql.= ")"; + $sql .= "lineid"; + $sql .= ", fk_categ"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", ".$cat; + $sql .= ")"; dol_syslog(get_class($this)."::update_conciliation", LOG_DEBUG); $this->db->query($sql); @@ -2054,7 +2054,7 @@ class AccountLine extends CommonObject // No error check. Can fail if category already affected } - $this->rappro=1; + $this->rappro = 1; $this->db->commit(); return 1; @@ -2082,12 +2082,12 @@ class AccountLine extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $newdate=$this->db->jdate($obj->datev)+(3600*24*$sign); + $obj = $this->db->fetch_object($resql); + $newdate = $this->db->jdate($obj->datev) + (3600 * 24 * $sign); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " datev = '".$this->db->idate($newdate)."'"; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " datev = '".$this->db->idate($newdate)."'"; + $sql .= " WHERE rowid = ".$rowid; $result = $this->db->query($sql); if ($result) @@ -2149,12 +2149,12 @@ class AccountLine extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $newdate=$this->db->jdate($obj->dateo)+(3600*24*$sign); + $obj = $this->db->fetch_object($resql); + $newdate = $this->db->jdate($obj->dateo) + (3600 * 24 * $sign); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " dateo = '".$this->db->idate($newdate)."'"; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " dateo = '".$this->db->idate($newdate)."'"; + $sql .= " WHERE rowid = ".$rowid; $result = $this->db->query($sql); if ($result) @@ -2210,11 +2210,11 @@ class AccountLine extends CommonObject public function info($id) { $sql = 'SELECT b.rowid, b.datec, b.tms as datem,'; - $sql.= ' b.fk_user_author, b.fk_user_rappro'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'bank as b'; - $sql.= ' WHERE b.rowid = '.$id; + $sql .= ' b.fk_user_author, b.fk_user_rappro'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'bank as b'; + $sql .= ' WHERE b.rowid = '.$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -2226,7 +2226,7 @@ class AccountLine extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_rappro) { @@ -2261,32 +2261,32 @@ class AccountLine extends CommonObject { global $langs; - $result=''; - $label=$langs->trans("ShowTransaction").': '.$this->rowid; + $result = ''; + $label = $langs->trans("ShowTransaction").': '.$this->rowid; $linkstart = ''; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'account'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.=($this->ref?$this->ref:$this->rowid); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'account'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($this->ref ? $this->ref : $this->rowid); $result .= $linkend; - if ($option == 'showall' || $option == 'showconciliated') $result.=' ('; + if ($option == 'showall' || $option == 'showconciliated') $result .= ' ('; if ($option == 'showall') { - $result.=$langs->trans("BankAccount").': '; - $accountstatic=new Account($this->db); - $accountstatic->id=$this->fk_account; - $accountstatic->ref=$this->bank_account_ref; - $accountstatic->label=$this->bank_account_label; - $result.=$accountstatic->getNomUrl(0).', '; + $result .= $langs->trans("BankAccount").': '; + $accountstatic = new Account($this->db); + $accountstatic->id = $this->fk_account; + $accountstatic->ref = $this->bank_account_ref; + $accountstatic->label = $this->bank_account_label; + $result .= $accountstatic->getNomUrl(0).', '; } if ($option == 'showall' || $option == 'showconciliated') { - $result.=$langs->trans("BankLineConciliated").': '; - $result.=yn($this->rappro); + $result .= $langs->trans("BankLineConciliated").': '; + $result .= yn($this->rappro); } - if ($option == 'showall' || $option == 'showconciliated') $result.=')'; + if ($option == 'showall' || $option == 'showconciliated') $result .= ')'; return $result; } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index a58d7a7c6ea..47b251b788b 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -63,18 +63,18 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $db->begin(); - $datev=dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datep=dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $object->accountid=GETPOST("accountid"); - $object->paymenttype=GETPOST("paiementtype"); - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount")); - $object->label=GETPOST("label"); - $object->ltt=$lttype; + $object->accountid = GETPOST("accountid"); + $object->paymenttype = GETPOST("paiementtype"); + $object->datev = $datev; + $object->datep = $datep; + $object->amount = price2num(GETPOST("amount")); + $object->label = GETPOST("label"); + $object->ltt = $lttype; - $ret=$object->addPayment($user); + $ret = $object->addPayment($user); if ($ret > 0) { $db->commit(); @@ -85,27 +85,27 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $_GET["action"]="create"; + $_GET["action"] = "create"; } } //delete payment of localtax if ($action == 'delete') { - $result=$object->fetch($id); + $result = $object->fetch($id); if ($object->rappro == 0) { $db->begin(); - $ret=$object->delete($user); + $ret = $object->delete($user); if ($ret > 0) { if ($object->fk_bank) { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + $accountline = new AccountLine($db); + $result = $accountline->fetch($object->fk_bank); + if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } if ($result >= 0) @@ -116,7 +116,7 @@ if ($action == 'delete') } else { - $object->error=$accountline->error; + $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } @@ -129,7 +129,7 @@ if ($action == 'delete') } else { - $mesg='Error try do delete a line linked to a conciliated bank transaction'; + $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; setEventMessages($mesg, null, 'errors'); } } @@ -151,13 +151,13 @@ if ($id) $form = new Form($db); -$title=$langs->trans("LT".$object->ltt) . " - " . $langs->trans("Card"); -$help_url=''; +$title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card"); +$help_url = ''; llxHeader("", $title, $helpurl); if ($action == 'create') { - print load_fiche_titre($langs->transcountry($lttype==2?"newLT2Payment":"newLT1Payment", $mysoc->country_code)); + print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); print '
'."\n"; print ''; @@ -178,15 +178,15 @@ if ($action == 'create') print '
'.$langs->trans("Label").'transcountry(($lttype==2?"LT2Payment":"LT1Payment"), $mysoc->country_code)).'">
'.$langs->trans("Label").'transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'">
'.$langs->trans("Amount").'
'.$langs->trans("Account").''; - $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant + $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant print '
'.$langs->trans("PaymentMode").''; @@ -200,8 +200,8 @@ if ($action == 'create') print '
'; @@ -254,11 +254,11 @@ if ($id) print ''.$langs->trans("Amount").''.price($object->amount).''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($object->fk_account > 0) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); $bankline->fetch($object->fk_bank); print ''; @@ -271,8 +271,8 @@ if ($id) } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index bb57e796ef6..ebf87b91693 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -46,9 +46,9 @@ if ($user->socid > 0) * Actions */ -if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes')) +if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) { - $error=0; + $error = 0; if ($_POST["cancel"]) { @@ -59,7 +59,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (! $_POST["paiementtype"] > 0) + if (!$_POST["paiementtype"] > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; @@ -71,14 +71,14 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $error++; $action = 'create'; } - if (! empty($conf->banque->enabled) && ! ($_POST["accountid"] > 0)) + if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); $error++; $action = 'create'; } - if (! $error) + if (!$error) { $paymentid = 0; @@ -96,10 +96,10 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes { $error++; setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors'); - $action='create'; + $action = 'create'; } - if (! $error) + if (!$error) { $db->begin(); @@ -107,34 +107,34 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $paiement = new PaymentSocialContribution($db); $paiement->chid = $chid; $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Tableau de montant + $paiement->amounts = $amounts; // Tableau de montant $paiement->paiementtype = $_POST["paiementtype"]; $paiement->num_paiement = $_POST["num_paiement"]; $paiement->note = $_POST["note"]; - if (! $error) + if (!$error) { - $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib')=='on'?1:0)); + $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib') == 'on' ? 1 : 0)); if ($paymentid < 0) { $error++; setEventMessages($paiement->error, null, 'errors'); - $action='create'; + $action = 'create'; } } - if (! $error) + if (!$error) { - $result=$paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', ''); - if (! ($result > 0)) + $result = $paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', ''); + if (!($result > 0)) { $error++; setEventMessages($paiement->error, null, 'errors'); - $action='create'; + $action = 'create'; } } - if (! $error) + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid; @@ -156,7 +156,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes llxHeader(); -$form=new Form($db); +$form = new Form($db); // Formulaire de creation d'un paiement de charge @@ -209,12 +209,12 @@ if ($action == 'create') print ''.$langs->trans("Amount")."".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'';*/ $sql = "SELECT sum(p.amount) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql.= " WHERE p.fk_charge = ".$chid; + $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; + $sql .= " WHERE p.fk_charge = ".$chid; $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $sumpaid = $obj->total; $db->free(); } @@ -223,20 +223,20 @@ if ($action == 'create') print ''.$langs->trans("Date").''; $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0; + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0; print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); print ""; print ''; print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(isset($_POST["paiementtype"])?$_POST["paiementtype"]:$charge->paiementtype, "paiementtype"); + $form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $charge->paiementtype, "paiementtype"); print "\n"; print ''; print ''; print ''.$langs->trans('AccountToDebit').''; print ''; - $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '', 1); // Show opend bank account list + $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $charge->accountid, "accountid", 0, '', 1); // Show opend bank account list print ''; // Number @@ -270,8 +270,8 @@ if ($action == 'create') print ''.$langs->trans("Amount").''; print "\n"; - $total=0; - $totalrecu=0; + $total = 0; + $totalrecu = 0; while ($i < $num) { @@ -301,7 +301,7 @@ if ($action == 'create') $nameRemain = "remain_".$objp->id; if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'"); - $remaintopay=$objp->amount - $sumpaid; + $remaintopay = $objp->amount - $sumpaid; print ''; print ''; } @@ -312,9 +312,9 @@ if ($action == 'create') print ""; print "\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $objp->am; $i++; } if ($i > 1) diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 2e1915f780e..477f925f534 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -101,14 +101,14 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $urladd= "&statut=".$statut; + $urladd = "&statut=".$statut; - $selectedfields=''; + $selectedfields = ''; - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->prelevement->bons->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'); } // Lines of title fields @@ -124,18 +124,18 @@ if ($result) print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); - $moreforfilter=''; + $moreforfilter = ''; print '
'; - print ''."\n"; + print '
'."\n"; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index c016f1e6c02..2aaca08e69b 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -46,8 +46,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="p.datec"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "p.datec"; $search_line = GETPOST('search_line', 'alpha'); $search_bon = GETPOST('search_bon', 'alpha'); @@ -55,8 +55,8 @@ $search_code = GETPOST('search_code', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); $statut = GETPOST('statut', 'int'); -$bon=new BonPrelevement($db, ""); -$ligne=new LignePrelevement($db, $user); +$bon = new BonPrelevement($db, ""); +$ligne = new LignePrelevement($db, $user); /* @@ -65,11 +65,11 @@ $ligne=new LignePrelevement($db, $user); 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_line=""; - $search_bon=""; - $search_code=""; - $search_company=""; - $statut=""; + $search_line = ""; + $search_bon = ""; + $search_code = ""; + $search_company = ""; + $statut = ""; } @@ -77,31 +77,31 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -$form=new Form($db); +$form = new Form($db); llxHeader('', $langs->trans("WithdrawalsLines")); $sql = "SELECT p.rowid, p.ref, p.statut, p.datec"; -$sql.= " ,f.rowid as facid, f.ref, f.total_ttc"; -$sql.= " , s.rowid as socid, s.nom as name, s.code_client"; -$sql.= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne"; -$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; -$sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; -$sql.= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; -$sql.= " , ".MAIN_DB_PREFIX."facture as f"; -$sql.= " , ".MAIN_DB_PREFIX."societe as s"; -$sql.= " WHERE pl.fk_prelevement_bons = p.rowid"; -$sql.= " AND pf.fk_prelevement_lignes = pl.rowid"; -$sql.= " AND pf.fk_facture = f.rowid"; -$sql.= " AND f.fk_soc = s.rowid"; -$sql.= " AND f.entity IN (".getEntity('invoice').")"; -if ($socid) $sql.= " AND s.rowid = ".$socid; -if ($search_line) $sql.= " AND pl.rowid = '".$db->escape($search_line)."'"; -if ($search_bon) $sql.= natural_search("p.ref", $search_bon); -if ($search_code) $sql.= natural_search("s.code_client", $search_code); -if ($search_company) $sql.= natural_search("s.nom", $search_company); +$sql .= " ,f.rowid as facid, f.ref, f.total_ttc"; +$sql .= " , s.rowid as socid, s.nom as name, s.code_client"; +$sql .= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne"; +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; +$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; +$sql .= " , ".MAIN_DB_PREFIX."facture as f"; +$sql .= " , ".MAIN_DB_PREFIX."societe as s"; +$sql .= " WHERE pl.fk_prelevement_bons = p.rowid"; +$sql .= " AND pf.fk_prelevement_lignes = pl.rowid"; +$sql .= " AND pf.fk_facture = f.rowid"; +$sql .= " AND f.fk_soc = s.rowid"; +$sql .= " AND f.entity IN (".getEntity('invoice').")"; +if ($socid) $sql .= " AND s.rowid = ".$socid; +if ($search_line) $sql .= " AND pl.rowid = '".$db->escape($search_line)."'"; +if ($search_bon) $sql .= natural_search("p.ref", $search_bon); +if ($search_code) $sql .= natural_search("s.code_client", $search_code); +if ($search_company) $sql .= natural_search("s.nom", $search_company); -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -116,7 +116,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -126,28 +126,28 @@ if ($result) $urladd = "&statut=".$statut; $urladd .= "&search_bon=".$search_bon; - if ($limit > 0 && $limit != $conf->liste_limit) $urladd.='&limit='.urlencode($limit); + if ($limit > 0 && $limit != $conf->liste_limit) $urladd .= '&limit='.urlencode($limit); print"\n\n"; print ''; print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); - $moreforfilter=''; + $moreforfilter = ''; print '
'; - print '
  '; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'."\n"; + print '
'."\n"; print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 4fb2f27b53f..a5279ecbeae 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -34,12 +34,12 @@ class PaymentSocialContribution extends CommonObject /** * @var string ID to identify managed object */ - public $element='paiementcharge'; + public $element = 'paiementcharge'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='paiementcharge'; + public $table_element = 'paiementcharge'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -51,9 +51,9 @@ class PaymentSocialContribution extends CommonObject */ public $fk_charge; - public $datec=''; - public $tms=''; - public $datep=''; + public $datec = ''; + public $tms = ''; + public $datep = ''; /** * @deprecated @@ -61,8 +61,8 @@ class PaymentSocialContribution extends CommonObject */ public $total; - public $amount; // Total amount of payment - public $amounts=array(); // Array of amounts + public $amount; // Total amount of payment + public $amounts = array(); // Array of amounts /** * @var int ID @@ -108,28 +108,28 @@ class PaymentSocialContribution extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::create", LOG_DEBUG); // Validate parametres - if (! $this->datepaye) + if (!$this->datepaye) { - $this->error='ErrorBadValueForParameterCreatePaymentSocialContrib'; + $this->error = 'ErrorBadValueForParameterCreatePaymentSocialContrib'; return -1; } // Clean parameters - if (isset($this->fk_charge)) $this->fk_charge= (int) $this->fk_charge; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement= (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); - if (isset($this->note)) $this->note=trim($this->note); - if (isset($this->fk_bank)) $this->fk_bank= (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat= (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif= (int) $this->fk_user_modif; + if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; $totalamount = 0; foreach ($this->amounts as $key => $value) // How payment is dispatch @@ -149,14 +149,14 @@ class PaymentSocialContribution extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,"; - $sql.= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; - $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->datepaye)."',"; - $sql.= " ".$totalamount.","; - $sql.= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; - $sql.= " 0)"; + $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; + $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->datepaye)."',"; + $sql .= " ".$totalamount.","; + $sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql .= " 0)"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge"); @@ -172,18 +172,18 @@ class PaymentSocialContribution extends CommonObject // If we want to closed payed invoices if ($closepaidcontrib) { - $contrib=new ChargeSociales($this->db); + $contrib = new ChargeSociales($this->db); $contrib->fetch($contribid); $paiement = $contrib->getSommePaiement(); //$creditnotes=$contrib->getSumCreditNotesUsed(); - $creditnotes=0; + $creditnotes = 0; //$deposits=$contrib->getSumDepositsUsed(); - $deposits=0; - $alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay=price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); + $deposits = 0; + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { - $result=$contrib->set_paid($user); + $result = $contrib->set_paid($user); } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } @@ -197,18 +197,18 @@ class PaymentSocialContribution extends CommonObject } $result = $this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE', $user); - if($result < 0) $error++; + if ($result < 0) $error++; - if ($totalamount != 0 && ! $error) + if ($totalamount != 0 && !$error) { - $this->amount=$totalamount; - $this->total=$totalamount; // deprecated + $this->amount = $totalamount; + $this->total = $totalamount; // deprecated $this->db->commit(); return $this->id; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -278,7 +278,7 @@ class PaymentSocialContribution extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -294,18 +294,18 @@ class PaymentSocialContribution extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_charge)) $this->fk_charge= (int) $this->fk_charge; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement= (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); - if (isset($this->note)) $this->note=trim($this->note); - if (isset($this->fk_bank)) $this->fk_bank= (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat= (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif= (int) $this->fk_user_modif; + if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -315,26 +315,26 @@ class PaymentSocialContribution extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET"; - $sql.= " fk_charge=".(isset($this->fk_charge)?$this->fk_charge:"null").","; - $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; - $sql.= " fk_typepaiement=".(isset($this->fk_typepaiement)?$this->fk_typepaiement:"null").","; - $sql.= " num_paiement=".(isset($this->num_paiement)?"'".$this->db->escape($this->num_paiement)."'":"null").","; - $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; - $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; - $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; - $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; + $sql .= " fk_charge=".(isset($this->fk_charge) ? $this->fk_charge : "null").","; + $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; + $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; + $sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").","; + $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; + $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; - $sql.= " WHERE rowid=".$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(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } //if (! $error) //{ @@ -355,13 +355,13 @@ class PaymentSocialContribution extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -381,7 +381,7 @@ class PaymentSocialContribution extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; dol_syslog(get_class($this)."::delete"); @@ -392,20 +392,20 @@ class PaymentSocialContribution extends CommonObject $accline = new AccountLine($this->db); $accline->fetch($this->bank_line); $result = $accline->delete(); - if($result < 0) { + if ($result < 0) { $this->errors[] = $accline->error; $error++; } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } //if (! $error) @@ -427,13 +427,13 @@ class PaymentSocialContribution extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -453,35 +453,35 @@ class PaymentSocialContribution extends CommonObject */ public function createFromClone(User $user, $fromid) { - $error=0; + $error = 0; - $object=new PaymentSocialContribution($this->db); + $object = new PaymentSocialContribution($this->db); $this->db->begin(); // Load source object $object->fetch($fromid); - $object->id=0; - $object->statut=0; + $object->id = 0; + $object->statut = 0; // Clear fields // ... // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result=$object->create($user); + $result = $object->create($user); // Other options if ($result < 0) { - $this->error=$object->error; + $this->error = $object->error; $error++; } unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -503,19 +503,19 @@ class PaymentSocialContribution extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->fk_charge=''; - $this->datec=''; - $this->tms=''; - $this->datep=''; - $this->amount=''; - $this->fk_typepaiement=''; - $this->num_paiement=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_creat=''; - $this->fk_user_modif=''; + $this->fk_charge = ''; + $this->datec = ''; + $this->tms = ''; + $this->datep = ''; + $this->amount = ''; + $this->fk_typepaiement = ''; + $this->num_paiement = ''; + $this->note = ''; + $this->fk_bank = ''; + $this->fk_user_creat = ''; + $this->fk_user_modif = ''; } @@ -535,22 +535,22 @@ class PaymentSocialContribution extends CommonObject { global $conf; - $error=0; + $error = 0; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); - $total=$this->total; - if ($mode == 'payment_sc') $total=-$total; + $total = $this->total; + if ($mode == 'payment_sc') $total = -$total; // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datepaye, - $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") + $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") $label, $total, $this->num_paiement, @@ -564,7 +564,7 @@ class PaymentSocialContribution extends CommonObject // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { - $result=$this->update_fk_bank($bank_line_id); + $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; @@ -572,11 +572,11 @@ class PaymentSocialContribution extends CommonObject } // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction - $url=''; - if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/card.php?id='; + $url = ''; + if ($mode == 'payment_sc') $url = DOL_URL_ROOT.'/compta/payment_sc/card.php?id='; if ($url) { - $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; @@ -635,7 +635,7 @@ class PaymentSocialContribution extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return 0; } } @@ -663,7 +663,7 @@ class PaymentSocialContribution extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage $langs->load('compta'); /*if ($mode == 0) @@ -715,18 +715,18 @@ class PaymentSocialContribution extends CommonObject { global $langs; - $result=''; + $result = ''; - if (empty($this->ref)) $this->ref=$this->lib; + if (empty($this->ref)) $this->ref = $this->lib; $label = $langs->trans("ShowPayment").': '.$this->ref; if (!empty($this->id)) { $link = ''; - $linkend=''; + $linkend = ''; - if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; + if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; } return $result; diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index ee9dc5352c1..79eb6f9ab8e 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -33,9 +33,9 @@ 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 $boxcode = "goodcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxGoodCustomers"; public $depends = array("societe"); /** @@ -62,10 +62,10 @@ class box_goodcustomers extends ModeleBoxes $this->db = $db; // disable box for such cases - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled = 0; // not enabled by default. Very slow on large database - $this->hidden = ! ($user->rights->societe->lire); + $this->hidden = !($user->rights->societe->lire); } /** @@ -79,23 +79,23 @@ class box_goodcustomers extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($this->db); + $thirdpartystatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; - $sql.= " count(*) as nbfact, sum(". $this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; - $sql.= ' AND s.rowid = f.fk_soc'; - $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; - $sql.= $this->db->order("nbfact", "DESC"); - $sql.= $this->db->plimit($max, 0); + $sql .= " count(*) as nbfact, sum(".$this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; + $sql .= ' AND s.rowid = f.fk_soc'; + $sql .= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; + $sql .= $this->db->order("nbfact", "DESC"); + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -107,7 +107,7 @@ class box_goodcustomers extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->rowid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->code_client = $objp->code_client; @@ -131,7 +131,7 @@ class box_goodcustomers extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') ); $this->info_box_contents[$line][] = array( @@ -142,7 +142,7 @@ class box_goodcustomers extends ModeleBoxes $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); } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 1039ea74385..193bcdae2d6 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; */ class box_task extends ModeleBoxes { - public $boxcode="projettask"; - public $boximg="object_projecttask"; + public $boxcode = "projettask"; + public $boximg = "object_projecttask"; public $boxlabel; public $depends = array("projet"); @@ -42,7 +42,7 @@ class box_task extends ModeleBoxes public $db; public $param; - public $enabled = 1; // enable because fixed ;-). + public $enabled = 1; // enable because fixed ;-). public $info_box_head = array(); public $info_box_contents = array(); @@ -61,10 +61,10 @@ class box_task extends ModeleBoxes // Load translation files required by the page $langs->loadLangs(array('boxes', 'projects')); - $this->boxlabel="Tasks"; + $this->boxlabel = "Tasks"; $this->db = $db; - $this->hidden = ! ($user->rights->projet->lire); + $this->hidden = !($user->rights->projet->lire); } /** @@ -77,32 +77,32 @@ class box_task extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php"; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; $projectstatic = new Project($this->db); - $taskstatic=new Task($this->db); - $form= new Form($this->db); - $cookie_name='boxfilter_task'; - $boxcontent=''; + $taskstatic = new Task($this->db); + $form = new Form($this->db); + $cookie_name = 'boxfilter_task'; + $boxcontent = ''; $textHead = $langs->trans("CurentlyOpenedTasks"); - $filterValue='all'; - if(in_array(GETPOST($cookie_name), array('all','im_project_contact','im_task_contact'))){ + $filterValue = 'all'; + if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { $filterValue = GETPOST($cookie_name); } - elseif(!empty($_COOKIE[$cookie_name])){ + elseif (!empty($_COOKIE[$cookie_name])) { $filterValue = $_COOKIE[$cookie_name]; } - if($filterValue == 'im_task_contact'){ - $textHead.= ' : '.$langs->trans("WhichIamLinkedTo"); + if ($filterValue == 'im_task_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedTo"); } - elseif($filterValue == 'im_project_contact'){ - $textHead.= ' : '.$langs->trans("WhichIamLinkedToProject"); + elseif ($filterValue == 'im_project_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedToProject"); } @@ -135,7 +135,7 @@ class box_task extends ModeleBoxes }); '; // set cookie by js - $boxcontent.=''; + $boxcontent .= ''; $this->info_box_contents[0][] = array( 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', 'td' => 'class="nohover"', @@ -144,43 +144,43 @@ class box_task extends ModeleBoxes $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; - $sql.= ", p.rowid project_id, p.ref project_ref, p.title project_title"; + $sql .= ", p.rowid project_id, p.ref project_ref, p.title project_title"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; - $sql.= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; - if($filterValue === 'im_task_contact') { - $sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '" . $user->id . "' )"; - $sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; + if ($filterValue === 'im_task_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '".$user->id."' )"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; } - elseif($filterValue === 'im_project_contact') { - $sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '" . $user->id . "' )"; - $sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; + elseif ($filterValue === 'im_project_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '".$user->id."' )"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; } - $sql.= " WHERE "; - $sql.= " pt.entity = ".$conf->entity; - $sql.= " AND p.fk_statut = ".Project::STATUS_VALIDATED; - $sql.= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed - $sql.= " AND p.usage_task = 1 "; + $sql .= " WHERE "; + $sql .= " pt.entity = ".$conf->entity; + $sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED; + $sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed + $sql .= " AND p.usage_task = 1 "; - $sql.= " ORDER BY pt.datee ASC, pt.dateo ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY pt.datee ASC, pt.dateo ASC"; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); $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->id = $objp->rowid; + $taskstatic->ref = $objp->ref; + $taskstatic->label = $objp->label; $taskstatic->progress = $objp->progress; $taskstatic->fk_statut = $objp->fk_statut; $taskstatic->date_end = $objp->datee; - $taskstatic->planned_workload= $objp->planned_workload; - $taskstatic->duration_effective= $objp->duration_effective; + $taskstatic->planned_workload = $objp->planned_workload; + $taskstatic->duration_effective = $objp->duration_effective; $projectstatic->id = $objp->project_id; $projectstatic->ref = $objp->project_ref; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 22ba7b66ec8..335c1b50111 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -78,6 +78,7 @@ class CMailFile //! Defined background directly in body tag public $bodyCSS; + public $msgid; public $headers; public $message; /** @@ -263,7 +264,8 @@ class CMailFile // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; - // Action according to choosed sending method + // We set all data according to choosed sending method. + // We also set a value for ->msgid if ($this->sendmode == 'mail') { // Use mail php function (default PHP method) @@ -274,7 +276,7 @@ class CMailFile $text_body = ""; $files_encoded = ""; - // Define smtp_headers + // Define smtp_headers (this also set ->msgid) $smtp_headers = $this->write_smtpheaders(); if (!empty($moreinheader)) $smtp_headers .= $moreinheader; // $moreinheader contains the \r\n @@ -365,6 +367,9 @@ class CMailFile $smtps->setErrorsTo($errors_to); $smtps->setDeliveryReceipt($deliveryreceipt); + $host=dol_getprefix('email'); + $this->msgid = time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host; + $this->smtps = $smtps; } elseif ($this->sendmode == 'swiftmailer') @@ -386,7 +391,8 @@ class CMailFile // Adding a trackid header to a message $headers = $this->message->getHeaders(); $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid.'@'.$host); - $headerID = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host; + $this->msgid = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host; + $headerID = $this->msgid; $msgid = $headers->get('Message-ID'); $msgid->setId($headerID); $headers->addIdHeader('References', $headerID); @@ -1038,13 +1044,15 @@ class CMailFile if ($trackid) { // References is kept in response and Message-ID is returned into In-Reply-To: - $out .= 'Message-ID: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; // Uppercase seems replaced by phpmail - $out .= 'References: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; + $this->msgid = time().'.phpmail-dolibarr-'.$trackid.'@'.$host; + $out .= 'Message-ID: <'.$this->msgid.">".$this->eol2; // Uppercase seems replaced by phpmail + $out .= 'References: <'.$this->msgid.">".$this->eol2; $out .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host.$this->eol2; } else { - $out .= 'Message-ID: <'.time().'.phpmail@'.$host.">".$this->eol2; + $this->msgid = time().'.phpmail@'.$host; + $out .= 'Message-ID: <'.$this->msgid.">".$this->eol2; } if (!empty($_SERVER['REMOTE_ADDR'])) $out .= "X-RemoteAddr: ".$_SERVER['REMOTE_ADDR'].$this->eol2; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 425d0cd3004..d35ddf946fb 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -126,7 +126,7 @@ class Conf $this->service = new stdClass(); $this->contrat = new stdClass(); $this->actions = new stdClass(); - $this->agenda = new stdClass(); + $this->agenda = new stdClass(); $this->commande = new stdClass(); $this->propal = new stdClass(); $this->facture = new stdClass(); @@ -354,11 +354,11 @@ class Conf $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; - // For backward compatibility - $this->banque->multidir_output = array($this->entity => $rootfordata."/bank"); - $this->banque->multidir_temp = array($this->entity => $rootfordata."/bank/temp"); - $this->banque->dir_output=$rootfordata."/bank"; - $this->banque->dir_temp=$rootfordata."/bank/temp"; + // For bank storage + $this->bank->multidir_output = array($this->entity => $rootfordata."/bank"); + $this->bank->multidir_temp = array($this->entity => $rootfordata."/bank/temp"); + $this->bank->dir_output = $rootfordata."/bank"; + $this->bank->dir_temp = $rootfordata."/bank/temp"; // For medias storage $this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index a0879160727..fc148b94611 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -174,7 +174,7 @@ class DolEditor //$out.= ''; if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax) && ! empty($conf->fckeditor->enabled)) diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index c4af5773885..b65d72332e0 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -82,8 +82,8 @@ class EmailSenderProfile extends CommonObject 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1), //'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), //'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), - 'signature' => array('type'=>'text', 'label'=>'Signature', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,), - 'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,), + 'signature' => array('type'=>'text', 'label'=>'Signature', 'visible'=>-1, 'enabled'=>1, 'position'=>400, 'notnull'=>-1, 'index'=>1,), + 'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1), diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index dbdba9db085..e5b3f8fbb6e 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -754,7 +754,7 @@ class FormOther } ); }); '; } - $out .= ''; + $out .= ''; } else // In most cases, this is not used. We used instead function with no specific list of colors { diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index cdc5b283c44..1a844f86f2b 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -74,9 +74,9 @@ class Link extends CommonObject */ public function create($user = '') { - global $langs,$conf; + global $langs, $conf; - $error=0; + $error = 0; $langs->load("errors"); // Clean parameters if (empty($this->label)) { @@ -99,34 +99,34 @@ class Link extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."links (entity, datea, url, label, objecttype, objectid)"; $sql .= " VALUES ('".$conf->entity."', '".$this->db->idate($this->datea)."'"; - $sql .= ", '" . $this->db->escape($this->url) . "'"; - $sql .= ", '" . $this->db->escape($this->label) . "'"; - $sql .= ", '" . $this->db->escape($this->objecttype) . "'"; - $sql .= ", " . $this->objectid . ")"; + $sql .= ", '".$this->db->escape($this->url)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($this->objecttype)."'"; + $sql .= ", ".$this->objectid.")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "links"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."links"); if ($this->id > 0) { // Call trigger - $result=$this->call_trigger('LINK_CREATE', $user); + $result = $this->call_trigger('LINK_CREATE', $user); if ($result < 0) $error++; // End call triggers } else { $error++; } - if (! $error) + if (!$error) { - dol_syslog(get_class($this)."::Create success id=" . $this->id); + dol_syslog(get_class($this)."::Create success id=".$this->id); $this->db->commit(); return $this->id; } else { - dol_syslog(get_class($this)."::Create echec update " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::Create echec update ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } @@ -135,13 +135,13 @@ class Link extends CommonObject { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorCompanyNameAlreadyExists", $this->name); - $result=-1; + $this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name); + $result = -1; } else { - $this->error=$this->db->lasterror(); - $result=-2; + $this->error = $this->db->lasterror(); + $result = -2; } $this->db->rollback(); return $result; @@ -157,13 +157,13 @@ class Link extends CommonObject */ public function update($user = '', $call_trigger = 1) { - global $langs,$conf; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("errors"); - $error=0; + $error = 0; - dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger); + dol_syslog(get_class($this)."::Update id = ".$this->id." call_trigger = ".$call_trigger); // Check parameters if (empty($this->url)) @@ -180,30 +180,30 @@ class Link extends CommonObject $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "links SET "; - $sql .= "entity = '" . $conf->entity ."'"; - $sql .= ", datea = '" . $this->db->idate(dol_now()) . "'"; - $sql .= ", url = '" . $this->db->escape($this->url) . "'"; - $sql .= ", label = '" . $this->db->escape($this->label) . "'"; - $sql .= ", objecttype = '" . $this->db->escape($this->objecttype) . "'"; - $sql .= ", objectid = " . $this->objectid; - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."links SET "; + $sql .= "entity = '".$conf->entity."'"; + $sql .= ", datea = '".$this->db->idate(dol_now())."'"; + $sql .= ", url = '".$this->db->escape($this->url)."'"; + $sql .= ", label = '".$this->db->escape($this->label)."'"; + $sql .= ", objecttype = '".$this->db->escape($this->objecttype)."'"; + $sql .= ", objectid = ".$this->objectid; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update sql = " .$sql); + dol_syslog(get_class($this)."::update sql = ".$sql); $resql = $this->db->query($sql); if ($resql) { if ($call_trigger) { // Call trigger - $result=$this->call_trigger('LINK_MODIFY', $user); + $result = $this->call_trigger('LINK_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - dol_syslog(get_class($this) . "::Update success"); + dol_syslog(get_class($this)."::Update success"); $this->db->commit(); return 1; } else { @@ -218,12 +218,12 @@ class Link extends CommonObject { // Doublon $this->error = $langs->trans("ErrorDuplicateField"); - $result = -1; + $result = -1; } else { - $this->error = $langs->trans("Error sql = " . $sql); - $result = -2; + $this->error = $langs->trans("Error sql = ".$sql); + $result = -2; } $this->db->rollback(); return $result; @@ -244,14 +244,14 @@ class Link extends CommonObject { global $conf; - $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid; - if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; if ($sortfield) { if (empty($sortorder)) { $sortorder = "ASC"; } - $sql .= " ORDER BY " . $sortfield . " " . $sortorder; + $sql .= " ORDER BY ".$sortfield." ".$sortorder; } dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); @@ -259,7 +259,7 @@ class Link extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - dol_syslog(get_class($this)."::fetchAll " . $num . "records", LOG_DEBUG); + dol_syslog(get_class($this)."::fetchAll ".$num."records", LOG_DEBUG); if ($num > 0) { while ($obj = $this->db->fetch_object($resql)) @@ -295,9 +295,9 @@ class Link extends CommonObject { global $conf; - $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid; - if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) @@ -322,15 +322,15 @@ class Link extends CommonObject $rowid = $this->id; } - $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE rowid = " . $rowid; - if($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE rowid = ".$rowid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if($this->db->num_rows($resql) > 0) + if ($this->db->num_rows($resql) > 0) { $obj = $this->db->fetch_object($resql); @@ -348,7 +348,7 @@ class Link extends CommonObject return 0; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -367,7 +367,7 @@ class Link extends CommonObject $this->db->begin(); // Call trigger - $result=$this->call_trigger('LINK_DELETE', $user); + $result = $this->call_trigger('LINK_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -376,17 +376,17 @@ class Link extends CommonObject // End call triggers // Remove link - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "links"; - $sql.= " WHERE rowid = " . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); } - if (! $error) { + if (!$error) { $this->db->commit(); return 1; diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index d47146abc64..3af8d3924a8 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,17 +45,32 @@ class Menubase public $errors = array(); /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; + /** + * @var string Menu handler + */ public $menu_handler; + + /** + * @var string Module name if record is added by a module + */ public $module; + + /** + * @var string Menu top or left + */ public $type; + + /** + * @var string Name family/module for top menu (home, companies, ...) + */ public $mainmenu; /** - * @var int ID + * @var int 0 or Id of mother menu line, or -1 if we use fk_mainmenu and fk_leftmenu */ public $fk_menu; @@ -70,23 +85,71 @@ class Menubase public $fk_leftmenu; /** - * @var int position + * @var int Sort order of entry */ public $position; + + /** + * @var string Relative (or absolute) url to go + */ public $url; + + /** + * @var string Target of Url link + */ public $target; + + /** + * @var string Key for menu translation + * @deprecated + * @see title + */ public $titre; + + /** + * @var string Key for menu translation + */ + public $title; + + /** + * @var string Lang file to load for translation + */ public $langs; + + /** + * @var string Not used + * @deprecated + */ public $level; - public $leftmenu; //langs=trim($this->langs); $this->perms=trim($this->perms); $this->enabled=trim($this->enabled); - $this->user=trim($this->user); + $this->user = (int) $this->user; if (empty($this->position)) $this->position=0; if (! $this->level) $this->level=0; @@ -246,7 +309,7 @@ class Menubase */ public function update($user = null, $notrigger = 0) { - global $conf, $langs; + //global $conf, $langs; // Clean parameters $this->rowid=trim($this->rowid); @@ -265,7 +328,7 @@ class Menubase $this->langs=trim($this->langs); $this->perms=trim($this->perms); $this->enabled=trim($this->enabled); - $this->user=trim($this->user); + $this->user = (int) $this->user; // Check parameters // Put here code to add control on parameters values @@ -311,7 +374,7 @@ class Menubase */ public function fetch($id, $user = null) { - global $langs; + //global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; @@ -385,7 +448,7 @@ class Menubase */ public function delete($user) { - global $conf, $langs; + //global $conf, $langs; $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; $sql.= " WHERE rowid=".$this->id; diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 5c5975b9284..9eebf9091b2 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -1304,13 +1304,6 @@ class SMTPs $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; */ - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); - - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix - $host=dol_getprefix('email'); //NOTE: Message-ID should probably contain the username of the user who sent the msg diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e0a30c271a2..00ca3f3d45f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4275,7 +4275,9 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', } } - print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist + if ($savlimit || $morehtmlright) { + print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist + } print ''; @@ -4302,7 +4304,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be global $conf, $langs; print '
   '; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; - $out .= ''; - $out .= ''; + $out .= ''; + $out .= ''; $out .= ''; $out .= ''; foreach ($productFournList as $productFourn) { - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; } $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').'
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; } else { - $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); } return $out; } @@ -947,18 +947,18 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT"; - $sql.= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,"; - $sql.= " pfpl.price, pfpl.quantity"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl"; - $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= ", ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql.= " AND pfpl.fk_user = u.rowid"; - $sql.= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql.= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql.= " ORDER BY pfpl.datec"; - else $sql.= $this->db->order($sortfield, $sortorder); - $sql.=$this->db->plimit($limit, $offset); + $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,"; + $sql .= " pfpl.price, pfpl.quantity"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl"; + $sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= ", ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; + $sql .= " AND pfpl.fk_user = u.rowid"; + $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; + $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; + if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; + else $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); $resql = $this->db->query($sql); @@ -968,7 +968,7 @@ class ProductFournisseur extends Product while ($record = $this->db->fetch_array($resql)) { - $retarray[]=$record; + $retarray[] = $record; } $this->db->free($resql); @@ -976,7 +976,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1001,10 +1001,10 @@ class ProductFournisseur extends Product //$out .= ''.$langs->trans("QtyMin").''; $out .= ''.$langs->trans("User").''; foreach ($productFournLogList as $productFournLog) { - $out.= ''.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').''; - $out.= ''.price($productFournLog['price']).''; + $out .= ''.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').''; + $out .= ''.price($productFournLog['price']).''; //$out.= ''.$productFournLog['quantity'].''; - $out.= ''.$productFournLog['lastname'].''; + $out .= ''.$productFournLog['lastname'].''; } $out .= ''; } @@ -1027,19 +1027,19 @@ class ProductFournisseur extends Product { global $db, $conf, $langs; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("SupplierRef") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref_supplier; + $label = ''.$langs->trans("SupplierRef").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref_supplier; $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here if (is_array($logPrices) && count($logPrices) > 0) { - $label.= '
'; - $label.= '' . $langs->trans("History") . ''; - $label.= $this->displayPriceProductFournisseurLog($logPrices); + $label .= '
'; + $label .= ''.$langs->trans("History").''; + $label .= $this->displayPriceProductFournisseurLog($logPrices); } $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; @@ -1047,31 +1047,31 @@ class ProductFournisseur extends Product if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("SupplierRef"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("SupplierRef"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->fourn_ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->fourn_ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -1096,24 +1096,24 @@ class ProductFournisseur extends Product private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) { // Add record into log table - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log("; - $sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; + $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; $sql .= "values("; - $sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; - $sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; - $sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').","; - $sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').","; - $sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').","; - $sql .= "'" . $this->db->idate($datec) . "',"; - $sql .= " " . $this->product_fourn_price_id . ","; - $sql .= " " . $user->id . ","; - $sql .= " " . price2num($buyprice) . ","; - $sql .= " " . $qty; + $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; + $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; + $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; + $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; + $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; + $sql .= "'".$this->db->idate($datec)."',"; + $sql .= " ".$this->product_fourn_price_id.","; + $sql .= " ".$user->id.","; + $sql .= " ".price2num($buyprice).","; + $sql .= " ".$qty; $sql .= ")"; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { return -1; } else { return 1; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index aeb945bc220..207133d9cfa 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -40,9 +40,9 @@ $result = restrictedArea($user, 'societe', $socid, ''); * View */ -$commandestatic=new CommandeFournisseur($db); -$facturestatic=new FactureFournisseur($db); -$companystatic=new Societe($db); +$commandestatic = new CommandeFournisseur($db); +$facturestatic = new FactureFournisseur($db); +$companystatic = new Societe($db); llxHeader("", $langs->trans("SuppliersArea")); @@ -56,13 +56,13 @@ print '
'; // Orders $sql = "SELECT count(cf.rowid), cf.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s"; +$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -$sql.= " WHERE cf.fk_soc = s.rowid "; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; -$sql.= " AND cf.entity = ".$conf->entity; -$sql.= " GROUP BY cf.fk_statut"; +$sql .= " WHERE cf.fk_soc = s.rowid "; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; +$sql .= " AND cf.entity = ".$conf->entity; +$sql .= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); if ($resql) @@ -97,19 +97,19 @@ else // Draft orders -if (! empty($conf->fournisseur->enabled)) +if (!empty($conf->fournisseur->enabled)) { $langs->load("orders"); $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,"; - $sql.= " s.nom as name, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " s.nom as name, s.rowid as socid"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE cf.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; - $sql.= " AND cf.entity = ".$conf->entity; - $sql.= " AND cf.fk_statut = 0"; + $sql .= " WHERE cf.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; + $sql .= " AND cf.entity = ".$conf->entity; + $sql .= " AND cf.fk_statut = 0"; if ($socid) $sql .= " AND cf.fk_soc = ".$socid; $resql = $db->query($sql); @@ -129,21 +129,21 @@ if (! empty($conf->fournisseur->enabled)) $obj = $db->fetch_object($resql); print ''; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; print $commandestatic->getNomUrl(1, '', 16); print ''; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=0; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = 0; print $companystatic->getNomUrl(1, '', 16); print ''; print ''.price($obj->total_ttc).''; $i++; $total += $obj->total_ttc; } - if ($total>0) + if ($total > 0) { print ''.$langs->trans("Total").''.price($total).""; } @@ -154,22 +154,22 @@ if (! empty($conf->fournisseur->enabled)) } // Draft invoices -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type"; - $sql.= ", s.nom as name, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", s.nom as name, s.rowid as socid"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE s.rowid = ff.fk_soc"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; - $sql.= " AND ff.entity = ".$conf->entity; - $sql.= " AND ff.fk_statut = 0"; + $sql .= " WHERE s.rowid = ff.fk_soc"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; + $sql .= " AND ff.entity = ".$conf->entity; + $sql .= " AND ff.fk_statut = 0"; if ($socid) $sql .= " AND f.fk_soc = ".$socid; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); if ($num) @@ -185,20 +185,20 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $obj = $db->fetch_object($resql); print ''; - $facturestatic->ref=$obj->ref; - $facturestatic->id=$obj->rowid; - $facturestatic->type=$obj->type; + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->type = $obj->type; print $facturestatic->getNomUrl(1, ''); print ''; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=0; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = 0; print $companystatic->getNomUrl(1, '', 16); print ''; print ''.price($obj->total_ttc).''; print ''; - $tot_ttc+=$obj->total_ttc; + $tot_ttc += $obj->total_ttc; $i++; } @@ -225,18 +225,18 @@ print '
'; /* * List last modified supliers */ -$max=10; +$max = 10; $sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur, s.code_compta_fournisseur"; -$sql.= ", st.libelle as stcomm"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; +$sql .= ", st.libelle as stcomm"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND s.fournisseur = 1"; -$sql.= " AND s.entity IN (".getEntity('societe').")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql .= " WHERE s.fk_stcomm = st.id"; +$sql .= " AND s.fournisseur = 1"; +$sql .= " AND s.entity IN (".getEntity('societe').")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; -$sql.= " ORDER BY s.tms DESC"; +$sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); @@ -252,7 +252,7 @@ if ($resql) print ''.$langs->trans("DateModification")."\n"; print "\n"; - while ($obj = $db->fetch_object($resql) ) + while ($obj = $db->fetch_object($resql)) { print ''; print ''.img_object($langs->trans("ShowSupplier"), "company").''; @@ -275,7 +275,7 @@ else * List of suppliers categories */ $companystatic->LoadSupplierCateg(); -$categstatic=new Categorie($db); +$categstatic = new Categorie($db); if (count($companystatic->SupplierCategories)) { @@ -290,9 +290,9 @@ if (count($companystatic->SupplierCategories)) { print ''."\n"; print ''; - $categstatic->id=$rowid; - $categstatic->ref=$label; - $categstatic->label=$label; + $categstatic->id = $rowid; + $categstatic->ref = $label; + $categstatic->label = $label; print $categstatic->getNomUrl(1); print ''."\n"; // TODO this page not exist diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index cac93404a85..c5a88028586 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -911,7 +911,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ // Si il y a une erreur if (GETPOST('error')) { - switch(GETPOST('error')) { + switch (GETPOST('error')) { case 'datefin' : $errors[] = $langs->trans('ErrorEndDateCP'); break; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 37d38ea69eb..c44c588b335 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -25,7 +25,7 @@ * \ingroup holiday * \brief Class file of the module paid holiday. */ -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -36,12 +36,12 @@ class Holiday extends CommonObject /** * @var string ID to identify managed object */ - public $element='holiday'; + public $element = 'holiday'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='holiday'; + public $table_element = 'holiday'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -70,47 +70,47 @@ class Holiday extends CommonObject */ public $fk_user; - public $date_create=''; + public $date_create = ''; /** * @var string description */ public $description; - public $date_debut=''; // Date start in PHP server TZ - public $date_fin=''; // Date end in PHP server TZ - public $date_debut_gmt=''; // Date start in GMT - public $date_fin_gmt=''; // Date end in GMT - public $halfday=''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning - public $statut=''; // 1=draft, 2=validated, 3=approved + public $date_debut = ''; // Date start in PHP server TZ + public $date_fin = ''; // Date end in PHP server TZ + public $date_debut_gmt = ''; // Date start in GMT + public $date_fin_gmt = ''; // Date end in GMT + public $halfday = ''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning + public $statut = ''; // 1=draft, 2=validated, 3=approved /** * @var int ID */ public $fk_validator; - public $date_valid=''; + public $date_valid = ''; /** * @var int ID */ public $fk_user_valid; - public $date_refuse=''; + public $date_refuse = ''; /** * @var int ID */ public $fk_user_refuse; - public $date_cancel=''; + public $date_cancel = ''; /** * @var int ID */ public $fk_user_cancel; - public $detail_refuse=''; + public $detail_refuse = ''; /** * @var int ID @@ -175,21 +175,21 @@ class Holiday extends CommonObject $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; } - if (! empty($conf->global->HOLIDAY_ADDON)) + if (!empty($conf->global->HOLIDAY_ADDON)) { - $mybool=false; + $mybool = false; $file = $conf->global->HOLIDAY_ADDON.".php"; $classname = $conf->global->HOLIDAY_ADDON; // Include file with class - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/holiday/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } if ($mybool === false) @@ -207,7 +207,7 @@ class Holiday extends CommonObject } else { - $this->error=$obj->error; + $this->error = $obj->error; //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } @@ -256,58 +256,58 @@ class Holiday extends CommonObject public function create($user, $notrigger = 0) { global $conf; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Check parameters - if (empty($this->fk_user) || ! is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error="ErrorBadParameterFkUser"; return -1; } - if (empty($this->fk_validator) || ! is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error="ErrorBadParameterFkValidator"; return -1; } - if (empty($this->fk_type) || ! is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error="ErrorBadParameterFkType"; return -1; } + if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error = "ErrorBadParameterFkUser"; return -1; } + if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error = "ErrorBadParameterFkValidator"; return -1; } + if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error = "ErrorBadParameterFkType"; return -1; } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; - $sql.= "fk_user,"; - $sql.= "date_create,"; - $sql.= "description,"; - $sql.= "date_debut,"; - $sql.= "date_fin,"; - $sql.= "halfday,"; - $sql.= "statut,"; - $sql.= "fk_validator,"; - $sql.= "fk_type,"; - $sql.= "fk_user_create,"; - $sql.= "entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->fk_user)."',"; - $sql.= " '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->escape($this->description)."',"; - $sql.= " '".$this->db->idate($this->date_debut)."',"; - $sql.= " '".$this->db->idate($this->date_fin)."',"; - $sql.= " ".$this->halfday.","; - $sql.= " '1',"; - $sql.= " '".$this->db->escape($this->fk_validator)."',"; - $sql.= " ".$this->fk_type.","; - $sql.= " ".$user->id.","; - $sql.= " ".$conf->entity; - $sql.= ")"; + $sql .= "fk_user,"; + $sql .= "date_create,"; + $sql .= "description,"; + $sql .= "date_debut,"; + $sql .= "date_fin,"; + $sql .= "halfday,"; + $sql .= "statut,"; + $sql .= "fk_validator,"; + $sql .= "fk_type,"; + $sql .= "fk_user_create,"; + $sql .= "entity"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->fk_user)."',"; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->escape($this->description)."',"; + $sql .= " '".$this->db->idate($this->date_debut)."',"; + $sql .= " '".$this->db->idate($this->date_fin)."',"; + $sql .= " ".$this->halfday.","; + $sql .= " '1',"; + $sql .= " '".$this->db->escape($this->fk_validator)."',"; + $sql .= " ".$this->fk_type.","; + $sql .= " ".$user->id.","; + $sql .= " ".$conf->entity; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday"); - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_CREATE', $user); + $result = $this->call_trigger('HOLIDAY_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -316,13 +316,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -344,34 +344,34 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.date_create,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; - $sql.= " cp.note_private,"; - $sql.= " cp.note_public,"; - $sql.= " cp.fk_user_create,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; - if ($id > 0) $sql.= " WHERE cp.rowid = ".$id; - else $sql.=" WHERE cp.ref = '".$this->db->escape($ref)."'"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.date_create,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; + $sql .= " cp.note_private,"; + $sql .= " cp.note_public,"; + $sql .= " cp.fk_user_create,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + if ($id > 0) $sql .= " WHERE cp.rowid = ".$id; + else $sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -379,7 +379,7 @@ class Holiday extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = ($obj->ref?$obj->ref:$obj->rowid); + $this->ref = ($obj->ref ? $obj->ref : $obj->rowid); $this->fk_user = $obj->fk_user; $this->date_create = $this->db->jdate($obj->date_create); $this->description = $obj->description; @@ -411,7 +411,7 @@ class Holiday extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -429,55 +429,55 @@ class Holiday extends CommonObject global $langs, $conf; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.date_create,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.date_create,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; - $sql.= " uu.lastname as user_lastname,"; - $sql.= " uu.firstname as user_firstname,"; - $sql.= " uu.login as user_login,"; - $sql.= " uu.statut as user_statut,"; - $sql.= " uu.photo as user_photo,"; + $sql .= " uu.lastname as user_lastname,"; + $sql .= " uu.firstname as user_firstname,"; + $sql .= " uu.login as user_login,"; + $sql .= " uu.statut as user_statut,"; + $sql .= " uu.photo as user_photo,"; - $sql.= " ua.lastname as validator_lastname,"; - $sql.= " ua.firstname as validator_firstname,"; - $sql.= " ua.login as validator_login,"; - $sql.= " ua.statut as validator_statut,"; - $sql.= " ua.photo as validator_photo"; + $sql .= " ua.lastname as validator_lastname,"; + $sql .= " ua.firstname as validator_firstname,"; + $sql .= " ua.login as validator_login,"; + $sql .= " ua.statut as validator_statut,"; + $sql .= " ua.photo as validator_photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau - $sql.= " AND cp.fk_user IN (".$user_id.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau + $sql .= " AND cp.fk_user IN (".$user_id.")"; // Selection filter - if(!empty($filter)) { - $sql.= $filter; + if (!empty($filter)) { + $sql .= $filter; } // Order of display of the result - if(!empty($order)) { - $sql.= $order; + if (!empty($order)) { + $sql .= $order; } dol_syslog(get_class($this)."::fetchByUser", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // If no SQL error if ($resql) { @@ -486,16 +486,16 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // If no registration - if(!$num) { + if (!$num) { return 2; } // List the records and add them to the table - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; - $tab_result[$i]['ref'] = ($obj->ref?$obj->ref:$obj->rowid); + $tab_result[$i]['ref'] = ($obj->ref ? $obj->ref : $obj->rowid); $tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_type'] = $obj->fk_type; @@ -538,7 +538,7 @@ class Holiday extends CommonObject else { // SQL Error - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -555,55 +555,55 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.date_create,"; - $sql.= " cp.tms as date_update,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.date_create,"; + $sql .= " cp.tms as date_update,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; - $sql.= " uu.lastname as user_lastname,"; - $sql.= " uu.firstname as user_firstname,"; - $sql.= " uu.login as user_login,"; - $sql.= " uu.statut as user_statut,"; - $sql.= " uu.photo as user_photo,"; + $sql .= " uu.lastname as user_lastname,"; + $sql .= " uu.firstname as user_firstname,"; + $sql .= " uu.login as user_login,"; + $sql .= " uu.statut as user_statut,"; + $sql .= " uu.photo as user_photo,"; - $sql.= " ua.lastname as validator_lastname,"; - $sql.= " ua.firstname as validator_firstname,"; - $sql.= " ua.login as validator_login,"; - $sql.= " ua.statut as validator_statut,"; - $sql.= " ua.photo as validator_photo"; + $sql .= " ua.lastname as validator_lastname,"; + $sql .= " ua.firstname as validator_firstname,"; + $sql .= " ua.login as validator_login,"; + $sql .= " ua.statut as validator_statut,"; + $sql .= " ua.photo as validator_photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau // Selection filtering - if(!empty($filter)) { - $sql.= $filter; + if (!empty($filter)) { + $sql .= $filter; } // order of display - if(!empty($order)) { - $sql.= $order; + if (!empty($order)) { + $sql .= $order; } dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // If no SQL error if ($resql) { @@ -612,16 +612,16 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // If no registration - if(!$num) { + if (!$num) { return 2; } // List the records and add them to the table - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; - $tab_result[$i]['ref'] = ($obj->ref?$obj->ref:$obj->rowid); + $tab_result[$i]['ref'] = ($obj->ref ? $obj->ref : $obj->rowid); $tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_type'] = $obj->fk_type; $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create); @@ -663,7 +663,7 @@ class Holiday extends CommonObject else { // SQL Error - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -679,10 +679,10 @@ class Holiday extends CommonObject public function validate($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) { $num = $this->getNextNumRef(null); } @@ -694,28 +694,28 @@ class Holiday extends CommonObject // Update status $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - $sql.= " ref = '".$this->db->escape($num)."'"; - $sql.= " WHERE rowid= ".$this->id; + $sql .= " ref = '".$this->db->escape($num)."'"; + $sql .= " WHERE rowid= ".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_VALIDATE', $user); + $result = $this->call_trigger('HOLIDAY_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -724,13 +724,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::validate ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -750,86 +750,86 @@ class Holiday extends CommonObject public function approve($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - $sql.= " description= '".$this->db->escape($this->description)."',"; + $sql .= " description= '".$this->db->escape($this->description)."',"; - if(!empty($this->date_debut)) { - $sql.= " date_debut = '".$this->db->idate($this->date_debut)."',"; + if (!empty($this->date_debut)) { + $sql .= " date_debut = '".$this->db->idate($this->date_debut)."',"; } else { $error++; } - if(!empty($this->date_fin)) { - $sql.= " date_fin = '".$this->db->idate($this->date_fin)."',"; + if (!empty($this->date_fin)) { + $sql .= " date_fin = '".$this->db->idate($this->date_fin)."',"; } else { $error++; } - $sql.= " halfday = ".$this->halfday.","; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + $sql .= " halfday = ".$this->halfday.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - if(!empty($this->fk_validator)) { - $sql.= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; + if (!empty($this->fk_validator)) { + $sql .= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; } else { $error++; } - if(!empty($this->date_valid)) { - $sql.= " date_valid = '".$this->db->idate($this->date_valid)."',"; + if (!empty($this->date_valid)) { + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; } else { - $sql.= " date_valid = NULL,"; + $sql .= " date_valid = NULL,"; } - if(!empty($this->fk_user_valid)) { - $sql.= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; + if (!empty($this->fk_user_valid)) { + $sql .= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; } else { - $sql.= " fk_user_valid = NULL,"; + $sql .= " fk_user_valid = NULL,"; } - if(!empty($this->date_refuse)) { - $sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; + if (!empty($this->date_refuse)) { + $sql .= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; } else { - $sql.= " date_refuse = NULL,"; + $sql .= " date_refuse = NULL,"; } - if(!empty($this->fk_user_refuse)) { - $sql.= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; + if (!empty($this->fk_user_refuse)) { + $sql .= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; } else { - $sql.= " fk_user_refuse = NULL,"; + $sql .= " fk_user_refuse = NULL,"; } - if(!empty($this->date_cancel)) { - $sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; + if (!empty($this->date_cancel)) { + $sql .= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; } else { - $sql.= " date_cancel = NULL,"; + $sql .= " date_cancel = NULL,"; } - if(!empty($this->fk_user_cancel)) { - $sql.= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; + if (!empty($this->fk_user_cancel)) { + $sql .= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; } else { - $sql.= " fk_user_cancel = NULL,"; + $sql .= " fk_user_cancel = NULL,"; } - if(!empty($this->detail_refuse)) { - $sql.= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; + if (!empty($this->detail_refuse)) { + $sql .= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; } else { - $sql.= " detail_refuse = NULL"; + $sql .= " detail_refuse = NULL"; } - $sql.= " WHERE rowid= ".$this->id; + $sql .= " WHERE rowid= ".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::approve", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_APPROVE', $user); + $result = $this->call_trigger('HOLIDAY_APPROVE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -838,13 +838,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::approve ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -863,86 +863,86 @@ class Holiday extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - $sql.= " description= '".$this->db->escape($this->description)."',"; + $sql .= " description= '".$this->db->escape($this->description)."',"; - if(!empty($this->date_debut)) { - $sql.= " date_debut = '".$this->db->idate($this->date_debut)."',"; + if (!empty($this->date_debut)) { + $sql .= " date_debut = '".$this->db->idate($this->date_debut)."',"; } else { $error++; } - if(!empty($this->date_fin)) { - $sql.= " date_fin = '".$this->db->idate($this->date_fin)."',"; + if (!empty($this->date_fin)) { + $sql .= " date_fin = '".$this->db->idate($this->date_fin)."',"; } else { $error++; } - $sql.= " halfday = ".$this->halfday.","; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + $sql .= " halfday = ".$this->halfday.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - if(!empty($this->fk_validator)) { - $sql.= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; + if (!empty($this->fk_validator)) { + $sql .= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; } else { $error++; } - if(!empty($this->date_valid)) { - $sql.= " date_valid = '".$this->db->idate($this->date_valid)."',"; + if (!empty($this->date_valid)) { + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; } else { - $sql.= " date_valid = NULL,"; + $sql .= " date_valid = NULL,"; } - if(!empty($this->fk_user_valid)) { - $sql.= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; + if (!empty($this->fk_user_valid)) { + $sql .= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; } else { - $sql.= " fk_user_valid = NULL,"; + $sql .= " fk_user_valid = NULL,"; } - if(!empty($this->date_refuse)) { - $sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; + if (!empty($this->date_refuse)) { + $sql .= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; } else { - $sql.= " date_refuse = NULL,"; + $sql .= " date_refuse = NULL,"; } - if(!empty($this->fk_user_refuse)) { - $sql.= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; + if (!empty($this->fk_user_refuse)) { + $sql .= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; } else { - $sql.= " fk_user_refuse = NULL,"; + $sql .= " fk_user_refuse = NULL,"; } - if(!empty($this->date_cancel)) { - $sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; + if (!empty($this->date_cancel)) { + $sql .= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; } else { - $sql.= " date_cancel = NULL,"; + $sql .= " date_cancel = NULL,"; } - if(!empty($this->fk_user_cancel)) { - $sql.= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; + if (!empty($this->fk_user_cancel)) { + $sql .= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; } else { - $sql.= " fk_user_cancel = NULL,"; + $sql .= " fk_user_cancel = NULL,"; } - if(!empty($this->detail_refuse)) { - $sql.= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; + if (!empty($this->detail_refuse)) { + $sql .= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; } else { - $sql.= " detail_refuse = NULL"; + $sql .= " detail_refuse = 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(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_MODIFY', $user); + $result = $this->call_trigger('HOLIDAY_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -951,13 +951,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -977,25 +977,25 @@ class Holiday extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_DELETE', $user); + $result = $this->call_trigger('HOLIDAY_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -1004,13 +1004,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -1036,10 +1036,10 @@ class Holiday extends CommonObject { $this->fetchByUser($fk_user, '', ''); - foreach($this->holiday as $infos_CP) + foreach ($this->holiday as $infos_CP) { - if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays - if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays + if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays + if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays /* var_dump("--"); var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']); @@ -1118,36 +1118,36 @@ class Holiday extends CommonObject { global $langs, $conf; - $isavailablemorning=true; - $isavailableafternoon=true; + $isavailablemorning = true; + $isavailableafternoon = true; $sql = "SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday, cp.statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = ".(int) $fk_user; - $sql.= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; - if ($status != '-1') $sql.=" AND cp.statut IN (".$this->db->escape($status).")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = ".(int) $fk_user; + $sql .= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; + if ($status != '-1') $sql .= " AND cp.statut IN (".$this->db->escape($status).")"; $resql = $this->db->query($sql); if ($resql) { - $num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon + $num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon if ($num_rows > 0) { - $arrayofrecord=array(); - $i=0; + $arrayofrecord = array(); + $i = 0; while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); // Note: $obj->halfday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning - $arrayofrecord[$obj->rowid]=array('date_start'=>$this->db->jdate($obj->date_start), 'date_end'=>$this->db->jdate($obj->date_end), 'halfday'=>$obj->halfday); + $arrayofrecord[$obj->rowid] = array('date_start'=>$this->db->jdate($obj->date_start), 'date_end'=>$this->db->jdate($obj->date_end), 'halfday'=>$obj->halfday); $i++; } // We found a record, user is on holiday by default, so is not available is true. $isavailablemorning = true; - foreach($arrayofrecord as $record) + foreach ($arrayofrecord as $record) { if ($timestamp == $record['date_start'] && $record['halfday'] == 2) continue; if ($timestamp == $record['date_start'] && $record['halfday'] == -1) continue; @@ -1155,7 +1155,7 @@ class Holiday extends CommonObject break; } $isavailableafternoon = true; - foreach($arrayofrecord as $record) + foreach ($arrayofrecord as $record) { if ($timestamp == $record['date_end'] && $record['halfday'] == 2) continue; if ($timestamp == $record['date_end'] && $record['halfday'] == 1) continue; @@ -1181,26 +1181,26 @@ class Holiday extends CommonObject { global $langs; - $result=''; + $result = ''; - $label=$langs->trans("Show").': '.$this->ref; + $label = $langs->trans("Show").': '.$this->ref; $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; //if ($option != 'nolink') //{ // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} $linkstart = ''; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -1270,24 +1270,24 @@ class Holiday extends CommonObject global $langs; // Liste des statuts - $name = array('DraftCP','ToReviewCP','ApprovedCP','CancelCP','RefuseCP'); - $nb = count($name)+1; + $name = array('DraftCP', 'ToReviewCP', 'ApprovedCP', 'CancelCP', 'RefuseCP'); + $nb = count($name) + 1; // Select HTML $statut = ''."\n"; + $statut .= ''."\n"; print $statut; } @@ -1302,12 +1302,12 @@ class Holiday extends CommonObject { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".$value."'"; - $sql.= " WHERE name = '".$name."'"; + $sql .= " value = '".$value."'"; + $sql .= " WHERE name = '".$name."'"; dol_syslog(get_class($this).'::updateConfCP name='.$name.'', LOG_DEBUG); $result = $this->db->query($sql); - if($result) { + if ($result) { return true; } @@ -1325,13 +1325,13 @@ class Holiday extends CommonObject public function getConfCP($name, $createifnotfound = '') { $sql = "SELECT value"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; - $sql.= " WHERE name = '".$this->db->escape($name)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $sql .= " WHERE name = '".$this->db->escape($name)."'"; dol_syslog(get_class($this).'::getConfCP name='.$name.' createifnotfound='.$createifnotfound, LOG_DEBUG); $result = $this->db->query($sql); - if($result) { + if ($result) { $obj = $this->db->fetch_object($result); // Return value if (empty($obj)) @@ -1339,7 +1339,7 @@ class Holiday extends CommonObject if ($createifnotfound) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_config(name, value)"; - $sql.= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')"; + $sql .= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')"; $result = $this->db->query($sql); if ($result) { @@ -1347,7 +1347,7 @@ class Holiday extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -2; } } @@ -1362,7 +1362,7 @@ class Holiday extends CommonObject } } else { // Erreur SQL - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1386,7 +1386,7 @@ class Holiday extends CommonObject $langs->load("holiday"); // Si mise à jour pour tout le monde en début de mois - $now=dol_now(); + $now = dol_now(); $month = date('m', $now); $newdateforlastupdate = dol_print_date($now, '%Y%m%d%H%M%S'); @@ -1405,16 +1405,16 @@ class Holiday extends CommonObject $nbUser = count($users); $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".$this->db->escape($newdateforlastupdate)."'"; - $sql.= " WHERE name = 'lastUpdate'"; + $sql .= " value = '".$this->db->escape($newdateforlastupdate)."'"; + $sql .= " WHERE name = 'lastUpdate'"; $result = $this->db->query($sql); - $typeleaves=$this->getTypes(1, 1); + $typeleaves = $this->getTypes(1, 1); // Update each user counter foreach ($users as $userCounter) { $nbDaysToAdd = $typeleaves[$userCounter['type']]['newByMonth']; - if(empty($nbDaysToAdd)) continue; + if (empty($nbDaysToAdd)) continue; dol_syslog("We update leave type id ".$userCounter['type']." for user id ".$userCounter['rowid'], LOG_DEBUG); @@ -1433,7 +1433,7 @@ class Holiday extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1453,7 +1453,7 @@ class Holiday extends CommonObject $nbHoliday = price2num($nbHoliday, 5); $sql = "SELECT nb_holiday FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; + $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $resql = $this->db->query($sql); if ($resql) { @@ -1463,36 +1463,36 @@ class Holiday extends CommonObject { // Update for user $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; - $sql.= " nb_holiday = ".$nbHoliday; - $sql.= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; + $sql .= " nb_holiday = ".$nbHoliday; + $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $result = $this->db->query($sql); - if (! $result) + if (!$result) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } else { // Insert for user $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users(nb_holiday, fk_user, fk_type) VALUES ("; - $sql.= $nbHoliday; - $sql.= ", ".(int) $userID.", ".(int) $fk_type.")"; + $sql .= $nbHoliday; + $sql .= ", ".(int) $userID.", ".(int) $fk_type.")"; $result = $this->db->query($sql); - if (! $result) + if (!$result) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } else { - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } - if (! $error) + if (!$error) { return 1; } @@ -1513,16 +1513,16 @@ class Holiday extends CommonObject { $sql = "SELECT value"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; - $sql.= " WHERE name = '".$name."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $sql .= " WHERE name = '".$name."'"; $result = $this->db->query($sql); - if($result) { + if ($result) { $obj = $this->db->fetch_object($result); // Si la valeur est 1 on retourne checked - if($obj->value) { + if ($obj->value) { return 'checked'; } } @@ -1539,29 +1539,29 @@ class Holiday extends CommonObject public function createCPusers($single = false, $userid = '') { // Si c'est l'ensemble des utilisateurs à ajouter - if (! $single) + if (!$single) { dol_syslog(get_class($this).'::createCPusers'); $arrayofusers = $this->fetchUsers(false, true); - foreach($arrayofusers as $users) + foreach ($arrayofusers as $users) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " (fk_user, nb_holiday)"; - $sql.= " VALUES ('".$users['rowid']."','0')"; + $sql .= " (fk_user, nb_holiday)"; + $sql .= " VALUES ('".$users['rowid']."','0')"; - $resql=$this->db->query($sql); - if (! $resql) dol_print_error($this->db); + $resql = $this->db->query($sql); + if (!$resql) dol_print_error($this->db); } } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " (fk_user, nb_holiday)"; - $sql.= " VALUES ('".$userid."','0')"; + $sql .= " (fk_user, nb_holiday)"; + $sql .= " VALUES ('".$userid."','0')"; - $resql=$this->db->query($sql); - if (! $resql) dol_print_error($this->db); + $resql = $this->db->query($sql); + if (!$resql) dol_print_error($this->db); } } @@ -1575,7 +1575,7 @@ class Holiday extends CommonObject { $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = '".$user_id."'"; + $sql .= " WHERE fk_user = '".$user_id."'"; $this->db->query($sql); } @@ -1591,13 +1591,13 @@ class Holiday extends CommonObject public function getCPforUser($user_id, $fk_type = 0) { $sql = "SELECT nb_holiday"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = ".(int) $user_id; - if ($fk_type > 0) $sql.=" AND fk_type = ".(int) $fk_type; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users"; + $sql .= " WHERE fk_user = ".(int) $user_id; + if ($fk_type > 0) $sql .= " AND fk_type = ".(int) $fk_type; dol_syslog(get_class($this).'::getCPforUser user_id='.$user_id.' type_id='.$fk_type, LOG_DEBUG); $result = $this->db->query($sql); - if($result) + if ($result) { $obj = $this->db->fetch_object($result); //return number_format($obj->nb_holiday,2); @@ -1631,23 +1631,23 @@ class Holiday extends CommonObject // Si utilisateur de Dolibarr $sql = "SELECT u.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE (ug.fk_user = u.rowid"; + $sql .= " AND ug.entity = ".$conf->entity.")"; + $sql .= " OR u.admin = 1"; } else { - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + $sql .= " WHERE u.entity IN (0,".$conf->entity.")"; } - $sql.= " AND u.statut > 0"; - if ($filters) $sql.=$filters; + $sql .= " AND u.statut > 0"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -1656,14 +1656,14 @@ class Holiday extends CommonObject $stringlist = ''; // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($i == 0) { - $stringlist.= $obj->rowid; + $stringlist .= $obj->rowid; } else { - $stringlist.= ', '.$obj->rowid; + $stringlist .= ', '.$obj->rowid; } $i++; @@ -1674,7 +1674,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1682,11 +1682,11 @@ class Holiday extends CommonObject { // We want only list of vacation balance for user ids $sql = "SELECT DISTINCT cpu.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE cpu.fk_user = u.user"; - if ($filters) $sql.=$filters; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE cpu.fk_user = u.user"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -1695,14 +1695,14 @@ class Holiday extends CommonObject $stringlist = ''; // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if($i == 0) { - $stringlist.= $obj->fk_user; + if ($i == 0) { + $stringlist .= $obj->fk_user; } else { - $stringlist.= ', '.$obj->fk_user; + $stringlist .= ', '.$obj->fk_user; } $i++; @@ -1713,7 +1713,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1779,11 +1779,11 @@ class Holiday extends CommonObject { // List of vacation balance users $sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE cpu.fk_user = u.rowid"; - if ($filters) $sql.=$filters; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE cpu.fk_user = u.rowid"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) @@ -1793,19 +1793,19 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user - $tab_result[$i]['name'] = $obj->lastname; // deprecated + $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user + $tab_result[$i]['name'] = $obj->lastname; // deprecated $tab_result[$i]['lastname'] = $obj->lastname; $tab_result[$i]['firstname'] = $obj->firstname; $tab_result[$i]['gender'] = $obj->gender; $tab_result[$i]['status'] = $obj->statut; $tab_result[$i]['employee'] = $obj->employee; $tab_result[$i]['photo'] = $obj->photo; - $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager + $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager $tab_result[$i]['type'] = $obj->fk_type; $tab_result[$i]['nb_holiday'] = $obj->nb_holiday; @@ -1818,7 +1818,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1836,20 +1836,20 @@ class Holiday extends CommonObject public function fetch_users_approver_holiday() { // phpcs:enable - $users_validator=array(); + $users_validator = array(); $sql = "SELECT DISTINCT ur.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; - $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; - $sql.= "UNION"; - $sql.= " SELECT DISTINCT ugu.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; - $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql .= " WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql .= "UNION"; + $sql .= " SELECT DISTINCT ugu.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql .= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; //print $sql; dol_syslog(get_class($this)."::fetch_users_approver_holiday sql=".$sql); $result = $this->db->query($sql); - if($result) + if ($result) { $num_rows = $this->db->num_rows($result); $i = 0; while ($i < $num_rows) @@ -1862,7 +1862,7 @@ class Holiday extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::fetch_users_approver_holiday Error ".$this->error, LOG_ERR); return -1; } @@ -1877,8 +1877,8 @@ class Holiday extends CommonObject public function countActiveUsers() { $sql = "SELECT count(u.rowid) as compteur"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.statut > 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.statut > 0"; $result = $this->db->query($sql); $objet = $this->db->fetch_object($result); @@ -1894,8 +1894,8 @@ class Holiday extends CommonObject { $sql = "SELECT count(u.rowid) as compteur"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u LEFT OUTER JOIN ".MAIN_DB_PREFIX."holiday_users hu ON (hu.fk_user=u.rowid)"; - $sql.= " WHERE u.statut > 0 AND hu.fk_user IS NULL"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u LEFT OUTER JOIN ".MAIN_DB_PREFIX."holiday_users hu ON (hu.fk_user=u.rowid)"; + $sql .= " WHERE u.statut > 0 AND hu.fk_user IS NULL"; $result = $this->db->query($sql); $objet = $this->db->fetch_object($result); @@ -1912,7 +1912,7 @@ class Holiday extends CommonObject */ public function verifNbUsers($userDolibarrWithoutCP, $userCP) { - if (empty($userCP)) $userCP=0; + if (empty($userCP)) $userCP = 0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); return 1; } @@ -1932,7 +1932,7 @@ class Holiday extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; $prev_solde = price2num($this->getCPforUser($fk_user_update, $fk_type), 5); $new_solde = price2num($new_solde, 5); @@ -1944,30 +1944,30 @@ class Holiday extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_logs ("; - $sql.= "date_action,"; - $sql.= "fk_user_action,"; - $sql.= "fk_user_update,"; - $sql.= "type_action,"; - $sql.= "prev_solde,"; - $sql.= "new_solde,"; - $sql.= "fk_type"; - $sql.= ") VALUES ("; - $sql.= " '".$this->db->idate(dol_now())."',"; - $sql.= " '".$fk_user_action."',"; - $sql.= " '".$fk_user_update."',"; - $sql.= " '".$this->db->escape($label)."',"; - $sql.= " '".$prev_solde."',"; - $sql.= " '".$new_solde."',"; - $sql.= " ".$fk_type; - $sql.= ")"; + $sql .= "date_action,"; + $sql .= "fk_user_action,"; + $sql .= "fk_user_update,"; + $sql .= "type_action,"; + $sql .= "prev_solde,"; + $sql .= "new_solde,"; + $sql .= "fk_type"; + $sql .= ") VALUES ("; + $sql .= " '".$this->db->idate(dol_now())."',"; + $sql .= " '".$fk_user_action."',"; + $sql .= " '".$fk_user_update."',"; + $sql .= " '".$this->db->escape($label)."',"; + $sql .= " '".$prev_solde."',"; + $sql .= " '".$new_solde."',"; + $sql .= " ".$fk_type; + $sql .= ")"; - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs"); } @@ -1975,13 +1975,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::addLogCP ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -2002,29 +2002,29 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cpl.rowid,"; - $sql.= " cpl.date_action,"; - $sql.= " cpl.fk_user_action,"; - $sql.= " cpl.fk_user_update,"; - $sql.= " cpl.type_action,"; - $sql.= " cpl.prev_solde,"; - $sql.= " cpl.new_solde,"; - $sql.= " cpl.fk_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl"; - $sql.= " WHERE cpl.rowid > 0"; // To avoid error with other search and criteria + $sql .= " cpl.rowid,"; + $sql .= " cpl.date_action,"; + $sql .= " cpl.fk_user_action,"; + $sql .= " cpl.fk_user_update,"; + $sql .= " cpl.type_action,"; + $sql .= " cpl.prev_solde,"; + $sql .= " cpl.new_solde,"; + $sql .= " cpl.fk_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl"; + $sql .= " WHERE cpl.rowid > 0"; // To avoid error with other search and criteria // Filtrage de séléction - if(!empty($filter)) { - $sql.= " ".$filter; + if (!empty($filter)) { + $sql .= " ".$filter; } // Ordre d'affichage - if(!empty($order)) { - $sql.= " ".$order; + if (!empty($order)) { + $sql .= " ".$order; } dol_syslog(get_class($this)."::fetchLog", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -2033,12 +2033,12 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // Si pas d'enregistrement - if(!$num) { + if (!$num) { return 2; } // On liste les résultats et on les ajoutent dans le tableau - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; @@ -2059,7 +2059,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -2077,10 +2077,10 @@ class Holiday extends CommonObject global $mysoc; $sql = "SELECT rowid, code, label, affect, delay, newByMonth"; - $sql.= " FROM " . MAIN_DB_PREFIX . "c_holiday_types"; - $sql.= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; - if ($active >= 0) $sql.=" AND active = ".((int) $active); - if ($affect >= 0) $sql.=" AND affect = ".((int) $affect); + $sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types"; + $sql .= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; + if ($active >= 0) $sql .= " AND active = ".((int) $active); + if ($affect >= 0) $sql .= " AND affect = ".((int) $affect); $result = $this->db->query($sql); if ($result) @@ -2111,21 +2111,21 @@ class Holiday extends CommonObject */ public function initAsSpecimen() { - global $user,$langs; + global $user, $langs; // Initialise parameters - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; - $this->fk_user=1; - $this->description='SPECIMEN description'; - $this->date_debut=dol_now(); - $this->date_fin=dol_now()+(24*3600); - $this->date_valid=dol_now(); - $this->fk_validator=1; - $this->halfday=0; - $this->fk_type=1; - $this->statut=Holiday::STATUS_VALIDATED; + $this->fk_user = 1; + $this->description = 'SPECIMEN description'; + $this->date_debut = dol_now(); + $this->date_fin = dol_now() + (24 * 3600); + $this->date_valid = dol_now(); + $this->fk_validator = 1; + $this->halfday = 0; + $this->fk_type = 1; + $this->statut = Holiday::STATUS_VALIDATED; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2137,17 +2137,17 @@ class Holiday extends CommonObject public function load_state_board() { // phpcs:enable - $this->nb=array(); + $this->nb = array(); $sql = "SELECT count(h.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as h"; - $sql.= " WHERE h.statut > 1"; - $sql.= " AND h.entity IN (".getEntity('holiday').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h"; + $sql .= " WHERE h.statut > 1"; + $sql .= " AND h.entity IN (".getEntity('holiday').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) { - $this->nb["holidays"]=$obj->nb; + while ($obj = $this->db->fetch_object($resql)) { + $this->nb["holidays"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2155,7 +2155,7 @@ class Holiday extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2211,7 +2211,7 @@ class Holiday extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 281a573353b..24c9b827117 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -62,7 +62,7 @@ $max=3; */ // Update sold -if (! empty($conf->holiday->enabled) && ! empty($setupcompanynotcomplete)) +if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) { $result = $holiday->updateBalance(); } @@ -73,18 +73,18 @@ if (! empty($conf->holiday->enabled) && ! empty($setupcompanynotcomplete)) */ $childids = $user->getAllChildIds(); -$childids[]=$user->id; +$childids[] = $user->id; llxHeader('', $langs->trans('HRMArea')); print load_fiche_titre($langs->trans("HRMArea"), '', 'hrm'); -if (! empty($setupcompanynotcomplete)) +if (!empty($setupcompanynotcomplete)) { $langs->load("errors"); - $warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete")); - print '
'; + $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); + print '
'; llxFooter(); exit; @@ -134,7 +134,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele } -if (! empty($conf->holiday->enabled)) +if (!empty($conf->holiday->enabled)) { if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { @@ -146,13 +146,13 @@ if (! empty($conf->holiday->enabled)) print ''; print ''; - $out=''; - $typeleaves=$holiday->getTypes(1, 1); - foreach($typeleaves as $key => $val) + $out = ''; + $typeleaves = $holiday->getTypes(1, 1); + foreach ($typeleaves as $key => $val) { $nb_type = $holiday->getCPforUser($user->id, $val['rowid']); $nb_holiday += $nb_type; - $out .= ' - '.$val['label'].': '.($nb_type?price2num($nb_type):0).'
'; + $out .= ' - '.$val['label'].': '.($nb_type ?price2num($nb_type) : 0).'
'; } print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'
'; print $out; @@ -161,7 +161,7 @@ if (! empty($conf->holiday->enabled)) print ''; print '

'; } - elseif (! is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) + elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) { print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'
'; } @@ -287,22 +287,22 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire { $total_ttc = $totalam = $total = 0; - $expensereportstatic=new ExpenseReport($db); - $userstatic=new User($db); + $expensereportstatic = new ExpenseReport($db); + $userstatic = new User($db); while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); - $expensereportstatic->id=$obj->rowid; - $expensereportstatic->ref=$obj->ref; + $expensereportstatic->id = $obj->rowid; + $expensereportstatic->ref = $obj->ref; - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->lastname; - $userstatic->firstname=$obj->firstname; - $userstatic->email=$obj->email; - $userstatic->login=$obj->login; - $userstatic->statut=$obj->statut; - $userstatic->photo=$obj->photo; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->email; + $userstatic->login = $obj->login; + $userstatic->statut = $obj->statut; + $userstatic->photo = $obj->photo; print ''; print ''.$expensereportstatic->getNomUrl(1).''; diff --git a/htdocs/index.php b/htdocs/index.php index 37ea818817a..ad4412ad746 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -24,14 +24,14 @@ * \brief Dolibarr home page */ -define('NOCSRFCHECK', 1); // This is main home and login page. We must be able to go on it from another web site. +define('NOCSRFCHECK', 1); // This is main home and login page. We must be able to go on it from another web site. require 'main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // If not defined, we select menu "home" -$_GET['mainmenu']=GETPOST('mainmenu', 'aZ09')?GETPOST('mainmenu', 'aZ09'):'home'; -$action=GETPOST('action', 'aZ09'); +$_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ?GETPOST('mainmenu', 'aZ09') : 'home'; +$action = GETPOST('action', 'aZ09'); $hookmanager->initHooks(array('index')); @@ -46,7 +46,7 @@ if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_IN header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); exit; } -if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled +if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled { header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); exit; @@ -54,12 +54,12 @@ if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FO if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) { require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - $zone=GETPOST('areacode', 'aZ09'); - $userid=GETPOST('userid', 'int'); - $boxorder=GETPOST('boxorder', 'aZ09'); - $boxorder.=GETPOST('boxcombo', 'aZ09'); + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); - $result=InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); } @@ -68,26 +68,26 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis * View */ -if (! is_object($form)) $form=new Form($db); +if (!is_object($form)) $form = new Form($db); // Title -$title=$langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION; -if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$langs->trans("HomeArea").' - '.$conf->global->MAIN_APPLICATION_TITLE; +$title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $langs->trans("HomeArea").' - '.$conf->global->MAIN_APPLICATION_TITLE; llxHeader('', $title); -$resultboxes=FormOther::getBoxesArea($user, "0"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) +$resultboxes = FormOther::getBoxesArea($user, "0"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) print load_fiche_titre($langs->trans("HomeArea"), $resultboxes['selectboxlist'], 'home'); -if (! empty($conf->global->MAIN_MOTD)) +if (!empty($conf->global->MAIN_MOTD)) { - $conf->global->MAIN_MOTD=preg_replace('//i', '
', $conf->global->MAIN_MOTD); - if (! empty($conf->global->MAIN_MOTD)) + $conf->global->MAIN_MOTD = preg_replace('//i', '
', $conf->global->MAIN_MOTD); + if (!empty($conf->global->MAIN_MOTD)) { - $substitutionarray=getCommonSubstitutionArray($langs); + $substitutionarray = getCommonSubstitutionArray($langs); complete_substitutions_array($substitutionarray, $langs); $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs); @@ -117,39 +117,39 @@ $langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts')); if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { - $object=new stdClass(); - $parameters=array(); - $action=''; - $reshook=$hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - $boxstatFromHook=$hookmanager->resPrint; + $object = new stdClass(); + $parameters = array(); + $action = ''; + $reshook = $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $boxstatFromHook = $hookmanager->resPrint; if (empty($reshook)) { // Condition to be checked for each display line dashboard - $conditions=array( + $conditions = array( $user->rights->user->user->lire, - ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), - ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), - ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS), - ! empty($conf->societe->enabled) && $user->rights->societe->contact->lire, - ! empty($conf->adherent->enabled) && $user->rights->adherent->lire, - ! empty($conf->product->enabled) && $user->rights->produit->lire, - ! empty($conf->service->enabled) && $user->rights->service->lire, - ! empty($conf->propal->enabled) && $user->rights->propale->lire, - ! empty($conf->commande->enabled) && $user->rights->commande->lire, - ! empty($conf->facture->enabled) && $user->rights->facture->lire, - ! empty($conf->contrat->enabled) && $user->rights->contrat->lire, - ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, - ! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), - ! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), - ! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), - ! empty($conf->projet->enabled) && $user->rights->projet->lire, - ! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, - ! empty($conf->holiday->enabled) && $user->rights->holiday->read, - ! empty($conf->don->enabled) && $user->rights->don->lire + !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), + !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), + !empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS), + !empty($conf->societe->enabled) && $user->rights->societe->contact->lire, + !empty($conf->adherent->enabled) && $user->rights->adherent->lire, + !empty($conf->product->enabled) && $user->rights->produit->lire, + !empty($conf->service->enabled) && $user->rights->service->lire, + !empty($conf->propal->enabled) && $user->rights->propale->lire, + !empty($conf->commande->enabled) && $user->rights->commande->lire, + !empty($conf->facture->enabled) && $user->rights->facture->lire, + !empty($conf->contrat->enabled) && $user->rights->contrat->lire, + !empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, + !empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), + !empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), + !empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), + !empty($conf->projet->enabled) && $user->rights->projet->lire, + !empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, + !empty($conf->holiday->enabled) && $user->rights->holiday->read, + !empty($conf->don->enabled) && $user->rights->don->lire ); // Class file containing the method load_state_board for each line - $includes=array( + $includes = array( DOL_DOCUMENT_ROOT."/user/class/user.class.php", DOL_DOCUMENT_ROOT."/societe/class/client.class.php", DOL_DOCUMENT_ROOT."/societe/class/client.class.php", @@ -172,7 +172,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) DOL_DOCUMENT_ROOT."/don/class/don.class.php" ); // Name class containing the method load_state_board for each line - $classes=array('User', + $classes = array('User', 'Client', 'Client', 'Fournisseur', @@ -194,7 +194,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) 'Don' ); // Cle array returned by the method load_state_board for each line - $keys=array('users', + $keys = array('users', 'customers', 'prospects', 'suppliers', @@ -216,7 +216,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) 'donations' ); // Dashboard Icon lines - $icons=array('user', + $icons = array('user', 'company', 'company', 'company', @@ -238,7 +238,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) 'generic' ); // Translation keyword - $titres=array("Users", + $titres = array("Users", "ThirdPartyCustomersStats", "ThirdPartyProspectsStats", "Suppliers", @@ -260,7 +260,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) "Donations" ); // Dashboard Link lines - $links=array( + $links = array( DOL_URL_ROOT.'/user/list.php', DOL_URL_ROOT.'/societe/list.php?type=c&mainmenu=companies', DOL_URL_ROOT.'/societe/list.php?type=p&mainmenu=companies', @@ -308,36 +308,36 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) // Loop and displays each line of table - $boardloaded=array(); + $boardloaded = array(); foreach ($keys as $key=>$val) { if ($conditions[$key]) { $boxstatItem = ''; - $classe=$classes[$key]; + $classe = $classes[$key]; // Search in cache if load_state_board is already realized - if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe])) + if (!isset($boardloaded[$classe]) || !is_object($boardloaded[$classe])) { - include_once $includes[$key]; // Loading a class cost around 1Mb + include_once $includes[$key]; // Loading a class cost around 1Mb - $board=new $classe($db); + $board = new $classe($db); $board->load_state_board($user); - $boardloaded[$classe]=$board; + $boardloaded[$classe] = $board; } else { - $board=$boardloaded[$classe]; + $board = $boardloaded[$classe]; } if (!empty($langfile[$key])) $langs->load($langfile[$key]); - $text=$langs->trans($titres[$key]); - $boxstatItem.=''; - $boxstatItem.='
'; - $boxstatItem.=''.$text.'
'; - $boxstatItem.=''.img_object("", $icons[$key], 'class="inline-block"').' '.($board->nb[$val]?$board->nb[$val]:0).''; - $boxstatItem.='
'; - $boxstatItem.='
'; + $text = $langs->trans($titres[$key]); + $boxstatItem .= ''; + $boxstatItem .= '
'; + $boxstatItem .= ''.$text.'
'; + $boxstatItem .= ''.img_object("", $icons[$key], 'class="inline-block"').' '.($board->nb[$val] ? $board->nb[$val] : 0).''; + $boxstatItem .= '
'; + $boxstatItem .= '
'; $boxstatItems[$val] = $boxstatItem; } @@ -485,7 +485,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $parameters = array(); $action = ''; $reshook = $hookmanager->executeHooks('addOpenElementsDashboardLine', $parameters, $object, - $action); // Note that $action and $object may have been modified by some hooks + $action); // Note that $action and $object may have been modified by some hooks if ($reshook == 0) { $dashboardlines = array_merge($dashboardlines, $hookmanager->resArray); } @@ -586,7 +586,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { 'dashboardgroup' => $dashboardgroup ); $reshook = $hookmanager->executeHooks('addOpenElementsDashboardGroup', $parameters, $object, - $action); // Note that $action and $object may have been modified by some hooks + $action); // Note that $action and $object may have been modified by some hooks if ($reshook == 0) { $dashboardgroup = array_merge($dashboardgroup, $hookmanager->resArray); } @@ -628,23 +628,23 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $boxwork = ''; $boxwork .= '
'; - $boxwork .= '' . "\n"; + $boxwork .= '
'."\n"; $boxwork .= ''; - $boxwork .= ''; - $boxwork .= '' . "\n"; + $boxwork .= ''."\n"; // Show dashboard $nbworkboardempty = 0; @@ -673,21 +673,21 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { // global stats $globalStatsKey = false; - if (!empty($groupElement['globalStatsKey']) && empty($groupElement['globalStats'])){ // can be filled by hook + if (!empty($groupElement['globalStatsKey']) && empty($groupElement['globalStats'])) { // can be filled by hook $globalStatsKey = $groupElement['globalStatsKey']; $groupElement['globalStats'] = array(); - if(in_array($globalStatsKey, $keys)) + if (in_array($globalStatsKey, $keys)) { // get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links $keyIndex = array_search($globalStatsKey, $keys); - $classe=$classes[$keyIndex]; + $classe = $classes[$keyIndex]; if (isset($boardloaded[$classe]) && is_object($boardloaded[$classe])) { - $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey]?$boardloaded[$classe]->nb[$globalStatsKey]:0; + $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey] ? $boardloaded[$classe]->nb[$globalStatsKey] : 0; $nbTotal = doubleval($groupElement['globalStats']['total']); - if($nbTotal>=10000){ $nbTotal = round($nbTotal/1000, 2) .'k'; } + if ($nbTotal >= 10000) { $nbTotal = round($nbTotal / 1000, 2).'k'; } $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')'; $groupElement['globalStats']['total'] = $nbTotal; $groupElement['globalStats']['link'] = $links[$keyIndex]; @@ -696,35 +696,35 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } - $openedDashBoard.= '
' . "\n"; - $openedDashBoard.= '
' . "\n"; - $openedDashBoard.= ' '."\n"; - $openedDashBoard.= ' '."\n"; + $openedDashBoard .= '
'."\n"; + $openedDashBoard .= '
'."\n"; + $openedDashBoard .= ' '."\n"; + $openedDashBoard .= ' '."\n"; - if(!empty($groupElement['globalStats'])){ + if (!empty($groupElement['globalStats'])) { $globalStatInTopOpenedDashBoard[] = $globalStatsKey; - $openedDashBoard.= ' '.$nbTotal.''."\n"; + $openedDashBoard .= ' '.$nbTotal.''."\n"; } - $openedDashBoard.= ' '."\n"; - $openedDashBoard .= '
' . "\n"; + $openedDashBoard .= ' '."\n"; + $openedDashBoard .= '
'."\n"; - $openedDashBoard .= ' '.$groupName.'' . "\n"; + $openedDashBoard .= ' '.$groupName.''."\n"; foreach ($boards as $board) { if (!empty($board->labelShort)) { - $infoName = '' . $board->labelShort . ''; + $infoName = ''.$board->labelShort.''; } else { $infoName = $board->label; } $textLateTitle = $langs->trans("NActionsLate", $board->nbtodolate); - $textLateTitle .= ' (' . $langs->trans("Late") . ' = ' . $langs->trans("DateReference") . ' > ' . $langs->trans("DateToday") . ' ' . (ceil($board->warning_delay) >= 0 ? '+' : '') . ceil($board->warning_delay) . ' ' . $langs->trans("days") . ')'; + $textLateTitle .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; $textLate = ''; if ($board->nbtodolate > 0) { - $textLate .= ' '; - $textLate .= ' ' . $board->nbtodolate; + $textLate .= ' '; + $textLate .= ' '.$board->nbtodolate; $textLate .= ''; } @@ -733,16 +733,16 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $nbtodClass = 'badge badge-info'; } - $openedDashBoard .= ' ' . $infoName . ' : ' . $board->nbtodo . '' . $textLate . '' . "\n"; + $openedDashBoard .= ' '.$infoName.' : '.$board->nbtodo.''.$textLate.''."\n"; if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) { - $openedDashBoard .= '' . $langs->trans('Total') . ' : ' . price($board->total) . ''; + $openedDashBoard .= ''.$langs->trans('Total').' : '.price($board->total).''; } } - $openedDashBoard .= '
' . "\n"; - $openedDashBoard .= '
' . "\n"; - $openedDashBoard .= '
' . "\n"; + $openedDashBoard .= '
'."\n"; + $openedDashBoard .= '
'."\n"; + $openedDashBoard .= '
'."\n"; $openedDashBoard .= "\n"; } } @@ -753,41 +753,41 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $text = ''; if ($totallate > 0) { - $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate") . ' (' . $langs->transnoentitiesnoconv("NActionsLate", - $totallate . (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')) . ')'; + $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate", + $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')'; } else { $text = $langs->transnoentitiesnoconv("NoItemLate"); } - $text .= '. ' . $langs->transnoentitiesnoconv("LateDesc"); + $text .= '. '.$langs->transnoentitiesnoconv("LateDesc"); - $weatherDashBoard = '
' . "\n"; - $weatherDashBoard .= '
' . "\n"; + $weatherDashBoard = '
'."\n"; + $weatherDashBoard .= '
'."\n"; $weatherDashBoard .= ' '; $weatherDashBoard .= img_weather('', $weather->level, '', 0, 'valignmiddle width50'); - $weatherDashBoard .= ' ' . "\n"; - $weatherDashBoard .= '
' . "\n"; - $weatherDashBoard .= ' ' . $langs->trans('GlobalOpenedElemView') . '' . "\n"; + $weatherDashBoard .= ' '."\n"; + $weatherDashBoard .= '
'."\n"; + $weatherDashBoard .= ' '.$langs->trans('GlobalOpenedElemView').''."\n"; if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { - $weatherDashBoard .= ' ' . $langs->transnoentitiesnoconv("NActionsLate", - price($totallatePercentage) . '%') . '' . "\n"; - $weatherDashBoard .= ' ' . $langs->trans('NActionsLate', - $totalLateNumber) . '' . "\n"; + $weatherDashBoard .= ' '.$langs->transnoentitiesnoconv("NActionsLate", + price($totallatePercentage).'%').''."\n"; + $weatherDashBoard .= ' '.$langs->trans('NActionsLate', + $totalLateNumber).''."\n"; } else { - $weatherDashBoard .= ' ' . $langs->transnoentitiesnoconv("NActionsLate", - $totalLateNumber) . '' . "\n"; + $weatherDashBoard .= ' '.$langs->transnoentitiesnoconv("NActionsLate", + $totalLateNumber).''."\n"; if ($totallatePercentage > 0) { - $weatherDashBoard .= ' ' . $langs->trans('NActionsLate', - price($totallatePercentage) . '%') . '' . "\n"; + $weatherDashBoard .= ' '.$langs->trans('NActionsLate', + price($totallatePercentage).'%').''."\n"; } } - $weatherDashBoard .= '
' . "\n"; - $weatherDashBoard .= '
' . "\n"; - $weatherDashBoard .= '
' . "\n"; + $weatherDashBoard .= '
'."\n"; + $weatherDashBoard .= '
'."\n"; + $weatherDashBoard .= '
'."\n"; $weatherDashBoard .= "\n"; - $openedDashBoard = $weatherDashBoard . $openedDashBoard; + $openedDashBoard = $weatherDashBoard.$openedDashBoard; } if (!empty($isIntopOpenedDashBoard)) { @@ -810,24 +810,24 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $textlate = $langs->trans("NActionsLate", $board->nbtodolate); - $textlate .= ' (' . $langs->trans("Late") . ' = ' . $langs->trans("DateReference") . ' > ' . $langs->trans("DateToday") . ' ' . (ceil($board->warning_delay) >= 0 ? '+' : '') . ceil($board->warning_delay) . ' ' . $langs->trans("days") . ')'; + $textlate .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; $boxwork .= '
'; $boxwork .= '
'; - $boxwork .= '' . $board->img . ' ' . $board->label . '
'; - $boxwork .= '' . $board->nbtodo . ''; + $boxwork .= ''.$board->img.' '.$board->label.'
'; + $boxwork .= ''.$board->nbtodo.''; if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) { - $boxwork .= ' / ' . price($board->total) . ''; + $boxwork .= ' / '.price($board->total).''; } $boxwork .= '
'; if ($board->nbtodolate > 0) { $boxwork .= '
' . $langs->trans("DolibarrWorkBoard") . '
'; + $boxwork .= '
'.$langs->trans("DolibarrWorkBoard").'
'; if ($showweather) { if ($totallate > 0) { - $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate") . ' (' . $langs->transnoentitiesnoconv("NActionsLate", - $totallate . (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')) . ')'; + $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate", + $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')'; } else { $text = $langs->transnoentitiesnoconv("NoItemLate"); } - $text .= '. ' . $langs->transnoentitiesnoconv("LateDesc"); + $text .= '. '.$langs->transnoentitiesnoconv("LateDesc"); //$text.=$form->textwithpicto('',$langs->trans("LateDesc")); $options = 'height="24px" style="float: right"'; $boxwork .= showWeather($totallate, $text, $options, 'inline-block valignmiddle'); } $boxwork .= '
'; // End table array of working board + $boxwork .= ''; // End table array of working board $boxwork .= '
'; if (!empty($isIntopOpenedDashBoard)) { print '
'; - print '
' . $openedDashBoard . '
'; + print '
'.$openedDashBoard.'
'; print '
'; } } @@ -898,47 +898,47 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) } } - if(!empty($boxstatFromHook) || !empty($boxstatItems)){ - $boxstat.='
'; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; - $boxstat.=''; + $boxstat .= '
'; - $boxstat.='
'.$langs->trans("DolibarrStateBoard").'
'; - $boxstat.='
'; + if (!empty($boxstatFromHook) || !empty($boxstatItems)) { + $boxstat .= '
'; + $boxstat .= ''; + $boxstat .= ''; + $boxstat .= ''; + $boxstat .= ''; + $boxstat .= ''; - $boxstat.='
'; + $boxstat .= '
'.$langs->trans("DolibarrStateBoard").'
'; + $boxstat .= '
'; - $boxstat.=$boxstatFromHook; + $boxstat .= $boxstatFromHook; - if(is_array($boxstatItems) && count($boxstatItems) > 0) + if (is_array($boxstatItems) && count($boxstatItems) > 0) { - $boxstat.= implode('', $boxstatItems); + $boxstat .= implode('', $boxstatItems); } - $boxstat.='
'; - $boxstat.='
'; - $boxstat.='
'; - $boxstat.='
'; - $boxstat.='
'; - $boxstat.='
'; - $boxstat.='
'; - $boxstat.='
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; + $boxstat .= '
'; - $boxstat.='
'; - $boxstat.='
'; + $boxstat .= '
'; + $boxstat .= '
'; } } -$boxlist.= '
'; +$boxlist .= '
'; -$boxlist.=$boxstat; -$boxlist.=$resultboxes['boxlistb']; +$boxlist .= $boxstat; +$boxlist .= $resultboxes['boxlistb']; -$boxlist.= '
'; -$boxlist.= "\n"; +$boxlist .= '
'; +$boxlist .= "\n"; -$boxlist.='
'; +$boxlist .= '
'; print $boxlist; @@ -953,15 +953,15 @@ print '
'; // Security warning repertoire install existe (si utilisateur admin) if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) { - $message=''; + $message = ''; // Check if install lock file is present - $lockfile=DOL_DATA_ROOT.'/install.lock'; - if (! empty($lockfile) && ! file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) + $lockfile = DOL_DATA_ROOT.'/install.lock'; + if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) { $langs->load("errors"); //if (! empty($message)) $message.='
'; - $message.=info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); + $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); } // Conf files must be in read only mode @@ -970,7 +970,7 @@ if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) $langs->load("errors"); //$langs->load("other"); //if (! empty($message)) $message.='
'; - $message.=info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); + $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); } if ($message) @@ -1021,48 +1021,48 @@ function getWeatherStatus($totallate) $weather = new stdClass(); $weather->picto = ''; - $offset=0; - $factor=10; // By default + $offset = 0; + $factor = 10; // By default $used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL'; - $level0=$offset; - $weather->level=0; - if (! empty($conf->global->{$used_conf.'0'})) { - $level0=$conf->global->{$used_conf.'0'}; + $level0 = $offset; + $weather->level = 0; + if (!empty($conf->global->{$used_conf.'0'})) { + $level0 = $conf->global->{$used_conf.'0'}; } - $level1=$offset+1*$factor; - if (! empty($conf->global->{$used_conf.'1'})) { - $level1=$conf->global->{$used_conf.'1'}; + $level1 = $offset + 1 * $factor; + if (!empty($conf->global->{$used_conf.'1'})) { + $level1 = $conf->global->{$used_conf.'1'}; } - $level2=$offset+2*$factor; - if (! empty($conf->global->{$used_conf.'2'})) { - $level2=$conf->global->{$used_conf.'2'}; + $level2 = $offset + 2 * $factor; + if (!empty($conf->global->{$used_conf.'2'})) { + $level2 = $conf->global->{$used_conf.'2'}; } - $level3=$offset+3*$factor; - if (! empty($conf->global->{$used_conf.'3'})) { - $level3=$conf->global->{$used_conf.'3'}; + $level3 = $offset + 3 * $factor; + if (!empty($conf->global->{$used_conf.'3'})) { + $level3 = $conf->global->{$used_conf.'3'}; } - if ($totallate <= $level0){ + if ($totallate <= $level0) { $weather->picto = 'weather-clear.png'; - $weather->level=0; + $weather->level = 0; } - elseif ($totallate <= $level1){ + elseif ($totallate <= $level1) { $weather->picto = 'weather-few-clouds.png'; - $weather->level=1; + $weather->level = 1; } - elseif ($totallate <= $level2){ + elseif ($totallate <= $level2) { $weather->picto = 'weather-clouds.png'; - $weather->level=2; + $weather->level = 2; } - elseif ($totallate <= $level3){ + elseif ($totallate <= $level3) { $weather->picto = 'weather-many-clouds.png'; - $weather->level=3; + $weather->level = 3; } - else{ + else { $weather->picto = 'weather-storm.png'; - $weather->level=4; + $weather->level = 4; } return $weather; diff --git a/htdocs/install/mysql/tables/llx_c_holiday_types.sql b/htdocs/install/mysql/tables/llx_c_holiday_types.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_price_expression.sql b/htdocs/install/mysql/tables/llx_c_price_expression.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_severity.sql b/htdocs/install/mysql/tables/llx_c_ticket_severity.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_type.sql b/htdocs/install/mysql/tables/llx_c_ticket_type.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_expensereport.sql b/htdocs/install/mysql/tables/llx_expensereport.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_ticket.key.sql b/htdocs/install/mysql/tables/llx_ticket.key.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 0efb8dfde59..d4fd5a20caf 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -92,14 +92,14 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial * View */ -if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto || preg_match('/version/', $versionto))) +if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto))) { print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\n"; print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); - $path=__DIR__.'/'; + $path = __DIR__.'/'; if (substr($sapi_type, 0, 3) == 'cli') { print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n"; @@ -107,24 +107,24 @@ if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto | exit; } -pHeader('', 'step5', GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto); +pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto); -if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) +if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { print '

Database '.$langs->trans('DataMigration').'

'; print ''; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); - $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } @@ -137,25 +137,25 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); // Create the global $hookmanager object include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); + $hookmanager = new HookManager($db); $hookmanager->initHooks(array('upgrade')); if (!$db->connected) { print ''; - dolibarr_install_syslog('upgrade2: failed to connect to database :' . $conf->db->name . ' on ' . $conf->db->host . ' for user ' . $conf->db->user, LOG_ERR); + dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR); $error++; } - if (! $error) + if (!$error) { - if($db->database_selected) + if ($db->database_selected) { - dolibarr_install_syslog('upgrade2: database connection successful :' . $dolibarr_main_db_name); + dolibarr_install_syslog('upgrade2: database connection successful :'.$dolibarr_main_db_name); } else { @@ -163,17 +163,17 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } } - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0; + if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; + if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; // Chargement config - if (! $error) + if (!$error) { $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; } @@ -185,18 +185,18 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a ***************************************************************************************/ $db->begin(); - if (! $error) + if (!$error) { // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:(isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:'')); + $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec // dans la 1ere colonne, la description de l'action a faire // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' - $versiontoarray=explode('.', $versionto); - $versionranarray=explode('.', DOL_VERSION); + $versiontoarray = explode('.', $versionto); + $versionranarray = explode('.', DOL_VERSION); // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. @@ -224,8 +224,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a $db->query($sql, 1); - $afterversionarray=explode('.', '2.0.0'); - $beforeversionarray=explode('.', '2.7.9'); + $afterversionarray = explode('.', '2.0.0'); + $beforeversionarray = explode('.', '2.7.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Script pour V2 -> V2.1 @@ -287,12 +287,12 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 2.8 - $afterversionarray=explode('.', '2.7.9'); - $beforeversionarray=explode('.', '2.8.9'); + $afterversionarray = explode('.', '2.7.9'); + $beforeversionarray = explode('.', '2.8.9'); //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx + migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); @@ -314,8 +314,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 2.9 - $afterversionarray=explode('.', '2.8.9'); - $beforeversionarray=explode('.', '2.9.9'); + $afterversionarray = explode('.', '2.8.9'); + $beforeversionarray = explode('.', '2.9.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_project_task_time($db, $langs, $conf); @@ -328,16 +328,16 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.0 - $afterversionarray=explode('.', '2.9.9'); - $beforeversionarray=explode('.', '3.0.9'); + $afterversionarray = explode('.', '2.9.9'); + $beforeversionarray = explode('.', '3.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Script for 3.1 - $afterversionarray=explode('.', '3.0.9'); - $beforeversionarray=explode('.', '3.1.9'); + $afterversionarray = explode('.', '3.0.9'); + $beforeversionarray = explode('.', '3.1.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); @@ -346,8 +346,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.2 - $afterversionarray=explode('.', '3.1.9'); - $beforeversionarray=explode('.', '3.2.9'); + $afterversionarray = explode('.', '3.1.9'); + $beforeversionarray = explode('.', '3.2.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_price_contrat($db, $langs, $conf); @@ -358,8 +358,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.3 - $afterversionarray=explode('.', '3.2.9'); - $beforeversionarray=explode('.', '3.3.9'); + $afterversionarray = explode('.', '3.2.9'); + $beforeversionarray = explode('.', '3.3.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_categorie_association($db, $langs, $conf); @@ -369,32 +369,32 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // No specific scripts // Tasks to do always and only into last targeted version - $afterversionarray=explode('.', '3.6.9'); // target is after this - $beforeversionarray=explode('.', '3.7.9'); // target is before this + $afterversionarray = explode('.', '3.6.9'); // target is after this + $beforeversionarray = explode('.', '3.7.9'); // target is before this if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_event_assignement($db, $langs, $conf); } // Scripts for 3.9 - $afterversionarray=explode('.', '3.7.9'); - $beforeversionarray=explode('.', '3.8.9'); + $afterversionarray = explode('.', '3.7.9'); + $beforeversionarray = explode('.', '3.8.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Scripts for 4.0 - $afterversionarray=explode('.', '3.9.9'); - $beforeversionarray=explode('.', '4.0.9'); + $afterversionarray = explode('.', '3.9.9'); + $beforeversionarray = explode('.', '4.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); } // Scripts for 5.0 - $afterversionarray=explode('.', '4.0.9'); - $beforeversionarray=explode('.', '5.0.9'); + $afterversionarray = explode('.', '4.0.9'); + $beforeversionarray = explode('.', '5.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate to add entity value into llx_societe_remise @@ -405,11 +405,11 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 6.0 - $afterversionarray=explode('.', '5.0.9'); - $beforeversionarray=explode('.', '6.0.9'); + $afterversionarray = explode('.', '5.0.9'); + $beforeversionarray = explode('.', '6.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - if (! empty($conf->multicompany->enabled)) + if (!empty($conf->multicompany->enabled)) { global $multicompany_transverse_mode; @@ -426,8 +426,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 7.0 - $afterversionarray=explode('.', '6.0.9'); - $beforeversionarray=explode('.', '7.0.9'); + $afterversionarray = explode('.', '6.0.9'); + $beforeversionarray = explode('.', '7.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate contact association @@ -437,16 +437,16 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 8.0 - $afterversionarray=explode('.', '7.0.9'); - $beforeversionarray=explode('.', '8.0.9'); + $afterversionarray = explode('.', '7.0.9'); + $beforeversionarray = explode('.', '8.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); } // Scripts for 9.0 - $afterversionarray=explode('.', '8.0.9'); - $beforeversionarray=explode('.', '9.0.9'); + $afterversionarray = explode('.', '8.0.9'); + $beforeversionarray = explode('.', '9.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_user_photospath(); @@ -467,7 +467,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) { // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) - $listofmodule=array( + $listofmodule = array( 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', 'MAIN_MODULE_AGENDA'=>'newboxdefonly', 'MAIN_MODULE_BARCODE'=>'newboxdefonly', @@ -488,7 +488,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a 'MAIN_MODULE_SYSLOG'=>'newboxdefonly', 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) + 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) 'MAIN_MODULE_VARIANTS'=>'newboxdefonly', 'MAIN_MODULE_WEBSITE'=>'newboxdefonly', ); @@ -500,27 +500,27 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. - if (! $error && $enablemodules) + if (!$error && $enablemodules) { // Reload modules (this must be always done and only into last targeted version) - $listofmodules=array(); - $enablemodules=preg_replace('/enablemodules=/', '', $enablemodules); - $tmplistofmodules=explode(',', $enablemodules); - foreach($tmplistofmodules as $value) + $listofmodules = array(); + $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); + $tmplistofmodules = explode(',', $enablemodules); + foreach ($tmplistofmodules as $value) { - $listofmodules[$value]='forceactivate'; + $listofmodules[$value] = 'forceactivate'; } migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); } // Can call a dedicated external upgrade process - if (! $error) + if (!$error) { - $parameters=array('versionfrom'=>$versionfrom, 'versionto='.$versionto); - $object=new stdClass(); - $action="upgrade"; - $reshook=$hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('versionfrom'=>$versionfrom, 'versionto='.$versionto); + $object = new stdClass(); + $action = "upgrade"; + $reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($hookmanager->resNbOfHooks > 0) { if ($reshook < 0) @@ -542,7 +542,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a else { //if (! empty($conf->modules)) - if (! empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done + if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done { print ''; $insert_sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn SET '; - $insert_sql.= ' fk_paiementfourn = \''.$select_obj->rowid.'\','; - $insert_sql.= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\','; - $insert_sql.= ' amount = \''.$select_obj->amount.'\''; + $insert_sql .= ' fk_paiementfourn = \''.$select_obj->rowid.'\','; + $insert_sql .= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\','; + $insert_sql .= ' amount = \''.$select_obj->amount.'\''; $insert_resql = $db->query($insert_sql); if ($insert_resql) @@ -1454,9 +1454,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) */ function migrate_price_facture($db, $langs, $conf) { - $err=0; + $err = 0; - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); $db->begin(); @@ -1468,14 +1468,14 @@ function migrate_price_facture($db, $langs, $conf) // List of invoice lines not up to date $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as vatrate, fd.total_ttc, fd.info_bits,"; - $sql.= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f"; - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE fd.fk_facture = f.rowid"; - $sql.= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)"; + $sql .= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE fd.fk_facture = f.rowid"; + $sql .= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)"; //print $sql; dolibarr_install_syslog("upgrade2::migrate_price_facture"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1496,10 +1496,10 @@ function migrate_price_facture($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $facligne= new FactureLigne($db); + $facligne = new FactureLigne($db); $facligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $facligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $facligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1508,20 +1508,20 @@ function migrate_price_facture($db, $langs, $conf) $facligne->total_tva = $total_tva; $facligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: line " . $rowid . ": facid=" . $obj->facid . " pu=" . $pu ." qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: line ".$rowid.": facid=".$obj->facid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $facligne->update_total(); /* On touche a facture mere uniquement si total_ttc = 0 */ - if (! $total_ttc_f) + if (!$total_ttc_f) { $facture = new Facture($db); - $facture->id=$obj->facid; + $facture->id = $obj->facid; - if ( $facture->fetch($facture->id) >= 0) + if ($facture->fetch($facture->id) >= 0) { - if ( $facture->update_price() > 0 ) + if ($facture->update_price() > 0) { //print $facture->id; } @@ -1573,7 +1573,7 @@ function migrate_price_facture($db, $langs, $conf) */ function migrate_price_propal($db, $langs, $conf) { - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); $db->begin(); @@ -1585,13 +1585,13 @@ function migrate_price_propal($db, $langs, $conf) // List of proposal lines not up to date $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as vatrate, pd.info_bits,"; - $sql.= " p.rowid as propalid, p.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p"; - $sql.= " WHERE pd.fk_propal = p.rowid"; - $sql.= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)"; + $sql .= " p.rowid as propalid, p.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p"; + $sql .= " WHERE pd.fk_propal = p.rowid"; + $sql .= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_propal"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1611,10 +1611,10 @@ function migrate_price_propal($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $propalligne= new PropaleLigne($db); + $propalligne = new PropaleLigne($db); $propalligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $propalligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $propalligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1623,7 +1623,7 @@ function migrate_price_propal($db, $langs, $conf) $propalligne->total_tva = $total_tva; $propalligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": propalid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva. ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": propalid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $propalligne->update_total(); @@ -1683,9 +1683,9 @@ function migrate_price_contrat($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); - if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id=0; // Ti not have this set to '' or will make sql syntax error. + if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. print ''; print ''; @@ -3722,7 +3722,7 @@ function migrate_categorie_association($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT fk_categorie_mere, fk_categorie_fille"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."categorie_association"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."categorie_association"; $resql = $db->query($sqlSelect); if ($resql) @@ -3737,11 +3737,11 @@ function migrate_categorie_association($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."categorie SET "; - $sqlUpdate.= "fk_parent = ".$obj->fk_categorie_mere; - $sqlUpdate.= " WHERE rowid = ".$obj->fk_categorie_fille; + $sqlUpdate .= "fk_parent = ".$obj->fk_categorie_mere; + $sqlUpdate .= " WHERE rowid = ".$obj->fk_categorie_fille; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3755,7 +3755,7 @@ function migrate_categorie_association($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { // TODO DROP table in the next release /* @@ -3813,10 +3813,10 @@ function migrate_event_assignement($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT a.id, a.fk_user_action"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action"; - $sqlSelect.= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')"; - $sqlSelect.= " ORDER BY a.id"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action"; + $sqlSelect .= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')"; + $sqlSelect .= " ORDER BY a.id"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -3832,10 +3832,10 @@ function migrate_event_assignement($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; - $sqlUpdate.= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; + $sqlUpdate .= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3849,7 +3849,7 @@ function migrate_event_assignement($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3890,10 +3890,10 @@ function migrate_event_assignement_contact($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT a.id, a.fk_contact"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople' AND ar.fk_element = a.fk_contact"; - $sqlSelect.= " WHERE fk_contact > 0 AND fk_contact NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople')"; - $sqlSelect.= " ORDER BY a.id"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople' AND ar.fk_element = a.fk_contact"; + $sqlSelect .= " WHERE fk_contact > 0 AND fk_contact NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople')"; + $sqlSelect .= " ORDER BY a.id"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -3909,10 +3909,10 @@ function migrate_event_assignement_contact($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; - $sqlUpdate.= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")"; + $sqlUpdate .= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")"; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3926,7 +3926,7 @@ function migrate_event_assignement_contact($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3972,7 +3972,7 @@ function migrate_reset_blocked_log($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT DISTINCT entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."blockedlog"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."blockedlog"; //print $sqlSelect; @@ -4001,9 +4001,9 @@ function migrate_reset_blocked_log($db, $langs, $conf) print ' - Record for entity must be reset...'; $sqlUpdate = "DELETE FROM ".MAIN_DB_PREFIX."blockedlog"; - $sqlUpdate.= " WHERE entity = " . $obj->entity; - $resqlUpdate=$db->query($sqlUpdate); - if (! $resqlUpdate) + $sqlUpdate .= " WHERE entity = ".$obj->entity; + $resqlUpdate = $db->query($sqlUpdate); + if (!$resqlUpdate) { $error++; dol_print_error($db); @@ -4011,18 +4011,18 @@ function migrate_reset_blocked_log($db, $langs, $conf) else { // Add set line - $object=new stdClass(); + $object = new stdClass(); $object->id = 1; $object->element = 'module'; $object->ref = 'systemevent'; $object->entity = $obj->entity; $object->date = dol_now(); - $b=new BlockedLog($db); + $b = new BlockedLog($db); $b->setObjectData($object, 'MODULE_SET', 0); $res = $b->create($user); - if ($res<=0) { + if ($res <= 0) { $error++; } } @@ -4045,7 +4045,7 @@ function migrate_reset_blocked_log($db, $langs, $conf) print $langs->trans('NothingToDo')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4086,8 +4086,8 @@ function migrate_remise_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT sr.rowid, s.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise as sr, ".MAIN_DB_PREFIX."societe as s"; - $sqlSelect.= " WHERE sr.fk_soc = s.rowid and sr.entity != s.entity"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."societe_remise as sr, ".MAIN_DB_PREFIX."societe as s"; + $sqlSelect .= " WHERE sr.fk_soc = s.rowid and sr.entity != s.entity"; //print $sqlSelect; @@ -4104,11 +4104,11 @@ function migrate_remise_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE rowid = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4123,7 +4123,7 @@ function migrate_remise_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4163,7 +4163,7 @@ function migrate_remise_except_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT sr.rowid, sr.fk_soc, sr.fk_facture_source, sr.fk_facture, sr.fk_facture_line"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4183,21 +4183,21 @@ function migrate_remise_except_entity($db, $langs, $conf) $fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture); $sqlSelect2 = "SELECT f.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sqlSelect2.= " WHERE f.rowid = " . $fk_facture; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sqlSelect2 .= " WHERE f.rowid = ".$fk_facture; } elseif (!empty($obj->fk_facture_line)) { $sqlSelect2 = "SELECT f.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; - $sqlSelect2.= " WHERE fd.rowid = " . $obj->fk_facture_line; - $sqlSelect2.= " AND fd.fk_facture = f.rowid"; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; + $sqlSelect2 .= " WHERE fd.rowid = ".$obj->fk_facture_line; + $sqlSelect2 .= " AND fd.fk_facture = f.rowid"; } else { $sqlSelect2 = "SELECT s.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sqlSelect2.= " WHERE s.rowid = " . $obj->fk_soc; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sqlSelect2 .= " WHERE s.rowid = ".$obj->fk_soc; } $resql2 = $db->query($sqlSelect2); @@ -4208,11 +4208,11 @@ function migrate_remise_except_entity($db, $langs, $conf) $obj2 = $db->fetch_object($resql2); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except SET"; - $sqlUpdate.= " entity = " . $obj2->entity; - $sqlUpdate.= " WHERE rowid = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj2->entity; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4234,7 +4234,7 @@ function migrate_remise_except_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4274,8 +4274,8 @@ function migrate_user_rights_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT u.rowid, u.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sqlSelect.= " WHERE u.entity > 1"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sqlSelect .= " WHERE u.entity > 1"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4291,11 +4291,11 @@ function migrate_user_rights_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."user_rights SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE fk_user = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE fk_user = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4310,7 +4310,7 @@ function migrate_user_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4350,8 +4350,8 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT u.rowid, u.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."usergroup as u"; - $sqlSelect.= " WHERE u.entity > 1"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."usergroup as u"; + $sqlSelect .= " WHERE u.entity > 1"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4367,11 +4367,11 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."usergroup_rights SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE fk_usergroup = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE fk_usergroup = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4386,7 +4386,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4419,9 +4419,9 @@ function migrate_rename_directories($db, $langs, $conf, $oldname, $newname) { dolibarr_install_syslog("upgrade2::migrate_rename_directories"); - if (is_dir(DOL_DATA_ROOT.$oldname) && ! file_exists(DOL_DATA_ROOT.$newname)) + if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) { - dolibarr_install_syslog("upgrade2::migrate_rename_directories move " . DOL_DATA_ROOT . $oldname . ' into ' . DOL_DATA_ROOT . $newname); + dolibarr_install_syslog("upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname); @rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname); } } @@ -4496,9 +4496,9 @@ function migrate_delete_old_files($db, $langs, $conf) $result = 1; if (file_exists(DOL_DOCUMENT_ROOT.$filetodelete)) { $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, 0, 0, null, true, false); - if (! $result) { + if (!$result) { $langs->load("errors"); - print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT . $filetodelete); + print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT.$filetodelete); print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; } else { //print $langs->trans("FileWasRemoved", $filetodelete).'
'; @@ -4523,7 +4523,7 @@ function migrate_delete_old_dir($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_delete_old_dir"); // List of files to delete - $filetodeletearray=array( + $filetodeletearray = array( DOL_DOCUMENT_ROOT.'/core/modules/facture/terre', DOL_DOCUMENT_ROOT.'/core/modules/facture/mercure', ); @@ -4533,7 +4533,7 @@ function migrate_delete_old_dir($db, $langs, $conf) if (file_exists($filetodelete)) { $result = dol_delete_dir_recursive($filetodelete); } - if (! $result) { + if (!$result) { $langs->load("errors"); print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteDir", $filetodelete); print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; @@ -4561,18 +4561,18 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); - foreach($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' + foreach ($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' { - if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled + if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) continue; // Discard reload if module not enabled - $mod=null; + $mod = null; if ($moduletoreload == 'MAIN_MODULE_AGENDA') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; if ($res) { - $mod=new modAgenda($db); + $mod = new modAgenda($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4580,9 +4580,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_API') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; if ($res) { - $mod=new modApi($db); + $mod = new modApi($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4590,9 +4590,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_BARCODE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; if ($res) { - $mod=new modBarcode($db); + $mod = new modBarcode($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4600,9 +4600,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_CRON') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; if ($res) { - $mod=new modCron($db); + $mod = new modCron($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4610,9 +4610,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_SOCIETE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; if ($res) { - $mod=new modSociete($db); + $mod = new modSociete($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4620,9 +4620,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; if ($res) { - $mod=new modProduct($db); + $mod = new modProduct($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4630,9 +4630,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; if ($res) { - $mod=new modService($db); + $mod = new modService($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4640,9 +4640,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; if ($res) { - $mod=new modCommande($db); + $mod = new modCommande($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4650,9 +4650,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; if ($res) { - $mod=new modFacture($db); + $mod = new modFacture($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4660,9 +4660,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; if ($res) { - $mod=new modFournisseur($db); + $mod = new modFournisseur($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4670,9 +4670,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; if ($res) { - $mod=new modHoliday($db); + $mod = new modHoliday($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4680,9 +4680,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; if ($res) { - $mod=new modDeplacement($db); + $mod = new modDeplacement($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4690,9 +4690,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; if ($res) { - $mod=new modDon($db); + $mod = new modDon($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4700,47 +4700,47 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; if ($res) { - $mod=new modECM($db); - $mod->remove('noboxes'); // We need to remove because a permission id has been removed + $mod = new modECM($db); + $mod->remove('noboxes'); // We need to remove because a permission id has been removed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; if ($res) { - $mod=new modPaybox($db); - $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod = new modPaybox($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Supplier Proposal module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; if ($res) { - $mod=new modSupplierProposal($db); - $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod = new modSupplierProposal($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; if ($res) { - $mod=new modOpenSurvey($db); - $mod->remove('noboxes'); // We need to remove because menu entries has changed + $mod = new modOpenSurvey($db); + $mod->remove('noboxes'); // We need to remove because menu entries has changed $mod->init($reloadmode); } } else { $tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg); - if (! empty($reg[1])) + if (!empty($reg[1])) { if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase { @@ -4751,10 +4751,10 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $moduletoreloadshort = $reg[1]; } dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; if ($res) { $classname = 'mod'.$moduletoreloadshort; - $mod=new $classname($db); + $mod = new $classname($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4762,10 +4762,10 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo { dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'); - $res=@dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + $res = @dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); if ($res) { $classname = 'mod'.$moduletoreloadshort; - $mod=new $classname($db); + $mod = new $classname($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4782,11 +4782,11 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } } - if (! empty($mod) && is_object($mod)) + if (!empty($mod) && is_object($mod)) { print '
'; @@ -4811,11 +4811,11 @@ function migrate_reload_menu($db, $langs, $conf, $versionto) dolibarr_install_syslog("upgrade2::migrate_reload_menu"); // Define list of menu handlers to initialize - $listofmenuhandler=array(); + $listofmenuhandler = array(); if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') { - $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers + $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers } foreach ($listofmenuhandler as $key => $val) @@ -4828,10 +4828,10 @@ function migrate_reload_menu($db, $langs, $conf, $versionto) // Load sql ini_menu_handler.sql file $dir = DOL_DOCUMENT_ROOT."/core/menus/"; - $file='init_menu_'.$key.'.sql'; + $file = 'init_menu_'.$key.'.sql'; if (file_exists($dir.$file)) { - $result=run_sql($dir.$file, 1, '', 1, $key); + $result = run_sql($dir.$file, 1, '', 1, $key); } print ''; @@ -4854,9 +4854,9 @@ function migrate_user_photospath() include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $fuser = new User($db); - if (! is_object($user)) $user = $fuser; // To avoid error during migration + if (!is_object($user)) $user = $fuser; // To avoid error during migration - $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users + $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users $resql = $db->query($sql); if ($resql) { @@ -4866,25 +4866,25 @@ function migrate_user_photospath() //echo '
'.$fuser->id.' -> '.$fuser->entity; $entity = (empty($fuser->entity) ? 1 : $fuser->entity); if ($entity > 1) { - $dir = DOL_DATA_ROOT . '/' . $entity . '/users'; + $dir = DOL_DATA_ROOT.'/'.$entity.'/users'; } else { - $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module + $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module } if ($dir) { //print "Process user id ".$fuser->id."
\n"; - $origin = $dir .'/'. get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path - $destin = $dir .'/'. $fuser->id; + $origin = $dir.'/'.get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path + $destin = $dir.'/'.$fuser->id; - $origin_osencoded=dol_osencode($origin); + $origin_osencoded = dol_osencode($origin); dol_mkdir($destin); //echo '
'.$origin.' -> '.$destin; if (dol_is_dir($origin)) { - $handle=opendir($origin_osencoded); + $handle = opendir($origin_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) @@ -4899,7 +4899,7 @@ function migrate_user_photospath() dol_mkdir($destin.'/'.$file); while (($thumb = readdir($thumbs)) !== false) { - if (! dol_is_file($destin.'/'.$file.'/'.$thumb)) + if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) { if ($thumb == '.' || $thumb == '..') continue; @@ -4914,7 +4914,7 @@ function migrate_user_photospath() } else // it is a file { - if (! dol_is_file($destin.'/'.$file)) + if (!dol_is_file($destin.'/'.$file)) { //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
'."\n"; print '.'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ebc8431f5e3..e7685ef25b9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -268,6 +268,7 @@ Emails=Emails EMailsSetup=Emails setup EMailsDesc=This page allows you to override your default PHP parameters for email sending. In most cases on Unix/Linux OS, the PHP setup is correct and these parameters are unnecessary. EmailSenderProfiles=Emails sender profiles +EMailsSenderProfileDesc=You can keep this section empty. If you enter some emails here, they will be added to the list of possible senders into the combobox when your write a new email. MAIN_MAIL_SMTP_PORT=SMTP/SMTPS Port (default value in php.ini: %s) MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (default value in php.ini: %s) MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix-like systems) @@ -903,6 +904,7 @@ Permission20003=Delete leave requests Permission20004=Read all leave requests (even of user not subordinates) Permission20005=Create/modify leave requests for everybody (even of user not subordinates) Permission20006=Admin leave requests (setup and update balance) +Permission20007=Approve leave requests Permission23001=Read Scheduled job Permission23002=Create/update Scheduled job Permission23003=Delete Scheduled job diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 9e31180f3ea..69b6a698e1a 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -127,4 +127,5 @@ HolidaysNumberingModules=Leave requests numbering models TemplatePDFHolidays=Template for leave requests PDF FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests -HolidaysToApprove=Holidays to approve \ No newline at end of file +HolidaysToApprove=Holidays to approve +NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index 5cde353105f..9a95ec9d438 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -22,42 +22,42 @@ * \brief File to return datables output */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; require DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; -$mens=GETPOST('mens'); -$capital=GETPOST('capital'); -$rate=GETPOST('rate'); -$echance=GETPOST('echeance'); -$nbterm=GETPOST('nbterm'); +$mens = GETPOST('mens'); +$capital = GETPOST('capital'); +$rate = GETPOST('rate'); +$echance = GETPOST('echeance'); +$nbterm = GETPOST('nbterm'); top_httphead(); -$output=array(); +$output = array(); $object = new LoanSchedule($db); -$int = ($capital*($rate/12)); +$int = ($capital * ($rate / 12)); $int = round($int, 2, PHP_ROUND_HALF_UP); -$cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP); -$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens); +$cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); +$output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1), 'mens'=>$mens); $echance++; -$capital=$cap_rest; -while ($echance<=$nbterm) { - $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm-$echance+1), 2, PHP_ROUND_HALF_UP); +$capital = $cap_rest; +while ($echance <= $nbterm) { + $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP); - $int = ($capital*($rate/12)); + $int = ($capital * ($rate / 12)); $int = round($int, 2, PHP_ROUND_HALF_UP); - $cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); - $output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens); + $output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1), 'mens'=>$mens); - $capital=$cap_rest; + $capital = $cap_rest; $echance++; } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 923fc6e5744..804b3d1f8ab 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -137,14 +137,14 @@ $arrayfields=array(); foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), @@ -282,13 +282,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - $sql .= $db->plimit($limit + 1, $offset); + if ($limit) $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if (!$resql) @@ -481,7 +481,7 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < min($num, $limit)) +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); if (empty($obj)) break; // Should not happen diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index a8a1f8248d1..f8a3e13b80a 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -40,19 +40,19 @@ if (!$user->rights->opensurvey->write) accessforbidden(); if (isset($_SESSION["nbrecases"])) { for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_POST["choix"][$i])) { - $_SESSION["choix$i"]=$_POST["choix"][$i]; + $_SESSION["choix$i"] = $_POST["choix"][$i]; } if (isset($_POST["typecolonne"][$i])) { - $_SESSION["typecolonne$i"]=$_POST["typecolonne"][$i]; + $_SESSION["typecolonne$i"] = $_POST["typecolonne"][$i]; } } } else { //nombre de cases par défaut - $_SESSION["nbrecases"]=5; + $_SESSION["nbrecases"] = 5; } if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) { - $_SESSION["nbrecases"]=$_SESSION["nbrecases"]+5; + $_SESSION["nbrecases"] = $_SESSION["nbrecases"] + 5; } // Create survey into database @@ -62,23 +62,23 @@ if (isset($_POST["confirmecreation"])) $toutchoix = ''; for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) { - if (! empty($_POST["choix"][$i])) + if (!empty($_POST["choix"][$i])) { - $toutchoix.=','; - $toutchoix.=str_replace(array(",","@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i])?'':'@'.$_POST["typecolonne"][$i]); + $toutchoix .= ','; + $toutchoix .= str_replace(array(",", "@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i]) ? '' : '@'.$_POST["typecolonne"][$i]); } } - $toutchoix=substr("$toutchoix", 1); - $_SESSION["toutchoix"]=$toutchoix; + $toutchoix = substr("$toutchoix", 1); + $_SESSION["toutchoix"] = $toutchoix; //test de remplissage des cases $testremplissage = ''; - for ($i=0;$i<$_SESSION["nbrecases"];$i++) + for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_POST["choix"][$i])) { - $testremplissage="ok"; + $testremplissage = "ok"; } } @@ -87,7 +87,7 @@ if (isset($_POST["confirmecreation"])) setEventMessages($langs->trans("ErrorOpenSurveyOneChoice"), null, 'errors'); } else { //format du sondage AUTRE - $_SESSION["formatsondage"]="A"; + $_SESSION["formatsondage"] = "A"; // Add into database ajouter_sondage(); @@ -101,10 +101,10 @@ if (isset($_POST["confirmecreation"])) * View */ -$form=new Form($db); +$form = new Form($db); -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); if (empty($_SESSION['titre'])) @@ -123,7 +123,7 @@ print ''."\n"; print load_fiche_titre($langs->trans("CreatePoll").' (2 / 2)'); -print '
'. $langs->trans("PollOnChoice") .'

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

'."\n"; print '
'."\n"; print '
'.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).''.$langs->trans('Error').'
'; print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); @@ -560,8 +560,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // Copy directory medias - $srcroot=DOL_DOCUMENT_ROOT.'/install/medias'; - $destroot=DOL_DATA_ROOT.'/medias'; + $srcroot = DOL_DOCUMENT_ROOT.'/install/medias'; + $destroot = DOL_DATA_ROOT.'/medias'; dolCopyDir($srcroot, $destroot, 0, 0); @@ -581,12 +581,12 @@ else $error++; } -$ret=0; -if ($error && isset($argv[1])) $ret=1; +$ret = 0; +if ($error && isset($argv[1])) $ret = 1; dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("--- upgrade2: end"); -pFooter($error?2:0, $setuplang); +pFooter($error ? 2 : 0, $setuplang); if ($db->connected) $db->close(); @@ -630,7 +630,7 @@ function migrate_paiements($db, $langs, $conf) while ($i < $num) { $obj = $db->fetch_object($resql); - $row[$i][0] = $obj->rowid ; + $row[$i][0] = $obj->rowid; $row[$i][1] = $obj->fk_facture; $row[$i][2] = $obj->amount; $i++; @@ -647,11 +647,11 @@ function migrate_paiements($db, $langs, $conf) if ($db->begin()) { $res = 0; - $num=count($row); + $num = count($row); for ($i = 0; $i < $num; $i++) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; + $sql .= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; $res += $db->query($sql); @@ -710,13 +710,13 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; - $sql.= " bu2.url_id as socid"; - $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; - $sql.= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; - $sql.= " AND b.rappro = 1"; - $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; + $sql .= " bu2.url_id as socid"; + $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; + $sql .= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; + $sql .= " AND b.rappro = 1"; + $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; $resql = $db->query($sql); @@ -732,7 +732,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $obj = $db->fetch_object($resql); if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas { - $row[$j]['paymentid'] = $obj->rowid ; // paymentid + $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; $row[$j]['bamount'] = $obj->bamount; @@ -754,30 +754,30 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $db->begin(); $res = 0; - $num=count($row); + $num = count($row); for ($i = 0; $i < $num; $i++) { if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; // On cherche facture sans lien paiement et du meme montant et pour meme societe. - $sql=" SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.=" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; - $sql.=" AND pf.fk_facture IS NULL"; - $sql.=" ORDER BY f.fk_statut"; + $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; + $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " ORDER BY f.fk_statut"; //print $sql.'
'; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
'; if ($num >= 1) { - $obj=$db->fetch_object($resql); - $facid=$obj->rowid; + $obj = $db->fetch_object($resql); + $facid = $obj->rowid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; + $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; $res += $db->query($sql); @@ -837,12 +837,12 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; - $sql.= " bu2.url_id as socid"; - $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; - $sql.= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; - $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; + $sql .= " bu2.url_id as socid"; + $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; + $sql .= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; + $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; $resql = $db->query($sql); @@ -858,7 +858,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $obj = $db->fetch_object($resql); if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas { - $row[$j]['paymentid'] = $obj->rowid ; // paymentid + $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; $row[$j]['bamount'] = $obj->bamount; @@ -874,9 +874,9 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) dol_print_error($db); } - $nberr=0; + $nberr = 0; - $num=count($row); + $num = count($row); if ($num) { print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)."
\n"; @@ -888,24 +888,24 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; // On cherche facture sans lien paiement et du meme montant et pour meme societe. - $sql=" SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; - $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - $sql.=" WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; - $sql.=" AND pf.fk_facture IS NULL"; - $sql.=" ORDER BY f.fk_statut"; + $sql = " SELECT distinct f.rowid from ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + $sql .= " WHERE f.fk_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; + $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " ORDER BY f.fk_statut"; //print $sql.'
'; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
'; if ($num >= 1) { - $obj=$db->fetch_object($resql); - $facid=$obj->rowid; + $obj = $db->fetch_object($resql); + $facid = $obj->rowid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; + $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; $res += $db->query($sql); print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])."
\n"; @@ -971,19 +971,19 @@ function migrate_contracts_det($db, $langs, $conf) { print '
'; - $nberr=0; + $nberr = 0; print '
'; print ''.$langs->trans('MigrationContractsUpdate')."
\n"; $sql = "SELECT c.rowid as cref, c.date_contrat, c.statut, c.mise_en_service, c.fin_validite, c.date_cloture, c.fk_product, c.fk_facture, c.fk_user_author,"; - $sql.= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p"; - $sql.= " ON c.fk_product = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " ON c.rowid=cd.fk_contrat"; - $sql.= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL"; + $sql .= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p"; + $sql .= " ON c.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " ON c.rowid=cd.fk_contrat"; + $sql .= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_det"); @@ -1003,20 +1003,20 @@ function migrate_contracts_det($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet ("; - $sql.= "fk_contrat, fk_product, statut, label, description,"; - $sql.= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,"; - $sql.= "subprice, price_ht, fk_user_author, fk_user_ouverture)"; - $sql.= " VALUES ("; - $sql.= $obj->cref.",".($obj->fk_product?$obj->fk_product:0).","; - $sql.= ($obj->mise_en_service?"4":"0").","; - $sql.= "'".$db->escape($obj->label)."', null,"; - $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":($obj->date_contrat?"'".$obj->date_contrat."'":"null")).","; - $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":"null").","; - $sql.= ($obj->fin_validite?"'".$obj->fin_validite."'":"null").","; - $sql.= "'".$obj->tva_tx."', 1,"; - $sql.= "'".$obj->price."', '".$obj->price."',".$obj->fk_user_author.","; - $sql.= ($obj->mise_en_service?$obj->fk_user_author:"null"); - $sql.= ")"; + $sql .= "fk_contrat, fk_product, statut, label, description,"; + $sql .= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,"; + $sql .= "subprice, price_ht, fk_user_author, fk_user_ouverture)"; + $sql .= " VALUES ("; + $sql .= $obj->cref.",".($obj->fk_product ? $obj->fk_product : 0).","; + $sql .= ($obj->mise_en_service ? "4" : "0").","; + $sql .= "'".$db->escape($obj->label)."', null,"; + $sql .= ($obj->mise_en_service ? "'".$obj->mise_en_service."'" : ($obj->date_contrat ? "'".$obj->date_contrat."'" : "null")).","; + $sql .= ($obj->mise_en_service ? "'".$obj->mise_en_service."'" : "null").","; + $sql .= ($obj->fin_validite ? "'".$obj->fin_validite."'" : "null").","; + $sql .= "'".$obj->tva_tx."', 1,"; + $sql .= "'".$obj->price."', '".$obj->price."',".$obj->fk_user_author.","; + $sql .= ($obj->mise_en_service ? $obj->fk_user_author : "null"); + $sql .= ")"; if ($db->query($sql)) { @@ -1031,7 +1031,7 @@ function migrate_contracts_det($db, $langs, $conf) $i++; } - if (! $nberr) + if (!$nberr) { // $db->rollback(); $db->commit(); @@ -1069,17 +1069,17 @@ function migrate_links_transfert($db, $langs, $conf) { print '
'; - $nberr=0; + $nberr = 0; print '
'; print ''.$langs->trans('MigrationBankTransfertsUpdate')."
\n"; $sql = "SELECT ba.rowid as barowid, bb.rowid as bbrowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid"; - $sql.= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account"; - $sql.= " AND ba.datev = bb.datev AND ba.datec = bb.datec"; - $sql.= " AND bu.fk_bank IS NULL"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid"; + $sql .= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account"; + $sql .= " AND ba.datev = bb.datev AND ba.datec = bb.datec"; + $sql .= " AND bu.fk_bank IS NULL"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_links_transfert"); @@ -1099,16 +1099,16 @@ function migrate_links_transfert($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; - $sql.= "fk_bank, url_id, url, label, type"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; - $sql.= ")"; + $sql .= "fk_bank, url_id, url, label, type"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; + $sql .= ")"; print $sql.'
'; dolibarr_install_syslog("migrate_links_transfert"); - if (! $db->query($sql)) + if (!$db->query($sql)) { dol_print_error($db); $nberr++; @@ -1117,7 +1117,7 @@ function migrate_links_transfert($db, $langs, $conf) $i++; } - if (! $nberr) + if (!$nberr) { // $db->rollback(); $db->commit(); @@ -1156,19 +1156,19 @@ function migrate_contracts_date1($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')."
\n"; - $sql="update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; + $sql = "update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
\n"; else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; - $sql="update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; + $sql = "update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
\n"; else @@ -1184,16 +1184,16 @@ function migrate_contracts_date2($db, $langs, $conf) { print '
'; - $nberr=0; + $nberr = 0; print '
'; print ''.$langs->trans('MigrationContractsInvalidDatesUpdate')."
\n"; $sql = "SELECT c.rowid as cref, c.datec, c.date_contrat, MIN(cd.date_ouverture) as datemin"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c,"; - $sql.= " ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL"; - $sql.= " GROUP BY c.rowid, c.date_contrat"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,"; + $sql .= " ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL"; + $sql .= " GROUP BY c.rowid, c.date_contrat"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_date2"); @@ -1205,7 +1205,7 @@ function migrate_contracts_date2($db, $langs, $conf) if ($num) { - $nbcontratsmodifie=0; + $nbcontratsmodifie = 0; $db->begin(); while ($i < $num) @@ -1214,11 +1214,11 @@ function migrate_contracts_date2($db, $langs, $conf) if ($obj->date_contrat > $obj->datemin) { print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)."
\n"; - $sql ="UPDATE ".MAIN_DB_PREFIX."contrat"; - $sql.=" SET date_contrat='".$obj->datemin."'"; - $sql.=" WHERE rowid=".$obj->cref; - $resql2=$db->query($sql); - if (! $resql2) dol_print_error($db); + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; + $sql .= " SET date_contrat='".$obj->datemin."'"; + $sql .= " WHERE rowid=".$obj->cref; + $resql2 = $db->query($sql); + if (!$resql2) dol_print_error($db); $nbcontratsmodifie++; } @@ -1256,10 +1256,10 @@ function migrate_contracts_date3($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')."
\n"; - $sql="update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; + $sql = "update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
\n"; else @@ -1284,10 +1284,10 @@ function migrate_contracts_open($db, $langs, $conf) print ''.$langs->trans('MigrationReopeningContracts')."
\n"; $sql = "SELECT c.rowid as cref FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; + $sql .= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_open"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) { $i = 0; $row = array(); @@ -1295,7 +1295,7 @@ function migrate_contracts_open($db, $langs, $conf) if ($num) { - $nbcontratsmodifie=0; + $nbcontratsmodifie = 0; $db->begin(); while ($i < $num) @@ -1303,11 +1303,11 @@ function migrate_contracts_open($db, $langs, $conf) $obj = $db->fetch_object($resql); print $langs->trans('MigrationReopenThisContract', $obj->cref)."
\n"; - $sql ="UPDATE ".MAIN_DB_PREFIX."contrat"; - $sql.=" SET statut=1"; - $sql.=" WHERE rowid=".$obj->cref; - $resql2=$db->query($sql); - if (! $resql2) dol_print_error($db); + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; + $sql .= " SET statut=1"; + $sql .= " WHERE rowid=".$obj->cref; + $resql2 = $db->query($sql); + if (!$resql2) dol_print_error($db); $nbcontratsmodifie++; @@ -1348,31 +1348,31 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $obj = $db->fetch_object($result); if ($obj) { - $error=0; - $nb=0; + $error = 0; + $nb = 0; $select_sql = 'SELECT rowid, fk_facture_fourn, amount'; - $select_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn'; - $select_sql.= ' WHERE fk_facture_fourn IS NOT NULL'; + $select_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn'; + $select_sql .= ' WHERE fk_facture_fourn IS NOT NULL'; dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn"); $select_resql = $db->query($select_sql); if ($select_resql) { $select_num = $db->num_rows($select_resql); - $i=0; + $i = 0; $var = true; // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn - while (($i < $select_num) && (! $error)) + while (($i < $select_num) && (!$error)) { $var = !$var; $select_obj = $db->fetch_object($select_resql); // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; - $check_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; - $check_sql.= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; + $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; + $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; $check_resql = $db->query($check_sql); if ($check_resql) { @@ -1391,9 +1391,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) print '
'.$select_obj->rowid.''.$select_obj->fk_facture_fourn.''.$select_obj->amount.'
'; @@ -1694,13 +1694,13 @@ function migrate_price_contrat($db, $langs, $conf) // List of contract lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as contratid"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE cd.fk_contrat = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as contratid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE cd.fk_contrat = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_contrat"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1719,11 +1719,11 @@ function migrate_price_contrat($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $contratligne= new ContratLigne($db); + $contratligne = new ContratLigne($db); //$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis $contratligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0, 'HT', $info_bits, $contratligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0, 'HT', $info_bits, $contratligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1732,7 +1732,7 @@ function migrate_price_contrat($db, $langs, $conf) $contratligne->total_tva = $total_tva; $contratligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": contratdetid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent. " -> " . $total_ht . ", " . $total_tva. " , " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": contratdetid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." -> ".$total_ht.", ".$total_tva." , ".$total_ttc); print ". "; $contratligne->update_total(); @@ -1772,7 +1772,7 @@ function migrate_price_commande($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); print '
'; @@ -1782,13 +1782,13 @@ function migrate_price_commande($db, $langs, $conf) // List of sales orders lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE cd.fk_commande = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE cd.fk_commande = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_commande"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1808,10 +1808,10 @@ function migrate_price_commande($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $commandeligne= new OrderLine($db); + $commandeligne = new OrderLine($db); $commandeligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1820,7 +1820,7 @@ function migrate_price_commande($db, $langs, $conf) $commandeligne->total_tva = $total_tva; $commandeligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . " : commandeid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global. " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid." : commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $commandeligne->update_total(); @@ -1889,7 +1889,7 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); print '
'; @@ -1899,13 +1899,13 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) // List of purchase order lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sql.= " WHERE cd.fk_commande = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql .= " WHERE cd.fk_commande = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1925,10 +1925,10 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $commandeligne= new CommandeFournisseurLigne($db); + $commandeligne = new CommandeFournisseurLigne($db); $commandeligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1937,7 +1937,7 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $commandeligne->total_tva = $total_tva; $commandeligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": commandeid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $commandeligne->update_total(); @@ -2009,42 +2009,42 @@ function migrate_modeles($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_modeles"); - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $modellist=ModelePDFFactures::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFFactures::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; - $modellist=ModelePDFCommandes::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFCommandes::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } - if (! empty($conf->expedition->enabled)) + if (!empty($conf->expedition->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; - $modellist=ModelePDFExpedition::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFExpedition::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } @@ -2091,8 +2091,8 @@ function migrate_commande_expedition($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)"; - $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; - $resql2=$db->query($sql); + $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2 = $db->query($sql); if (!$resql2) { @@ -2155,9 +2155,9 @@ function migrate_commande_livraison($db, $langs, $conf) $db->begin(); $sql = "SELECT l.rowid, l.fk_commande"; - $sql.= ", c.ref_client, c.date_livraison"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE c.rowid = l.fk_commande"; + $sql .= ", c.ref_client, c.date_livraison"; + $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE c.rowid = l.fk_commande"; $resql = $db->query($sql); if ($resql) { @@ -2171,16 +2171,16 @@ function migrate_commande_livraison($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)"; - $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; - $resql2=$db->query($sql); + $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2 = $db->query($sql); if ($resql2) { $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlu.= " ref_client='".$obj->ref_client."'"; - $sqlu.= ", date_livraison='".$obj->date_livraison."'"; - $sqlu.= " WHERE rowid = ".$obj->rowid; - $resql3=$db->query($sqlu); + $sqlu .= " ref_client='".$obj->ref_client."'"; + $sqlu .= ", date_livraison='".$obj->date_livraison."'"; + $sqlu .= " WHERE rowid = ".$obj->rowid; + $resql3 = $db->query($sqlu); if (!$resql3) { $error++; @@ -2250,9 +2250,9 @@ function migrate_detail_livraison($db, $langs, $conf) $db->begin(); $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht"; - $sql.= ", ld.fk_livraison"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; - $sql.= " WHERE ld.fk_commande_ligne = cd.rowid"; + $sql .= ", ld.fk_livraison"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; + $sql .= " WHERE ld.fk_commande_ligne = cd.rowid"; $resql = $db->query($sql); if ($resql) { @@ -2266,19 +2266,19 @@ function migrate_detail_livraison($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET"; - $sql.= " fk_product=".$obj->fk_product; - $sql.= ",description='".$db->escape($obj->description)."'"; - $sql.= ",subprice='".$obj->subprice."'"; - $sql.= ",total_ht='".$obj->total_ht."'"; - $sql.= " WHERE fk_commande_ligne = ".$obj->rowid; - $resql2=$db->query($sql); + $sql .= " fk_product=".$obj->fk_product; + $sql .= ",description='".$db->escape($obj->description)."'"; + $sql .= ",subprice='".$obj->subprice."'"; + $sql .= ",total_ht='".$obj->total_ht."'"; + $sql .= " WHERE fk_commande_ligne = ".$obj->rowid; + $resql2 = $db->query($sql); if ($resql2) { $sql = "SELECT total_ht"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE rowid = ".$obj->fk_livraison; - $resql3=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sql .= " WHERE rowid = ".$obj->fk_livraison; + $resql3 = $db->query($sql); if ($resql3) { @@ -2286,9 +2286,9 @@ function migrate_detail_livraison($db, $langs, $conf) $total_ht = $obju->total_ht + $obj->total_ht; $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlu.= " total_ht='".$total_ht."'"; - $sqlu.= " WHERE rowid=".$obj->fk_livraison; - $resql4=$db->query($sqlu); + $sqlu .= " total_ht='".$total_ht."'"; + $sqlu .= " WHERE rowid=".$obj->fk_livraison; + $resql4 = $db->query($sqlu); if (!$resql4) { $error++; @@ -2365,8 +2365,8 @@ function migrate_stocks($db, $langs, $conf) $db->begin(); $sql = "SELECT SUM(reel) as total, fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= " GROUP BY fk_product"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " GROUP BY fk_product"; $resql = $db->query($sql); if ($resql) { @@ -2380,10 +2380,10 @@ function migrate_stocks($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; - $sql.= " stock = '".$obj->total."'"; - $sql.= " WHERE rowid=".$obj->fk_product; + $sql .= " stock = '".$obj->total."'"; + $sql .= " WHERE rowid=".$obj->fk_product; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if ($resql2) { } @@ -2440,9 +2440,9 @@ function migrate_menus($db, $langs, $conf) $db->begin(); $sql = "SELECT m.rowid, mc.action"; - $sql.= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; - $sql.= " AND m.enabled = '1'"; + $sql .= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; + $sql .= " AND m.enabled = '1'"; $resql = $db->query($sql); if ($resql) { @@ -2455,11 +2455,11 @@ function migrate_menus($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; - $sql.= " enabled = '".$obj->action."'"; - $sql.= " WHERE rowid=".$obj->rowid; - $sql.= " AND enabled = '1'"; + $sql .= " enabled = '".$obj->action."'"; + $sql .= " WHERE rowid=".$obj->rowid; + $sql .= " AND enabled = '1'"; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if ($resql2) { } @@ -2521,10 +2521,10 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $db->begin(); $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."co_exp as ce"; - $sql.= " WHERE c.rowid = ce.fk_commande"; - $sql.= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."co_exp as ce"; + $sql .= " WHERE c.rowid = ce.fk_commande"; + $sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; $resql = $db->query($sql); if ($resql) @@ -2539,10 +2539,10 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql.= " fk_adresse_livraison = '".$obj->fk_adresse_livraison."'"; - $sql.= " WHERE rowid=".$obj->fk_expedition; + $sql .= " fk_adresse_livraison = '".$obj->fk_adresse_livraison."'"; + $sql .= " WHERE rowid=".$obj->fk_expedition; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if (!$resql2) { $error++; @@ -2595,7 +2595,7 @@ function migrate_restore_missing_links($db, $langs, $conf) if (($db->type == 'mysql' || $db->type == 'mysqli')) { - if (versioncompare($db->getVersionArray(), array(4,0)) < 0) + if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action"); return 0; @@ -2610,16 +2610,16 @@ function migrate_restore_missing_links($db, $langs, $conf) // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 1. - $table1='facturedet'; $field1='fk_remise_except'; - $table2='societe_remise_except'; $field2='fk_facture_line'; + $table1 = 'facturedet'; $field1 = 'fk_remise_except'; + $table2 = 'societe_remise_except'; $field2 = 'fk_facture_line'; $db->begin(); $sql = "SELECT t1.rowid, t1.".$field1." as field"; - $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; - $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; - $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; - $sql.= " WHERE t1.rowid = t2.".$field2.")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; + $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; + $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; + $sql .= " WHERE t1.rowid = t2.".$field2.")"; dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1"); $resql = $db->query($sql); @@ -2636,11 +2636,11 @@ function migrate_restore_missing_links($db, $langs, $conf) print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; - $sql.= " ".$field2." = '".$obj->rowid."'"; - $sql.= " WHERE rowid=".$obj->field; + $sql .= " ".$field2." = '".$obj->rowid."'"; + $sql .= " WHERE rowid=".$obj->field; - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { $error++; dol_print_error($db); @@ -2675,16 +2675,16 @@ function migrate_restore_missing_links($db, $langs, $conf) print ''.$langs->trans('MigrationFixData')." (2)
\n"; // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 2. - $table2='facturedet'; $field2='fk_remise_except'; - $table1='societe_remise_except'; $field1='fk_facture_line'; + $table2 = 'facturedet'; $field2 = 'fk_remise_except'; + $table1 = 'societe_remise_except'; $field1 = 'fk_facture_line'; $db->begin(); $sql = "SELECT t1.rowid, t1.".$field1." as field"; - $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; - $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; - $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; - $sql.= " WHERE t1.rowid = t2.".$field2.")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; + $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; + $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; + $sql .= " WHERE t1.rowid = t2.".$field2.")"; dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2"); $resql = $db->query($sql); @@ -2701,11 +2701,11 @@ function migrate_restore_missing_links($db, $langs, $conf) print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; - $sql.= " ".$field2." = '".$obj->rowid."'"; - $sql.= " WHERE rowid=".$obj->field; + $sql .= " ".$field2." = '".$obj->rowid."'"; + $sql .= " WHERE rowid=".$obj->field; - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { $error++; dol_print_error($db); @@ -2776,22 +2776,22 @@ function migrate_project_user_resp($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; - $sql2.= "datecreate"; - $sql2.= ", statut"; - $sql2.= ", element_id"; - $sql2.= ", fk_c_type_contact"; - $sql2.= ", fk_socpeople"; - $sql2.= ") VALUES ("; - $sql2.= "'".$db->idate(dol_now())."'"; - $sql2.= ", '4'"; - $sql2.= ", ".$obj->rowid; - $sql2.= ", '160'"; - $sql2.= ", ".$obj->fk_user_resp; - $sql2.= ")"; + $sql2 .= "datecreate"; + $sql2 .= ", statut"; + $sql2 .= ", element_id"; + $sql2 .= ", fk_c_type_contact"; + $sql2 .= ", fk_socpeople"; + $sql2 .= ") VALUES ("; + $sql2 .= "'".$db->idate(dol_now())."'"; + $sql2 .= ", '4'"; + $sql2 .= ", ".$obj->rowid; + $sql2 .= ", '160'"; + $sql2 .= ", ".$obj->fk_user_resp; + $sql2 .= ")"; if ($obj->fk_user_resp > 0) { - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { $error++; @@ -2871,20 +2871,20 @@ function migrate_project_task_actors($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; - $sql2.= "datecreate"; - $sql2.= ", statut"; - $sql2.= ", element_id"; - $sql2.= ", fk_c_type_contact"; - $sql2.= ", fk_socpeople"; - $sql2.= ") VALUES ("; - $sql2.= "'".$db->idate(dol_now())."'"; - $sql2.= ", '4'"; - $sql2.= ", ".$obj->fk_project_task; - $sql2.= ", '180'"; - $sql2.= ", ".$obj->fk_user; - $sql2.= ")"; + $sql2 .= "datecreate"; + $sql2 .= ", statut"; + $sql2 .= ", element_id"; + $sql2 .= ", fk_c_type_contact"; + $sql2 .= ", fk_socpeople"; + $sql2 .= ") VALUES ("; + $sql2 .= "'".$db->idate(dol_now())."'"; + $sql2 .= ", '4'"; + $sql2 .= ", ".$obj->fk_project_task; + $sql2 .= ", '180'"; + $sql2 .= ", ".$obj->fk_user; + $sql2 .= ")"; - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { @@ -2950,12 +2950,12 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) { - dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = " . MAIN_DB_PREFIX . $table); + dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); $db->begin(); $sqlSelect = "SELECT ".$fk_source.", ".$fk_target; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX.$table; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table; $resql = $db->query($sqlSelect); if ($resql) @@ -2970,19 +2970,19 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sqlInsert.= "fk_source"; - $sqlInsert.= ", sourcetype"; - $sqlInsert.= ", fk_target"; - $sqlInsert.= ", targettype"; - $sqlInsert.= ") VALUES ("; - $sqlInsert.= $obj->$fk_source; - $sqlInsert.= ", '".$sourcetype."'"; - $sqlInsert.= ", ".$obj->$fk_target; - $sqlInsert.= ", '".$targettype."'"; - $sqlInsert.= ")"; + $sqlInsert .= "fk_source"; + $sqlInsert .= ", sourcetype"; + $sqlInsert .= ", fk_target"; + $sqlInsert .= ", targettype"; + $sqlInsert .= ") VALUES ("; + $sqlInsert .= $obj->$fk_source; + $sqlInsert .= ", '".$sourcetype."'"; + $sqlInsert .= ", ".$obj->$fk_target; + $sqlInsert .= ", '".$targettype."'"; + $sqlInsert .= ")"; - $result=$db->query($sqlInsert); - if (! $result) + $result = $db->query($sqlInsert); + if (!$result) { $error++; dol_print_error($db); @@ -3049,7 +3049,7 @@ function migrate_project_task_time($db, $langs, $conf) $db->begin(); $sql = "SELECT rowid, fk_task, task_duration"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; $resql = $db->query($sql); if ($resql) { @@ -3069,16 +3069,16 @@ function migrate_project_task_time($db, $langs, $conf) { // convert to second // only for int time and float time ex: 1,75 for 1h45 - list($hour,$min) = explode('.', $obj->task_duration); - $hour = $hour*60*60; - $min = ($min/100)*60*60; - $newtime = $hour+$min; + list($hour, $min) = explode('.', $obj->task_duration); + $hour = $hour * 60 * 60; + $min = ($min / 100) * 60 * 60; + $newtime = $hour + $min; $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; - $sql2.= " task_duration = ".$newtime; - $sql2.= " WHERE rowid = ".$obj->rowid; + $sql2 .= " task_duration = ".$newtime; + $sql2 .= " WHERE rowid = ".$obj->rowid; - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { $error++; @@ -3086,12 +3086,12 @@ function migrate_project_task_time($db, $langs, $conf) } print ". "; $oldtime++; - if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; + if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; else $totaltime[$obj->fk_task] = $newtime; } else { - if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; + if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; else $totaltime[$obj->fk_task] = $obj->task_duration; } @@ -3102,13 +3102,13 @@ function migrate_project_task_time($db, $langs, $conf) { if ($oldtime > 0) { - foreach($totaltime as $taskid => $total_duration) + foreach ($totaltime as $taskid => $total_duration) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; - $sql.= " duration_effective = ".$total_duration; - $sql.= " WHERE rowid = ".$taskid; + $sql .= " duration_effective = ".$total_duration; + $sql .= " WHERE rowid = ".$taskid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) { $error++; @@ -3181,11 +3181,11 @@ function migrate_customerorder_shipping($db, $langs, $conf) if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) { $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sqlSelect.= ", ".MAIN_DB_PREFIX."element_element as el"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'"; - $sqlSelect.= " WHERE e.rowid = el.fk_target"; - $sqlSelect.= " AND el.targettype = 'shipping'"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'"; + $sqlSelect .= " WHERE e.rowid = el.fk_target"; + $sqlSelect .= " AND el.targettype = 'shipping'"; $resql = $db->query($sqlSelect); if ($resql) @@ -3200,12 +3200,12 @@ function migrate_customerorder_shipping($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sqlUpdate.= " ref_customer = '".$obj->ref_client."'"; - $sqlUpdate.= ", date_delivery = '".($obj->date_livraison?$obj->date_livraison:'null')."'"; - $sqlUpdate.= " WHERE rowid = ".$obj->shipping_id; + $sqlUpdate .= " ref_customer = '".$obj->ref_client."'"; + $sqlUpdate .= ", date_delivery = '".($obj->date_livraison ? $obj->date_livraison : 'null')."'"; + $sqlUpdate .= " WHERE rowid = ".$obj->shipping_id; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3275,8 +3275,8 @@ function migrate_shipping_delivery($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT rowid, fk_expedition"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sqlSelect.= " WHERE fk_expedition is not null"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sqlSelect .= " WHERE fk_expedition is not null"; $resql = $db->query($sqlSelect); if ($resql) @@ -3291,25 +3291,25 @@ function migrate_shipping_delivery($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sqlInsert.= "fk_source"; - $sqlInsert.= ", sourcetype"; - $sqlInsert.= ", fk_target"; - $sqlInsert.= ", targettype"; - $sqlInsert.= ") VALUES ("; - $sqlInsert.= $obj->fk_expedition; - $sqlInsert.= ", 'shipping'"; - $sqlInsert.= ", ".$obj->rowid; - $sqlInsert.= ", 'delivery'"; - $sqlInsert.= ")"; + $sqlInsert .= "fk_source"; + $sqlInsert .= ", sourcetype"; + $sqlInsert .= ", fk_target"; + $sqlInsert .= ", targettype"; + $sqlInsert .= ") VALUES ("; + $sqlInsert .= $obj->fk_expedition; + $sqlInsert .= ", 'shipping'"; + $sqlInsert .= ", ".$obj->rowid; + $sqlInsert .= ", 'delivery'"; + $sqlInsert .= ")"; - $result=$db->query($sqlInsert); + $result = $db->query($sqlInsert); if ($result) { $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL"; - $sqlUpdate.= " WHERE rowid = ".$obj->rowid; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3383,16 +3383,16 @@ function migrate_shipping_delivery2($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison as l,"; - $sqlSelect.= " ".MAIN_DB_PREFIX."element_element as el,"; - $sqlSelect.= " ".MAIN_DB_PREFIX."expedition as e"; - $sqlSelect.= " WHERE l.rowid = el.fk_target"; - $sqlSelect.= " AND el.targettype = 'delivery'"; - $sqlSelect.= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; - $sqlSelect.= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison as l,"; + $sqlSelect .= " ".MAIN_DB_PREFIX."element_element as el,"; + $sqlSelect .= " ".MAIN_DB_PREFIX."expedition as e"; + $sqlSelect .= " WHERE l.rowid = el.fk_target"; + $sqlSelect .= " AND el.targettype = 'delivery'"; + $sqlSelect .= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; + $sqlSelect .= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null // Add condition to know if we never migrate this record - $sqlSelect.= " AND (l.ref_customer IS NULL".($db->type!='pgsql'?" or l.ref_customer = ''":"").")"; - $sqlSelect.= " AND (l.date_delivery IS NULL".($db->type!='pgsql'?" or l.date_delivery = ''":"").")"; + $sqlSelect .= " AND (l.ref_customer IS NULL".($db->type != 'pgsql' ? " or l.ref_customer = ''" : "").")"; + $sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")"; $resql = $db->query($sqlSelect); if ($resql) @@ -3407,12 +3407,12 @@ function migrate_shipping_delivery2($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlUpdate.= " ref_customer = '".$obj->ref_customer."',"; - $sqlUpdate.= " date_delivery = ".($obj->date_delivery?"'".$obj->date_delivery."'":'null'); - $sqlUpdate.= " WHERE rowid = ".$obj->delivery_id; + $sqlUpdate .= " ref_customer = '".$obj->ref_customer."',"; + $sqlUpdate .= " date_delivery = ".($obj->date_delivery ? "'".$obj->date_delivery."'" : 'null'); + $sqlUpdate .= " WHERE rowid = ".$obj->delivery_id; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3469,21 +3469,21 @@ function migrate_actioncomm_element($db, $langs, $conf) 'invoice_supplier' => 'fk_supplier_invoice' ); - foreach($elements as $type => $field) + foreach ($elements as $type => $field) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm", $field); $obj = $db->fetch_object($result); if ($obj) { - dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=" . $field); + dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field); $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET "; - $sql.= "fk_element = ".$field.", elementtype = '".$type."'"; - $sql.= " WHERE ".$field." IS NOT NULL"; - $sql.= " AND fk_element IS NULL"; - $sql.= " AND elementtype IS NULL"; + $sql .= "fk_element = ".$field.", elementtype = '".$type."'"; + $sql .= " WHERE ".$field." IS NOT NULL"; + $sql .= " AND fk_element IS NULL"; + $sql .= " AND elementtype IS NULL"; $resql = $db->query($sql); if ($resql) @@ -3527,23 +3527,23 @@ function migrate_mode_reglement($db, $langs, $conf) print ''.$langs->trans('MigrationPaymentMode')."
\n"; $elements = array( - 'old_id' => array(5,8,9,10,11), - 'new_id' => array(50,51,52,53,54), - 'code' => array('VAD','TRA','LCR','FAC','PRO'), - 'tables' => array('commande_fournisseur','commande','facture_rec','facture','propal') + 'old_id' => array(5, 8, 9, 10, 11), + 'new_id' => array(50, 51, 52, 53, 54), + 'code' => array('VAD', 'TRA', 'LCR', 'FAC', 'PRO'), + 'tables' => array('commande_fournisseur', 'commande', 'facture_rec', 'facture', 'propal') ); - $count=0; + $count = 0; - foreach($elements['old_id'] as $key => $old_id) + foreach ($elements['old_id'] as $key => $old_id) { - $error=0; + $error = 0; - dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=" . $elements['code'][$key]); + dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]); $sqlSelect = "SELECT id"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."c_paiement"; - $sqlSelect.= " WHERE id = ".$old_id; - $sqlSelect.= " AND code = '".$elements['code'][$key]."'"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."c_paiement"; + $sqlSelect .= " WHERE id = ".$old_id; + $sqlSelect .= " AND code = '".$elements['code'][$key]."'"; $resql = $db->query($sqlSelect); if ($resql) @@ -3556,27 +3556,27 @@ function migrate_mode_reglement($db, $langs, $conf) $db->begin(); $sqla = "UPDATE ".MAIN_DB_PREFIX."paiement SET "; - $sqla.= "fk_paiement = ".$elements['new_id'][$key]; - $sqla.= " WHERE fk_paiement = ".$old_id; - $sqla.= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".$old_id." AND code = '".$elements['code'][$key]."')"; + $sqla .= "fk_paiement = ".$elements['new_id'][$key]; + $sqla .= " WHERE fk_paiement = ".$old_id; + $sqla .= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".$old_id." AND code = '".$elements['code'][$key]."')"; $resqla = $db->query($sqla); $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET "; - $sql.= "id = ".$elements['new_id'][$key]; - $sql.= " WHERE id = ".$old_id; - $sql.= " AND code = '".$elements['code'][$key]."'"; + $sql .= "id = ".$elements['new_id'][$key]; + $sql .= " WHERE id = ".$old_id; + $sql .= " AND code = '".$elements['code'][$key]."'"; $resql = $db->query($sql); if ($resqla && $resql) { - foreach($elements['tables'] as $table) + foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; - $sql.= "fk_mode_reglement = ".$elements['new_id'][$key]; - $sql.= " WHERE fk_mode_reglement = ".$old_id; + $sql .= "fk_mode_reglement = ".$elements['new_id'][$key]; + $sql .= " WHERE fk_mode_reglement = ".$old_id; $resql = $db->query($sql); - if (! $resql) + if (!$resql) { dol_print_error($db); $error++; @@ -3584,7 +3584,7 @@ function migrate_mode_reglement($db, $langs, $conf) print ". "; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3627,54 +3627,54 @@ function migrate_clean_association($db, $langs, $conf, $versionto) $obj = $db->fetch_object($result); if ($obj) // It table categorie_association exists { - $couples=array(); - $filles=array(); + $couples = array(); + $filles = array(); $sql = "SELECT fk_categorie_mere, fk_categorie_fille"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: search duplicate"); $resql = $db->query($sql); if ($resql) { - $num=$db->num_rows($resql); - while ($obj=$db->fetch_object($resql)) + $num = $db->num_rows($resql); + while ($obj = $db->fetch_object($resql)) { - if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). + if (!isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). { if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) { - $filles[$obj->fk_categorie_fille]=1; // Set record for this child - $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); + $filles[$obj->fk_categorie_fille] = 1; // Set record for this child + $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille] = array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); } } } - dolibarr_install_syslog("upgrade: result is num=" . $num . " count(couples)=" . count($couples)); + dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples)); // If there is duplicates couples or child with two parents if (count($couples) > 0 && $num > count($couples)) { - $error=0; + $error = 0; $db->begin(); // We delete all - $sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: delete association"); - $resqld=$db->query($sql); + $resqld = $db->query($sql); if ($resqld) { // And we insert only each record once - foreach($couples as $key => $val) + foreach ($couples as $key => $val) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; - $sql.=" VALUES(".$val['mere'].", ".$val['fille'].")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; + $sql .= " VALUES(".$val['mere'].", ".$val['fille'].")"; dolibarr_install_syslog("upgrade: insert association"); - $resqli=$db->query($sql); - if (! $resqli) $error++; + $resqli = $db->query($sql); + if (!$resqli) $error++; } } - if (! $error) + if (!$error) { print '
'.$langs->trans("MigrationCategorieAssociation").''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).')
'; print ''.$langs->trans('Upgrade').': '; - print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated + print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated print ""; print "
\n"; print '
'."\n"; @@ -134,8 +134,8 @@ for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_SESSION["choix$i"]) === false) { $_SESSION["choix$i"] = ''; } - print ''."\n"; } @@ -144,7 +144,7 @@ print '
'. $langs->trans("TitleChoice") .' '.$j.': '; - $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList")); + print '
'.$langs->trans("TitleChoice").' '.$j.': '; + $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList")); print '   '.$langs->trans("Type").' '.$form->selectarray("typecolonne[]", $tmparray, $_SESSION["typecolonne$i"]); print '
'."\n"; //ajout de cases supplementaires print ''."\n"; -print ''."\n"; +print ''."\n"; print '
'. $langs->trans("5MoreChoices") .''.$langs->trans("5MoreChoices").'
'."\n"; print'
'."\n"; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 4f6eea5b903..8a2d643189b 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -22,13 +22,13 @@ * \brief File to return Ajax response on product list request */ -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('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '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('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); require '../../main.inc.php'; @@ -57,9 +57,9 @@ $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); dol_syslog(join(',', $_GET)); // print_r($_GET); -if (! empty($action) && $action == 'fetch' && ! empty($id)) +if (!empty($action) && $action == 'fetch' && !empty($id)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $outjson = array(); @@ -77,11 +77,11 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $found = false; // Price by qty - if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty + if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty { $sql = "SELECT price, unitprice, quantity, remise_percent"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty "; - $sql .= " WHERE rowid=" . $price_by_qty_rowid . ""; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty "; + $sql .= " WHERE rowid=".$price_by_qty_rowid.""; $result = $db->query($sql); if ($result) { @@ -99,14 +99,14 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } // Multiprice - if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price + if (!$found && isset($price_level) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price // level (from 1 to 6) { $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price "; - $sql .= " WHERE fk_product='" . $id . "'"; - $sql .= " AND entity IN (" . getEntity('productprice') . ")"; - $sql .= " AND price_level=" . $price_level; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price "; + $sql .= " WHERE fk_product='".$id."'"; + $sql .= " AND entity IN (".getEntity('productprice').")"; + $sql .= " AND price_level=".$price_level; $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1"; @@ -124,12 +124,12 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } // Price by customer - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $object->id,'t.fk_soc' => $socid); + $filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { @@ -143,21 +143,21 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } } - if (! $found) { + if (!$found) { $outprice_ht = price($object->price); $outprice_ttc = price($object->price_ttc); $outpricebasetype = $object->price_base_type; $outtva_tx = $object->tva_tx; } - $outjson = array('ref' => $outref,'label' => $outlabel,'desc' => $outdesc,'type' => $outtype,'price_ht' => $outprice_ht,'price_ttc' => $outprice_ttc,'pricebasetype' => $outpricebasetype,'tva_tx' => $outtva_tx,'qty' => $outqty,'discount' => $outdiscount); + $outjson = array('ref' => $outref, 'label' => $outlabel, 'desc' => $outdesc, 'type' => $outtype, 'price_ht' => $outprice_ht, 'price_ttc' => $outprice_ttc, 'pricebasetype' => $outpricebasetype, 'tva_tx' => $outtva_tx, 'qty' => $outqty, 'discount' => $outdiscount); } echo json_encode($outjson); } else { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $langs->load("products"); $langs->load("main"); @@ -170,19 +170,19 @@ else return; } - $match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET)); + $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $idprod = (! empty($match[0]) ? $match[0] : ''); + $idprod = (!empty($match[0]) ? $match[0] : ''); - if (GETPOST($htmlname, 'alpha') == '' && (! $idprod || ! GETPOST($idprod, 'alpha'))) + if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha'))) { print json_encode(array()); return; } // When used from jQuery, the search term is added as GET param "term". - $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); $form = new Form($db); if (empty($mode) || $mode == 1) { // mode=1: customer diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index b12a0d41370..99ddd39d49b 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -16,16 +16,16 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -$object=$GLOBALS['object']; +$object = $GLOBALS['object']; -$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); +$statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); ?> @@ -35,7 +35,7 @@ print load_fiche_titre($langs->trans("NewProduct"), '', 'products'); dol_fiche_head(''); ?> -error)?'':$object->error), $object->errors); ?> +error) ? '' : $object->error), $object->errors); ?> @@ -71,7 +71,7 @@ dol_fiche_head(''); selectarray('statut_buy', $statutarray, $object->status_buy); ?> -stock->enabled)) { ?> +stock->enabled)) { ?> trans("StockLimit"); ?> @@ -108,7 +108,7 @@ dol_fiche_head('');
-global->PRODUIT_MULTIPRICES) { ?> +global->PRODUIT_MULTIPRICES) { ?> diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index d51e1541278..26daca173a4 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -16,16 +16,16 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -$object=$GLOBALS['object']; +$object = $GLOBALS['object']; -$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); +$statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); ?> @@ -80,7 +80,7 @@ dol_fiche_head('');
-global->PRODUIT_MULTIPRICES) { ?> +global->PRODUIT_MULTIPRICES) { ?>
trans("SellingPrice"); ?>
diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 8117d8fb6aa..dd542b71f8d 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -21,7 +21,7 @@ * \ingroup produit * \brief File of class to manage predefined price products or services by customer */ -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * File of class to manage predefined price products or services by customer @@ -73,7 +73,7 @@ class Productcustomerprice extends CommonObject */ public $fk_user; - public $lines = array (); + public $lines = array(); /** @@ -166,7 +166,7 @@ class Productcustomerprice extends CommonObject } // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price("; $sql .= "entity,"; $sql .= "datec,"; $sql .= "fk_product,"; @@ -186,39 +186,39 @@ class Productcustomerprice extends CommonObject $sql .= "fk_user,"; $sql .= "import_key"; $sql .= ") VALUES ("; - $sql .= " " . $conf->entity . ","; - $sql .= " '" . $this->db->idate(dol_now()) . "',"; - $sql .= " " . (! isset($this->fk_product) ? 'NULL' : "'" . $this->db->escape($this->fk_product) . "'") . ","; - $sql .= " " . (! isset($this->fk_soc) ? 'NULL' : "'" . $this->db->escape($this->fk_soc) . "'") . ","; - $sql .= " " . (empty($this->price) ? '0' : "'" . $this->db->escape($this->price) . "'") . ","; - $sql .= " " . (empty($this->price_ttc) ? '0' : "'" . $this->db->escape($this->price_ttc) . "'") . ","; - $sql .= " " . (empty($this->price_min) ? '0' : "'" . $this->db->escape($this->price_min) . "'") . ","; - $sql .= " " . (empty($this->price_min_ttc) ? '0' : "'" . $this->db->escape($this->price_min_ttc) . "'") . ","; - $sql .= " " . (! isset($this->price_base_type) ? 'NULL' : "'" . $this->db->escape($this->price_base_type) . "'") . ","; + $sql .= " ".$conf->entity.","; + $sql .= " '".$this->db->idate(dol_now())."',"; + $sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").","; + $sql .= " ".(!isset($this->fk_soc) ? 'NULL' : "'".$this->db->escape($this->fk_soc)."'").","; + $sql .= " ".(empty($this->price) ? '0' : "'".$this->db->escape($this->price)."'").","; + $sql .= " ".(empty($this->price_ttc) ? '0' : "'".$this->db->escape($this->price_ttc)."'").","; + $sql .= " ".(empty($this->price_min) ? '0' : "'".$this->db->escape($this->price_min)."'").","; + $sql .= " ".(empty($this->price_min_ttc) ? '0' : "'".$this->db->escape($this->price_min_ttc)."'").","; + $sql .= " ".(!isset($this->price_base_type) ? 'NULL' : "'".$this->db->escape($this->price_base_type)."'").","; $sql .= " ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " " . (! isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx)?0:$this->tva_tx)) . ","; - $sql .= " " . (! isset($this->recuperableonly) ? 'NULL' : "'" . $this->db->escape($this->recuperableonly) . "'") . ","; - $sql .= " " . (empty($this->localtax1_type) ? "'0'" : "'" . $this->db->escape($this->localtax1_type) . "'") . ","; - $sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx)?0:$this->localtax1_tx)) . ","; - $sql .= " " . (empty($this->localtax2_type) ? "'0'" : "'" . $this->db->escape($this->localtax2_type) . "'") . ","; - $sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx)?0:$this->localtax2_tx)) . ","; - $sql .= " " . $user->id . ","; - $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ""; + $sql .= " ".(!isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx) ? 0 : $this->tva_tx)).","; + $sql .= " ".(!isset($this->recuperableonly) ? 'NULL' : "'".$this->db->escape($this->recuperableonly)."'").","; + $sql .= " ".(empty($this->localtax1_type) ? "'0'" : "'".$this->db->escape($this->localtax1_type)."'").","; + $sql .= " ".(!isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx)).","; + $sql .= " ".(empty($this->localtax2_type) ? "'0'" : "'".$this->db->escape($this->localtax2_type)."'").","; + $sql .= " ".(!isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx)).","; + $sql .= " ".$user->id.","; + $sql .= " ".(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'").""; $sql .= ")"; $this->db->begin(); - dol_syslog(get_class($this) . "::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } - if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_customer_price"); + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_customer_price"); - if (! $notrigger) { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -231,21 +231,21 @@ class Productcustomerprice extends CommonObject } } - if (! $error) { + if (!$error) { $result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $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; + return -1 * $error; } else { $this->db->commit(); return $this->id; @@ -283,10 +283,10 @@ class Productcustomerprice extends CommonObject $sql .= " t.fk_user,"; $sql .= " t.import_key"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t"; - $sql .= " WHERE t.rowid = " . $id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { @@ -316,8 +316,8 @@ class Productcustomerprice extends CommonObject return 1; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -337,8 +337,8 @@ class Productcustomerprice extends CommonObject // phpcs:enable global $langs; - if ( empty($sortfield)) $sortfield = "t.rowid"; - if ( empty($sortorder)) $sortorder = "DESC"; + if (empty($sortfield)) $sortfield = "t.rowid"; + if (empty($sortorder)) $sortorder = "DESC"; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -364,39 +364,39 @@ class Productcustomerprice extends CommonObject $sql .= " t.import_key,"; $sql .= " soc.nom as socname,"; $sql .= " prod.ref as prodref"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t "; - $sql .= " ," . MAIN_DB_PREFIX . "product as prod "; - $sql .= " ," . MAIN_DB_PREFIX . "societe as soc "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t "; + $sql .= " ,".MAIN_DB_PREFIX."product as prod "; + $sql .= " ,".MAIN_DB_PREFIX."societe as soc "; $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; - $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; - $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; + $sql .= " AND prod.entity IN (".getEntity('product').")"; + $sql .= " AND t.entity IN (".getEntity('productprice').")"; // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year { - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif ($key == 'soc.nom') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } elseif ($key == 'prod.ref') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } else { - $sql .= ' AND ' . $key . ' = ' . $value; + $sql .= ' AND '.$key.' = '.$value; } } } - $sql.= $this->db->order($sortfield, $sortorder); - if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset); - dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $line = new PriceByCustomerLine(); $line->id = $obj->rowid; @@ -429,8 +429,8 @@ class Productcustomerprice extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -450,8 +450,8 @@ class Productcustomerprice extends CommonObject // phpcs:enable global $langs; - if (! empty($sortfield)) $sortfield = "t.rowid"; - if (! empty($sortorder)) $sortorder = "DESC"; + if (!empty($sortfield)) $sortfield = "t.rowid"; + if (!empty($sortorder)) $sortorder = "DESC"; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -474,38 +474,38 @@ class Productcustomerprice extends CommonObject $sql .= " t.import_key,"; $sql .= " soc.nom as socname,"; $sql .= " prod.ref as prodref"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price_log as t "; - $sql .= " ," . MAIN_DB_PREFIX . "product as prod "; - $sql .= " ," . MAIN_DB_PREFIX . "societe as soc "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price_log as t "; + $sql .= " ,".MAIN_DB_PREFIX."product as prod "; + $sql .= " ,".MAIN_DB_PREFIX."societe as soc "; $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; - $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; - $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; + $sql .= " AND prod.entity IN (".getEntity('product').")"; + $sql .= " AND t.entity IN (".getEntity('productprice').")"; // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year { - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif ($key == 'soc.nom') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } else { - $sql .= ' AND ' . $key . ' = ' . $value; + $sql .= ' AND '.$key.' = '.$value; } } } - $sql.= $this->db->order($sortfield, $sortorder); - if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset); - dol_syslog(get_class($this) . "::fetch_all_log", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_all_log", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $line = new PriceByCustomerLine(); $line->id = $obj->rowid; @@ -536,8 +536,8 @@ class Productcustomerprice extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -622,7 +622,7 @@ class Productcustomerprice extends CommonObject // Do a copy of current record into log table // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price_log("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price_log("; $sql .= "entity,"; $sql .= "datec,"; @@ -665,75 +665,75 @@ class Productcustomerprice extends CommonObject $sql .= " t.fk_user,"; $sql .= " t.import_key"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t"; - $sql .= " WHERE t.rowid = " . $this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; + $sql .= " WHERE t.rowid = ".$this->id; $this->db->begin(); - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } // Update request - $sql = "UPDATE " . MAIN_DB_PREFIX . "product_customer_price SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."product_customer_price SET"; - $sql .= " entity=" . $conf->entity . ","; - $sql .= " datec='" . $this->db->idate(dol_now()) . "',"; - $sql .= " tms=" . (dol_strlen($this->tms) != 0 ? "'" . $this->db->idate($this->tms) . "'" : 'null') . ","; - $sql .= " fk_product=" . (isset($this->fk_product) ? $this->fk_product : "null") . ","; - $sql .= " fk_soc=" . (isset($this->fk_soc) ? $this->fk_soc : "null") . ","; - $sql .= " price=" . (isset($this->price) ? $this->price : "null") . ","; - $sql .= " price_ttc=" . (isset($this->price_ttc) ? $this->price_ttc : "null") . ","; - $sql .= " price_min=" . (isset($this->price_min) ? $this->price_min : "null") . ","; - $sql .= " price_min_ttc=" . (isset($this->price_min_ttc) ? $this->price_min_ttc : "null") . ","; - $sql .= " price_base_type=" . (isset($this->price_base_type) ? "'" . $this->db->escape($this->price_base_type) . "'" : "null") . ","; + $sql .= " entity=".$conf->entity.","; + $sql .= " datec='".$this->db->idate(dol_now())."',"; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").","; + $sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").","; + $sql .= " price=".(isset($this->price) ? $this->price : "null").","; + $sql .= " price_ttc=".(isset($this->price_ttc) ? $this->price_ttc : "null").","; + $sql .= " price_min=".(isset($this->price_min) ? $this->price_min : "null").","; + $sql .= " price_min_ttc=".(isset($this->price_min_ttc) ? $this->price_min_ttc : "null").","; + $sql .= " price_base_type=".(isset($this->price_base_type) ? "'".$this->db->escape($this->price_base_type)."'" : "null").","; $sql .= " default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " tva_tx=" . (isset($this->tva_tx) ? (empty($this->tva_tx)?0:$this->tva_tx) : "null") . ","; - $sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ","; - $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? (empty($this->localtax1_tx)?0:$this->localtax1_tx) : "null") . ","; - $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? (empty($this->localtax2_tx)?0:$this->localtax2_tx) : "null") . ","; - $sql .= " localtax1_type=" . (! empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'": "'0'") . ","; - $sql .= " localtax2_type=" . (! empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'": "'0'") . ","; - $sql .= " fk_user=" . $user->id . ","; - $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ""; + $sql .= " tva_tx=".(isset($this->tva_tx) ? (empty($this->tva_tx) ? 0 : $this->tva_tx) : "null").","; + $sql .= " recuperableonly=".(isset($this->recuperableonly) ? $this->recuperableonly : "null").","; + $sql .= " localtax1_tx=".(isset($this->localtax1_tx) ? (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx) : "null").","; + $sql .= " localtax2_tx=".(isset($this->localtax2_tx) ? (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx) : "null").","; + $sql .= " localtax1_type=".(!empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'").","; + $sql .= " localtax2_type=".(!empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'").","; + $sql .= " fk_user=".$user->id.","; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; - $sql .= " WHERE rowid=" . $this->id; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf); + if ($result < 0) { $error++; $this->errors = $interface->errors; } // End call triggers } } - if (! $error) { + if (!$error) { $result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return 1; @@ -754,34 +754,34 @@ class Productcustomerprice extends CommonObject // Find all susidiaries $sql = "SELECT s.rowid"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; - $sql .= " WHERE s.parent = " . $this->fk_soc; - $sql .= " AND s.entity IN (" . getEntity('societe') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.parent = ".$this->fk_soc; + $sql .= " AND s.entity IN (".getEntity('societe').")"; - dol_syslog(get_class($this) . "::setPriceOnAffiliateThirdparty", LOG_DEBUG); + dol_syslog(get_class($this)."::setPriceOnAffiliateThirdparty", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( ($obj = $this->db->fetch_object($resql)) && (empty($error)) ) { + while (($obj = $this->db->fetch_object($resql)) && (empty($error))) { // find if there is an existing line for the product and the subsidiaries $prodsocprice = new Productcustomerprice($this->db); - $filter = array ( - 't.fk_product' => $this->fk_product,'t.fk_soc' => $obj->rowid + $filter = array( + 't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid ); $result = $prodsocprice->fetch_all('', '', 0, 0, $filter); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocprice->error; } else { // There is one line if (count($prodsocprice->lines) > 0) { // If force update => Update - if (! empty($forceupdateaffiliate)) { + if (!empty($forceupdateaffiliate)) { $prodsocpriceupd = new Productcustomerprice($this->db); $prodsocpriceupd->fetch($prodsocprice->lines [0]->id); @@ -793,7 +793,7 @@ class Productcustomerprice extends CommonObject $resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocpriceupd->error; } } @@ -810,7 +810,7 @@ class Productcustomerprice extends CommonObject $resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocpriceupd->error; } } @@ -821,11 +821,11 @@ class Productcustomerprice extends CommonObject if (empty($error)) { return 1; } else { - return - 1; + return -1; } } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -844,8 +844,8 @@ class Productcustomerprice extends CommonObject $this->db->begin(); - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -858,26 +858,26 @@ class Productcustomerprice extends CommonObject } } - if (! $error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_customer_price"; - $sql .= " WHERE rowid=" . $this->id; + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_customer_price"; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return 1; @@ -908,28 +908,28 @@ class Productcustomerprice extends CommonObject // ... // Create clone - $object->context['createfromclone']='createfromclone'; + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options if ($result < 0) { $this->error = $object->error; - $this->errors=array_merge($this->errors, $object->errors); + $this->errors = array_merge($this->errors, $object->errors); $error++; } - if (! $error) { + if (!$error) { } unset($object->context['createfromclone']); // End - if (! $error) { + if (!$error) { $this->db->commit(); return $object->id; } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/product/document.php b/htdocs/product/document.php index ef508c9a200..f12b20b7921 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -62,33 +62,33 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="position_name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "position_name"; $object = new Product($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + if (!empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + elseif (!empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; } } -$modulepart='produit'; +$modulepart = 'produit'; /* * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -102,10 +102,10 @@ if (empty($reshook)) $urlfile = GETPOST('urlfile', 'alpha'); $filename = basename($urlfile); $filetomerge = new Propalmergepdfproduct($db); - $filetomerge->fk_product=$object->id; - $filetomerge->file_name=$filename; - $result=$filetomerge->delete_by_file($user); - if ($result<0) { + $filetomerge->fk_product = $object->id; + $filetomerge->file_name = $filename; + $result = $filetomerge->delete_by_file($user); + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } } @@ -115,7 +115,7 @@ if (empty($reshook)) include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } -if ($action=='filemerge') +if ($action == 'filemerge') { $is_refresh = GETPOST('refresh'); if (empty($is_refresh)) { @@ -131,11 +131,11 @@ if ($action=='filemerge') $filetomerge = new Propalmergepdfproduct($db); if ($conf->global->MAIN_MULTILANGS) { - $result=$filetomerge->delete_by_product($user, $object->id, $lang_id); + $result = $filetomerge->delete_by_product($user, $object->id, $lang_id); } else { - $result=$filetomerge->delete_by_product($user, $object->id); + $result = $filetomerge->delete_by_product($user, $object->id); } - if ($result<0) { + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } @@ -149,8 +149,8 @@ if ($action=='filemerge') $filetomerge->lang = $lang_id; } - $result=$filetomerge->create($user); - if ($result<0) { + $result = $filetomerge->create($user); + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } } @@ -170,13 +170,13 @@ $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Documents'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Documents'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Documents'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Documents'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); @@ -234,8 +234,8 @@ if ($object->id) dol_fiche_end(); $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; // Merge propal PDF document PDF files @@ -255,7 +255,7 @@ if ($object->id) $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { $filearray = array_merge($filearray, dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1)); } @@ -269,8 +269,8 @@ if ($object->id) print $langs->trans('PropalMergePdfProductActualFile'); } - print ''; - print ''; + print ''; + print ''; print ''; if (count($filetomerge->lines) == 0) { print $langs->trans('PropalMergePdfProductChooseFile'); @@ -291,7 +291,7 @@ if ($object->id) print Form::selectarray('lang_id', $langs_available, $default_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); if ($conf->global->MAIN_MULTILANGS) { - print ''; + print ''; } print ''; @@ -306,9 +306,9 @@ if ($object->id) if ($conf->global->MAIN_MULTILANGS) { - if (array_key_exists($filetoadd['name'] . '_' . $default_lang, $filetomerge->lines)) + if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines)) { - $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $default_lang); + $filename = $filetoadd['name'].' - '.$langs->trans('Language_'.$default_lang); $checked = ' checked '; } } @@ -321,13 +321,13 @@ if ($object->id) } print ''; } } print ''; print '
trans("SellingPrice"); ?>
'; - print '' . $filename . ''; + print ''.$filename.''; print '
'; - print ''; + print ''; print '
'; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b10f409e9a1..b419185d84e 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -259,8 +259,9 @@ if (empty($reshook)) { $supplier = new Fournisseur($db); $result = $supplier->fetch($id_fourn); - if (isset($_POST['ref_fourn_price_id'])) - $object->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); + if (GETPOSTISSET('ref_fourn_price_id')) { + $object->fetch_product_fournisseur_price(GETPOST('ref_fourn_price_id', 'int')); + } $extralabels = $extrafields->fetch_name_optionals_label("product_fournisseur_price"); $extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price"); diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 3054aebfa9d..12c9163cf92 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -56,20 +56,20 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page < 0) $page = 0; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; // Load sale and categ filters $search_sale = GETPOST("search_sale"); $search_categ = GETPOST("search_categ"); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas=GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -77,10 +77,10 @@ if (! empty($canvas)) } // Define virtualdiffersfromphysical -$virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)|| ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) +$virtualdiffersfromphysical = 0; +if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } @@ -91,18 +91,18 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global 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 { - $sref=""; - $snom=""; - $sall=""; - $tosell=""; - $tobuy=""; - $search_sale=""; - $search_categ=""; - $type=""; - $catid=''; - $toolowstock=''; - $fourn_id=''; - $sbarcode=''; + $sref = ""; + $snom = ""; + $sall = ""; + $tosell = ""; + $tobuy = ""; + $search_sale = ""; + $search_categ = ""; + $type = ""; + $catid = ''; + $toolowstock = ''; + $fourn_id = ''; + $sbarcode = ''; } @@ -111,50 +111,50 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -$helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; -$form=new Form($db); -$htmlother=new FormOther($db); +$form = new Form($db); +$htmlother = new FormOther($db); $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; -$sql.= ' p.fk_product_type, p.tms as datem,'; -$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; -$sql.= ' SUM(s.reel) as stock_physique'; -if (! empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ', u.short_label as unit_short'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; -if (! empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; +$sql .= ' p.fk_product_type, p.tms as datem,'; +$sql .= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; +$sql .= ' SUM(s.reel) as stock_physique'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ', u.short_label as unit_short'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; // We'll need this table joined to the select in order to filter by categ -if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -$sql.= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ -if ($sall) $sql.=natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); +if ($search_categ) $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; +$sql .= " WHERE p.entity IN (".getEntity('product').")"; +if ($search_categ) $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ +if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) { - if ($type==1) + if ($type == 1) { - $sql.= " AND p.fk_product_type = '1'"; + $sql .= " AND p.fk_product_type = '1'"; } else { - $sql.= " AND p.fk_product_type <> '1'"; + $sql .= " AND p.fk_product_type <> '1'"; } } -if ($sref) $sql.= natural_search('p.ref', $sref); -if ($search_barcode) $sql.= natural_search('p.barcode', $search_barcode); -if ($snom) $sql.= natural_search('p.label', $snom); -if (! empty($tosell)) $sql.= " AND p.tosell = ".$tosell; -if (! empty($tobuy)) $sql.= " AND p.tobuy = ".$tobuy; -if (! empty($canvas)) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; -if($catid) $sql.= " AND cp.fk_categorie = ".$catid; -if ($fourn_id > 0) $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; +if ($sref) $sql .= natural_search('p.ref', $sref); +if ($search_barcode) $sql .= natural_search('p.barcode', $search_barcode); +if ($snom) $sql .= natural_search('p.label', $snom); +if (!empty($tosell)) $sql .= " AND p.tosell = ".$tosell; +if (!empty($tobuy)) $sql .= " AND p.tobuy = ".$tobuy; +if (!empty($canvas)) $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; +if ($catid) $sql .= " AND cp.fk_categorie = ".$catid; +if ($fourn_id > 0) $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; // Insert categ filter if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); -$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; -$sql.= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock"; -if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; -$sql.= $db->order($sortfield, $sortorder); +$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; +$sql .= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock"; +if ($toolowstock) $sql .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -169,7 +169,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -187,31 +187,31 @@ if ($resql) if (isset($type)) { - if ($type==1) { $texte = $langs->trans("Services"); } + if ($type == 1) { $texte = $langs->trans("Services"); } else { $texte = $langs->trans("Products"); } } else { $texte = $langs->trans("ProductsAndServices"); } - $texte.=' ('.$langs->trans("MenuStocks").')'; + $texte .= ' ('.$langs->trans("MenuStocks").')'; - $param=''; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($tosell) $param.="&tosell=".urlencode($tosell); - if ($tobuy) $param.="&tobuy=".urlencode($tobuy); - if ($type) $param.="&type=".urlencode($type); - if ($fourn_id) $param.="&fourn_id=".urlencode($fourn_id); - if ($snom) $param.="&snom=".urlencode($snom); - if ($sref) $param.="&sref=".urlencode($sref); - if ($search_sale) $param.="&search_sale=".urlencode($search_sale); - if ($search_categ) $param.="&search_categ=".urlencode($search_categ); - if ($toolowstock) $param.="&toolowstock=".urlencode($toolowstock); - if ($sbarcode) $param.="&sbarcode=".urlencode($sbarcode); - if ($catid) $param.="&catid=".urlencode($catid); + $param = ''; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($tosell) $param .= "&tosell=".urlencode($tosell); + if ($tobuy) $param .= "&tobuy=".urlencode($tobuy); + if ($type) $param .= "&type=".urlencode($type); + if ($fourn_id) $param .= "&fourn_id=".urlencode($fourn_id); + if ($snom) $param .= "&snom=".urlencode($snom); + if ($sref) $param .= "&sref=".urlencode($sref); + if ($search_sale) $param .= "&search_sale=".urlencode($search_sale); + if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); + if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock); + if ($sbarcode) $param .= "&sbarcode=".urlencode($sbarcode); + if ($catid) $param .= "&catid=".urlencode($catid); llxHeader("", $texte, $helpurl); - print ''; + print ''; print ''; print ''; print ''; @@ -220,7 +220,7 @@ if ($resql) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'products', 0, '', '', $limit); - if (! empty($catid)) + if (!empty($catid)) { print "
"; $c = new Categorie($db); @@ -231,48 +231,48 @@ if ($resql) } // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) + $moreforfilter = ''; + if (!empty($conf->categorie->enabled)) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); + $moreforfilter .= '
'; } - $moreforfilter.='
'; - $moreforfilter.=$langs->trans("StockTooLow").' '; - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans("StockTooLow").' '; + $moreforfilter .= '
'; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } - $param=''; - if ($tosell) $param.="&tosell=".$tosell; - if ($tobuy) $param.="&tobuy=".$tobuy; - if ($type) $param.="&type=".$type; - if ($fourn_id) $param.="&fourn_id=".$fourn_id; - if ($snom) $param.="&snom=".$snom; - if ($sref) $param.="&sref=".$sref; - if ($toolowstock) $param.="&toolowstock=".$toolowstock; - if ($search_categ) $param.="&search_categ=".$search_categ; + $param = ''; + if ($tosell) $param .= "&tosell=".$tosell; + if ($tobuy) $param .= "&tobuy=".$tobuy; + if ($type) $param .= "&type=".$type; + if ($fourn_id) $param .= "&fourn_id=".$fourn_id; + if ($snom) $param .= "&snom=".$snom; + if ($sref) $param .= "&sref=".$sref; + if ($toolowstock) $param .= "&toolowstock=".$toolowstock; + if ($search_categ) $param .= "&search_categ=".$search_categ; $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); $warehouses_list = $formProduct->cache_warehouses; $nb_warehouse = count($warehouses_list); $colspan_warehouse = 1; - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse+1 : 1; } + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse + 1 : 1; } print '
'; - print ''; + print '
'; // Fields title search print ''; @@ -283,7 +283,7 @@ if ($resql) print ''; print ''; // Duration - if (! empty($conf->service->enabled) && $type == 1) + if (!empty($conf->service->enabled) && $type == 1) { print ''; print ''; print ''; print ''; @@ -307,14 +307,14 @@ if ($resql) 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->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + if (!empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); print_liste_field_titre("StockLimit", $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", $param, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock", $param, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right '); // Details per warehouse - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) { - if ($nb_warehouse>1) { + if ($nb_warehouse > 1) { foreach ($warehouses_list as &$wh) { print_liste_field_titre($wh['label'], '', '', '', '', '', '', '', 'right '); } @@ -322,7 +322,7 @@ if ($resql) } if ($virtualdiffersfromphysical) print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", $param, "", '', $sortfield, $sortorder, 'right '); // Units - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print_liste_field_titre("Unit", $_SERVER["PHP_SELF"], "unit_short", $param, "", 'align="right"', $sortfield, $sortorder); } print_liste_field_titre(''); @@ -335,7 +335,7 @@ if ($resql) { $objp = $db->fetch_object($resql); - $product=new Product($db); + $product = new Product($db); $product->fetch($objp->rowid); $product->load_stock(); @@ -346,7 +346,7 @@ if ($resql) print ''; print ''; - if (! empty($conf->service->enabled) && $type == 1) + if (!empty($conf->service->enabled) && $type == 1) { print ''; // Details per warehouse - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) { - if($nb_warehouse>1) { - foreach($warehouses_list as &$wh) { + if ($nb_warehouse > 1) { + foreach ($warehouses_list as &$wh) { print ''; @@ -385,8 +385,8 @@ if ($resql) print ''; } // Units - if (! empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; } print ''; print ''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f969679a9f6..0ec6652f20b 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -88,6 +88,15 @@ class Project extends CommonObject public $thirdparty_name; // To store name of thirdparty (defined only in some cases) public $user_author_id; //!< Id of project creator. Not defined if shared project. + + /** + * @var int user close id + */ + public $fk_user_close; + + /** + * @var int user close id + */ public $user_close_id; public $public; //!< Tell if this is a public or private project public $budget_amount; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 15c98b4d1fc..cd82f25d4d8 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -95,18 +95,18 @@ print '
'; if ($mine) print $langs->trans("MyProjectsDesc").'

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

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

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

'; } print '
'; // Get list of ponderated percent for each status -$listofoppstatus=array(); $listofopplabel=array(); $listofoppcode=array(); +$listofoppstatus = array(); $listofopplabel = array(); $listofoppcode = array(); $sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label"; -$sql.= " FROM ".MAIN_DB_PREFIX."c_lead_status as cls"; -$sql.= " WHERE active=1"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_lead_status as cls"; +$sql .= " WHERE active=1"; $resql = $db->query($sql); -if ( $resql ) +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -114,9 +114,9 @@ if ( $resql ) while ($i < $num) { $objp = $db->fetch_object($resql); - $listofoppstatus[$objp->rowid]=$objp->percent; - $listofopplabel[$objp->rowid]=$objp->label; - $listofoppcode[$objp->rowid]=$objp->code; + $listofoppstatus[$objp->rowid] = $objp->percent; + $listofopplabel[$objp->rowid] = $objp->label; + $listofoppcode[$objp->rowid] = $objp->code; $i++; } } @@ -127,12 +127,12 @@ else dol_print_error($db); print '
'; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search project - if (! empty($conf->projet->enabled) && $user->rights->projet->lire) + if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { - $listofsearchfields['search_project']=array('text'=>'Project'); + $listofsearchfields['search_project'] = array('text'=>'Project'); } if (count($listofsearchfields)) @@ -141,8 +141,8 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; print '
'; print '
'; print ' '; @@ -298,7 +298,7 @@ if ($resql) print ' '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'.$product->label.''; if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationYear"); @@ -361,14 +361,14 @@ if ($resql) // Real stock print ''; if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; - print $objp->stock_physique|0; + print $objp->stock_physique | 0; print ''; print empty($product->stock_warehouse[$wh['id']]->real) ? '0' : $product->stock_warehouse[$wh['id']]->real; print '' . $objp->unit_short . ''.$objp->unit_short.''.$langs->trans("Movements").''.$product->LibStatut($objp->statut, 5, 0).'
'; - $i=0; - foreach($listofsearchfields as $key => $value) + $i = 0; + foreach ($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; @@ -173,16 +173,16 @@ print '
'; // Latest modified projects $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.tms as datem,"; -$sql.= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; -$sql.= " WHERE p.entity IN (".getEntity('project').")"; -if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 -if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; -$sql.= " ORDER BY p.tms DESC"; -$sql.= $db->plimit($max, 0); +$sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.canvas"; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; +$sql .= " WHERE p.entity IN (".getEntity('project').")"; +if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 +if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +$sql .= " ORDER BY p.tms DESC"; +$sql .= $db->plimit($max, 0); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { print '
'; @@ -202,21 +202,21 @@ if ($resql) print '
'; print '\n"; $sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)"; -$sql.= ", s.nom as name, s.rowid as socid"; -$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; -$sql.= " WHERE p.entity IN (".getEntity('project').")"; -$sql.= " AND p.fk_statut = 1"; -if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 -if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; -$sql.= " GROUP BY s.nom, s.rowid"; -$sql.= $db->order($sortfield, $sortorder); +$sql .= ", s.nom as name, s.rowid as socid"; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; +$sql .= " WHERE p.entity IN (".getEntity('project').")"; +$sql .= " AND p.fk_statut = 1"; +if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 +if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +$sql .= " GROUP BY s.nom, s.rowid"; +$sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); -if ( $resql ) +if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -289,8 +289,8 @@ if ( $resql ) print '
'.$langs->trans("Search").'
'; - $projectstatic->id=$obj->rowid; - $projectstatic->ref=$obj->ref; - $projectstatic->title=$obj->title; - $projectstatic->dateo=$obj->dateo; - $projectstatic->datep=$obj->datep; - $projectstatic->thirdparty_name=$obj->name; + $projectstatic->id = $obj->rowid; + $projectstatic->ref = $obj->ref; + $projectstatic->title = $obj->title; + $projectstatic->dateo = $obj->dateo; + $projectstatic->datep = $obj->datep; + $projectstatic->thirdparty_name = $obj->name; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->email=$obj->email; - $companystatic->client=$obj->client; - $companystatic->fournisseur=$obj->fournisseur; - $companystatic->code_client=$obj->code_client; - $companystatic->code_fournisseur=$obj->code_fournisseur; - $companystatic->canvas=$obj->canvas; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->email = $obj->email; + $companystatic->client = $obj->client; + $companystatic->fournisseur = $obj->fournisseur; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas = $obj->canvas; print ''; print ''; print '
'; @@ -228,9 +228,9 @@ if ($resql) print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($projectstatic->element, $filename, $filedir); print '
'; @@ -253,7 +253,7 @@ if ($resql) else dol_print_error($db); -$companystatic=new Societe($db); // We need a clean new object for next loop because current one has some properties set. +$companystatic = new Societe($db); // We need a clean new object for next loop because current one has some properties set. // Open project per thirdparty @@ -265,18 +265,18 @@ print_liste_field_titre("NbOfProjects", "", "", "", "", '', $sortfield, $sortord print "
'; if ($obj->socid) { - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; print $companystatic->getNomUrl(1); } else @@ -316,7 +316,7 @@ else print "
"; print '
'; -if (! empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA)) +if (!empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA)) { // This list can be very long, so we don't show it by default on task area. We prefer to use the list page. // Add constant PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA to show this list diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 6a0748f8f84..7ffc0908c4e 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -26,13 +26,13 @@ * \brief File to offer a way to make an online signature for a particular Dolibarr entity */ -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +define("NOLOGIN", 1); // This means this output page does not require to be logged. +define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; @@ -46,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); // Input are: // type ('invoice','order','contractline'), @@ -55,15 +55,15 @@ $action=GETPOST('action', 'alpha'); // tag (a free text, required if type is empty) // currency (iso code) -$suffix=GETPOST("suffix", 'alpha'); -$source=GETPOST("source", 'alpha'); -$ref=$REF=GETPOST("ref", 'alpha'); +$suffix = GETPOST("suffix", 'alpha'); +$source = GETPOST("source", 'alpha'); +$ref = $REF = GETPOST("ref", 'alpha'); -if (empty($source)) $source='proposal'; +if (empty($source)) $source = 'proposal'; -if (! $action) +if (!$action) { - if ($source && ! $ref) + if ($source && !$ref) { print $langs->trans('ErrorBadParameters')." - ref missing"; exit; @@ -71,8 +71,8 @@ if (! $action) } -$paymentmethod=''; -$validpaymentmethod=array(); +$paymentmethod = ''; +$validpaymentmethod = array(); @@ -80,34 +80,34 @@ $validpaymentmethod=array(); // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. +$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. // Complete urls for post treatment -$SECUREKEY=GETPOST("securekey"); // Secure key +$SECUREKEY = GETPOST("securekey"); // Secure key -if (! empty($source)) +if (!empty($source)) { - $urlok.='source='.urlencode($source).'&'; - $urlko.='source='.urlencode($source).'&'; + $urlok .= 'source='.urlencode($source).'&'; + $urlko .= 'source='.urlencode($source).'&'; } -if (! empty($REF)) +if (!empty($REF)) { - $urlok.='ref='.urlencode($REF).'&'; - $urlko.='ref='.urlencode($REF).'&'; + $urlok .= 'ref='.urlencode($REF).'&'; + $urlko .= 'ref='.urlencode($REF).'&'; } -if (! empty($SECUREKEY)) +if (!empty($SECUREKEY)) { - $urlok.='securekey='.urlencode($SECUREKEY).'&'; - $urlko.='securekey='.urlencode($SECUREKEY).'&'; + $urlok .= 'securekey='.urlencode($SECUREKEY).'&'; + $urlko .= 'securekey='.urlencode($SECUREKEY).'&'; } -if (! empty($entity)) +if (!empty($entity)) { - $urlok.='entity='.urlencode($entity).'&'; - $urlko.='entity='.urlencode($entity).'&'; + $urlok .= 'entity='.urlencode($entity).'&'; + $urlko .= 'entity='.urlencode($entity).'&'; } -$urlok=preg_replace('/&$/', '', $urlok); // Remove last & -$urlko=preg_replace('/&$/', '', $urlko); // Remove last & +$urlok = preg_replace('/&$/', '', $urlok); // Remove last & +$urlko = preg_replace('/&$/', '', $urlko); // Remove last & $creditor = $mysoc->name; @@ -127,16 +127,16 @@ if ($action == 'dosign') * View */ -$head=''; -if (! empty($conf->global->MAIN_SIGN_CSS_URL)) $head=''."\n"; +$head = ''; +if (!empty($conf->global->MAIN_SIGN_CSS_URL)) $head = ''."\n"; -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Check link validity -if (! empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) +if (!empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) { $langs->load("errors"); dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); @@ -161,24 +161,24 @@ print ''."\n"; print ''."\n"; // Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo) -$width=0; +$width = 0; // Define logo and logosmall -$logosmall=$mysoc->logo_small; -$logo=$mysoc->logo; -$paramlogo='ONLINE_SIGN_LOGO_'.$suffix; -if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; -elseif (! empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall=$conf->global->ONLINE_SIGN_LOGO; +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_SIGN_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo; +elseif (!empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall = $conf->global->ONLINE_SIGN_LOGO; //print ''."\n"; // Define urllogo -$urllogo=''; -if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +$urllogo = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); } -elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); - $width=96; + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $width = 96; } // Output html code for logo if ($urllogo) @@ -191,18 +191,18 @@ if ($urllogo) } // Output introduction text -$text=''; -if (! empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) +$text = ''; +if (!empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) { $langs->load("members"); - if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text.=$langs->trans($reg[1])."
\n"; - else $text.=$conf->global->ONLINE_SIGN_NEWFORM_TEXT."
\n"; - $text=''."\n"; + if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text .= $langs->trans($reg[1])."
\n"; + else $text .= $conf->global->ONLINE_SIGN_NEWFORM_TEXT."
\n"; + $text = ''."\n"; } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text .= ''."\n"; + $text .= ''."\n"; } print $text; @@ -211,47 +211,47 @@ print '

'.$text.'

'.$text.'

'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'
'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'


'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'
'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'

'; print ''; print ''."\n"; -$found=false; -$error=0; -$var=false; +$found = false; +$error = 0; +$var = false; // Payment on customer order if ($source == 'proposal') { - $found=true; + $found = true; $langs->load("proposal"); require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $proposal=new Propal($db); - $result=$proposal->fetch('', $ref); + $proposal = new Propal($db); + $result = $proposal->fetch('', $ref); if ($result <= 0) { - $mesg=$proposal->error; + $mesg = $proposal->error; $error++; } else { - $result=$proposal->fetch_thirdparty($proposal->socid); + $result = $proposal->fetch_thirdparty($proposal->socid); } // Creditor - print ''."\n"; // Debitor - print ''."\n"; @@ -259,7 +259,7 @@ if ($source == 'proposal') -if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); +if (!$found && !$mesg) $mesg = $langs->trans("ErrorBadParameters"); if ($mesg) print ''."\n"; @@ -268,7 +268,7 @@ print "\n"; if ($action != 'dosign') { - if ($found && ! $error) // We are in a management option and no error + if ($found && !$error) // We are in a management option and no error { } else diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 00a92ecc115..9b3dd7dea03 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -22,8 +22,8 @@ * \ingroup core * \brief Class file to manage forms into resource module */ -require_once DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php"; -require_once DOL_DOCUMENT_ROOT ."/resource/class/dolresource.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"; +require_once DOL_DOCUMENT_ROOT."/resource/class/dolresource.class.php"; /** @@ -39,14 +39,14 @@ class FormResource */ public $db; - public $substit=array(); + public $substit = array(); - public $param=array(); + public $param = array(); /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** @@ -79,10 +79,10 @@ class FormResource public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20) { // phpcs:enable - global $conf,$user,$langs; + global $conf, $user, $langs; - $out=''; - $outarray=array(); + $out = ''; + $outarray = array(); $resourcestat = new Dolresource($this->db); @@ -91,20 +91,20 @@ class FormResource if ($outputmode != 2) { $out = ''; - $out.= ''; + $out .= ''; } if ($resourcestat) { - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && ! $forcecombo) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo) { //$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2); - $out.= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); + $out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); } // Construct $out and $outarray - $out.= ''."\n"; + if ($showempty) $out .= ''."\n"; $num = 0; if (is_array($resourcestat->lines)) $num = count($resourcestat->lines); @@ -115,34 +115,34 @@ class FormResource { while ($i < $num) { - $resourceclass=ucfirst($resourcestat->lines[$i]->element); + $resourceclass = ucfirst($resourcestat->lines[$i]->element); - $label=$resourcestat->lines[$i]->ref?$resourcestat->lines[$i]->ref:''.$resourcestat->lines[$i]->label; - if ($resourceclass != 'Dolresource') $label.=' ('.$langs->trans($resourceclass).')'; + $label = $resourcestat->lines[$i]->ref ? $resourcestat->lines[$i]->ref : ''.$resourcestat->lines[$i]->label; + if ($resourceclass != 'Dolresource') $label .= ' ('.$langs->trans($resourceclass).')'; if ($selected > 0 && $selected == $resourcestat->lines[$i]->id) { - $out.= ''; + $out .= ''; } else { - $out.= ''; + $out .= ''; } array_push($outarray, array('key'=>$resourcestat->lines[$i]->id, 'value'=>$resourcestat->lines[$i]->label, 'label'=>$resourcestat->lines[$i]->label)); $i++; - if (($i % 10) == 0) $out.="\n"; + if (($i % 10) == 0) $out .= "\n"; } } - $out.= ''."\n"; - $out.= ajax_combobox($htmlname); + $out .= ''."\n"; + $out .= ajax_combobox($htmlname); if ($outputmode != 2) { - $out.= '     '; + $out .= '     '; - $out.= ''; + $out .= ''; } } else @@ -170,22 +170,22 @@ class FormResource public function select_types_resource($selected = '', $htmlname = 'type_resource', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0) { // phpcs:enable - global $langs,$user; + global $langs, $user; $resourcestat = new Dolresource($this->db); dol_syslog(get_class($this)."::select_types_resource ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); - $filterarray=array(); + $filterarray = array(); - if ($filtertype != '' && $filtertype != '-1') $filterarray=explode(',', $filtertype); + if ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype); $resourcestat->load_cache_code_type_resource(); print ''; - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 42fae860666..8a29d653912 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -57,7 +57,7 @@ class Thirdparties extends DolibarrApi $this->company = new Societe($this->db); - if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY)) { + if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY)) { static::$FIELDS[] = 'email'; } } @@ -112,7 +112,7 @@ class Thirdparties extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $sqlfilters = '') { - global $db, $conf; + global $db; $obj_ret = array(); @@ -121,24 +121,24 @@ class Thirdparties extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."societe as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; - $sql.= " WHERE t.fk_stcomm = st.id"; - if ($mode == 1) $sql.= " AND t.client IN (1, 3)"; - if ($mode == 2) $sql.= " AND t.client IN (2, 3)"; - if ($mode == 3) $sql.= " AND t.client IN (0)"; - if ($mode == 4) $sql.= " AND t.fournisseur IN (1)"; - $sql.= ' AND t.entity IN ('.getEntity('societe').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; + $sql .= " WHERE t.fk_stcomm = st.id"; + if ($mode == 1) $sql .= " AND t.client IN (1, 3)"; + if ($mode == 2) $sql .= " AND t.client IN (2, 3)"; + if ($mode == 3) $sql .= " AND t.client IN (0)"; + if ($mode == 4) $sql .= " AND t.fournisseur IN (1)"; + $sql .= ' AND t.entity IN ('.getEntity('societe').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; - if ($socid) $sql.= " AND t.rowid IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($socids) $sql .= " AND t.rowid IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { @@ -147,15 +147,15 @@ class Thirdparties extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -164,7 +164,7 @@ class Thirdparties extends DolibarrApi } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); @@ -172,11 +172,12 @@ class Thirdparties extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); $soc_static = new Societe($db); - if($soc_static->fetch($obj->rowid)) { + if ($soc_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($soc_static); } $i++; @@ -185,7 +186,7 @@ class Thirdparties extends DolibarrApi else { throw new RestException(503, 'Error when retrieve thirdparties : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'Thirdparties not found'); } return $obj_ret; @@ -199,13 +200,13 @@ class Thirdparties extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->company->$field = $value; } if ($this->company->create(DolibarrApiAccess::$user) < 0) @@ -223,25 +224,25 @@ class Thirdparties extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->company->$field = $value; } - if($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) + if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) return $this->get($id); return false; @@ -272,27 +273,27 @@ class Thirdparties extends DolibarrApi throw new RestException(400, 'Try to merge a thirdparty into itself'); } - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - $result = $this->company->fetch($id); // include the fetch of extra fields - if( ! $result ) { + $result = $this->company->fetch($id); // include the fetch of extra fields + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->companytoremove = new Societe($db); - $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields - if( ! $result ) { + $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -309,7 +310,7 @@ class Thirdparties extends DolibarrApi // Recopy some data $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; - $listofproperties=array( + $listofproperties = array( 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', @@ -323,7 +324,7 @@ class Thirdparties extends DolibarrApi } // Concat some data - $listofproperties=array( + $listofproperties = array( 'note_public', 'note_private' ); foreach ($listofproperties as $property) @@ -367,7 +368,7 @@ class Thirdparties extends DolibarrApi } // Move links - if (! $error) + if (!$error) { $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', @@ -422,12 +423,12 @@ class Thirdparties extends DolibarrApi } - if (! $error) + if (!$error) { - $object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id); + $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id); // Call trigger - $result=$object->call_trigger('COMPANY_MODIFY', $user); + $result = $object->call_trigger('COMPANY_MODIFY', $user); if ($result < 0) { //setEventMessages($object->error, $object->errors, 'errors'); @@ -436,7 +437,7 @@ class Thirdparties extends DolibarrApi // End call triggers } - if (! $error) + if (!$error) { //We finally remove the old thirdparty if ($soc_origin->delete($soc_origin->id, $user) < 1) @@ -469,14 +470,14 @@ class Thirdparties extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->societe->supprimer) { + if (!DolibarrApiAccess::$user->rights->societe->supprimer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->company->oldcopy = clone $this->company; @@ -498,12 +499,12 @@ class Thirdparties extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -537,24 +538,24 @@ class Thirdparties extends DolibarrApi */ public function addCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -575,24 +576,24 @@ class Thirdparties extends DolibarrApi */ public function deleteCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -616,12 +617,12 @@ class Thirdparties extends DolibarrApi */ public function getSupplierCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -655,24 +656,24 @@ class Thirdparties extends DolibarrApi */ public function addSupplierCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -693,24 +694,24 @@ class Thirdparties extends DolibarrApi */ public function deleteSupplierCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -738,20 +739,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -782,20 +783,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -825,20 +826,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -868,20 +869,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -935,14 +936,14 @@ class Thirdparties extends DolibarrApi if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)"; - $sql.= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); $result = $this->db->query($sql); - if( ! $result ) { + if (!$result) { throw new RestException(503, $this->db->lasterror()); } else { $num = $this->db->num_rows($result); - while ( $obj = $this->db->fetch_object($result) ) { + while ($obj = $this->db->fetch_object($result)) { $obj_ret[] = $obj; } } @@ -967,14 +968,14 @@ class Thirdparties extends DolibarrApi */ public function getInvoicesQualifiedForReplacement($id) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -985,7 +986,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_replacable_invoices($id); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->thirdparty->error); } @@ -1009,14 +1010,14 @@ class Thirdparties extends DolibarrApi */ public function getInvoicesQualifiedForCreditNote($id) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1027,7 +1028,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_qualified_avoir_invoices($id); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->thirdparty->error); } @@ -1047,14 +1048,14 @@ class Thirdparties extends DolibarrApi { global $db, $conf; - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1063,18 +1064,18 @@ class Thirdparties extends DolibarrApi */ $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE fk_soc = ".$id." "; + $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE fk_soc = ".$id." "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, 'Account not found'); } - $i=0; + $i = 0; $accounts = array(); @@ -1085,13 +1086,13 @@ class Thirdparties extends DolibarrApi { $obj = $db->fetch_object($result); $account = new CompanyBankAccount($db); - if($account->fetch($obj->rowid)) { + if ($account->fetch($obj->rowid)) { $accounts[] = $account; } $i++; } } - else{ + else { throw new RestException(404, 'Account not found'); } @@ -1124,7 +1125,7 @@ class Thirdparties extends DolibarrApi */ public function createCompanyBankAccount($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1132,7 +1133,7 @@ class Thirdparties extends DolibarrApi $account->socid = $id; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1159,7 +1160,7 @@ class Thirdparties extends DolibarrApi */ public function updateCompanyBankAccount($id, $bankaccount_id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1167,12 +1168,12 @@ class Thirdparties extends DolibarrApi $account->fetch($bankaccount_id, $id, -1, ''); - if($account->socid != $id){ + if ($account->socid != $id) { throw new RestException(401); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1194,7 +1195,7 @@ class Thirdparties extends DolibarrApi */ public function deleteCompanyBankAccount($id, $bankaccount_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1202,7 +1203,7 @@ class Thirdparties extends DolibarrApi $account->fetch($bankaccount_id); - if(!$account->socid == $id) + if (!$account->socid == $id) throw new RestException(401); return $account->delete(DolibarrApiAccess::$user); @@ -1222,12 +1223,12 @@ class Thirdparties extends DolibarrApi { global $conf; - $this->langs->loadLangs(array("main","dict","commercial","products","companies","banks","bills","withdrawals")); + $this->langs->loadLangs(array("main", "dict", "commercial", "products", "companies", "banks", "bills", "withdrawals")); $this->company->fetch($id); $action = 'builddoc'; - if(! DolibarrApiAccess::$user->rights->societe->creer) + if (!DolibarrApiAccess::$user->rights->societe->creer) throw new RestException(401); $this->company->setDocModel(DolibarrApiAccess::$user, $model); @@ -1235,32 +1236,32 @@ class Thirdparties extends DolibarrApi $this->company->fk_bank = $this->company->fk_account; $outputlangs = $this->langs; - $newlang=''; + $newlang = ''; - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang; // for thirdparty - if (! empty($newlang)) { + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang = $this->company->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang = $this->company->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined $hidedetails = $hidedesc = $hideref = 0; - $moreparams=null; - if (empty($hidedetails)) $hidedetails=0; - if (empty($hidedesc)) $hidedesc=0; - if (empty($hideref)) $hideref=0; - if (empty($moreparams)) $moreparams=null; + $moreparams = null; + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE fk_soc = ".$id." "; - if ($companybankid) $sql.= " AND id = ".$companybankid.""; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE fk_soc = ".$id." "; + if ($companybankid) $sql .= " AND id = ".$companybankid.""; - $i=0; - $accounts=array(); + $i = 0; + $accounts = array(); $result = $this->db->query($sql); if ($result) @@ -1321,11 +1322,11 @@ class Thirdparties extends DolibarrApi { global $db, $conf; - if(!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(!DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1333,16 +1334,16 @@ class Thirdparties extends DolibarrApi * We select all the records that match the socid */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account"; - $sql.= " WHERE fk_soc = $id"; - if($site) $sql .= " AND site ='$site'"; + $sql .= " WHERE fk_soc = $id"; + if ($site) $sql .= " AND site ='$site'"; $result = $db->query($sql); - if($result->num_rows == 0){ + if ($result->num_rows == 0) { throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.'); } - $i=0; + $i = 0; $accounts = array(); @@ -1352,7 +1353,7 @@ class Thirdparties extends DolibarrApi $obj = $db->fetch_object($result); $account = new SocieteAccount($db); - if($account->fetch($obj->rowid)) { + if ($account->fetch($obj->rowid)) { $accounts[] = $account; } $i++; @@ -1398,25 +1399,25 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - if(!isset($request_data['site'])) { + if (!isset($request_data['site'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the site attribute in your request data !'); } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { $account = new SocieteAccount($this->db); - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } $account->fk_soc = $id; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1457,7 +1458,7 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1465,16 +1466,16 @@ class Thirdparties extends DolibarrApi $result = $db->query($sql); // We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one. - if($result->num_rows == 0 ){ - if(!isset($request_data['key_account'])) { + if ($result->num_rows == 0) { + if (!isset($request_data['key_account'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !'); } $account = new SocieteAccount($this->db); - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1501,13 +1502,13 @@ class Thirdparties extends DolibarrApi $account->id = $obj->rowid; $account->fk_soc = $id; $account->site = $site; - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } $account->fk_user_creat = $obj->fk_user_creat; $account->date_creation = $obj->date_creation; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1539,30 +1540,30 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist."); } else { // If the user tries to edit the site member, we check first if - if(isset($request_data['site']) && $request_data['site'] !== $site) { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; + if (isset($request_data['site']) && $request_data['site'] !== $site) { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; $result = $db->query($sql); - if($result->num_rows !== 0) - throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists for this thirdparty with this site key."); + if ($result->num_rows !== 0) + throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key."); } $obj = $db->fetch_object($result); $account = new SocieteAccount($this->db); $account->fetch($obj->rowid); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1593,21 +1594,21 @@ class Thirdparties extends DolibarrApi global /** @var Database $db */ $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404); } else { $obj = $db->fetch_object($result); $account = new SocieteAccount($this->db); $account->fetch($obj->rowid); - if($account->delete(DolibarrApiAccess::$user) < 0) { + if ($account->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error while deleting $site gateway attached to this third party"); } } @@ -1630,7 +1631,7 @@ class Thirdparties extends DolibarrApi global /** @var Database $db */ $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1639,14 +1640,14 @@ class Thirdparties extends DolibarrApi */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id "; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, 'This third party does not have any gateway attached or does not exist.'); } else { - $i=0; + $i = 0; $num = $db->num_rows($result); while ($i < $num) @@ -1655,7 +1656,7 @@ class Thirdparties extends DolibarrApi $account = new SocieteAccount($db); $account->fetch($obj->rowid); - if($account->delete(DolibarrApiAccess::$user) < 0) { + if ($account->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500, 'Error while deleting gateways attached to this third party'); } $i++; @@ -1722,7 +1723,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param int $rowid Id of third party to load + * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) * @param string $ref_int Internal reference of third party (not used by dolibarr) @@ -1740,6 +1741,7 @@ class Thirdparties extends DolibarrApi */ private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') { + global $conf; if(! DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index d403499a79e..5cfe6fa3709 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -25,7 +25,7 @@ * \brief File of class to manage bank accounts description of third parties */ -require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; /** @@ -81,34 +81,34 @@ class CompanyBankAccount extends Account public function create(User $user = null, $notrigger = 0) { $now = dol_now(); - $error = 0; + $error = 0; // Correct default_rib to be sure to have always one default $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'"; $result = $this->db->query($sql); if ($result) { - $numrows=$this->db->num_rows($result); + $numrows = $this->db->num_rows($result); if ($this->default_rib && $numrows > 0) $this->default_rib = 0; if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1; } $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)"; - $sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')"; - $resql=$this->db->query($sql); + $sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')"; + $resql = $this->db->query($sql); if ($resql) { if ($this->db->affected_rows($resql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('COMPANY_RIB_CREATE', $user); + $result = $this->call_trigger('COMPANY_RIB_CREATE', $user); if ($result < 0) $error++; // End call triggers - if (! $error) + if (!$error) { return 1; } @@ -215,14 +215,14 @@ class CompanyBankAccount extends Account if (empty($id) && empty($socid)) return -1; $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE rowid = ".$id; + $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE rowid = ".$id; if ($socid) { - $sql.= " WHERE fk_soc = ".$socid; - if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default); - if ($type) $sql.= " AND type ='".$this->db->escape($type)."'"; + $sql .= " WHERE fk_soc = ".$socid; + if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default); + if ($type) $sql .= " AND type ='".$this->db->escape($type)."'"; } $resql = $this->db->query($sql); @@ -232,10 +232,10 @@ class CompanyBankAccount extends Account { $obj = $this->db->fetch_object($resql); - $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref + $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref - $this->id = $obj->rowid; - $this->type = $obj->type; + $this->id = $obj->rowid; + $this->type = $obj->type; $this->socid = $obj->fk_soc; $this->bank = $obj->bank; $this->code_banque = $obj->code_banque; @@ -243,7 +243,7 @@ class CompanyBankAccount extends Account $this->number = $obj->number; $this->cle_rib = $obj->cle_rib; $this->bic = $obj->bic; - $this->iban = $obj->iban; + $this->iban = $obj->iban; $this->domiciliation = $obj->domiciliation; $this->proprio = $obj->proprio; $this->owner_address = $obj->owner_address; @@ -279,31 +279,31 @@ class CompanyBankAccount extends Account $error = 0; - dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG); + dol_syslog(get_class($this)."::delete ".$this->id, LOG_DEBUG); $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('COMPANY_RIB_DELETE', $user); + $result = $this->call_trigger('COMPANY_RIB_DELETE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib"; - $sql .= " WHERE rowid = " . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib"; + $sql .= " WHERE rowid = ".$this->id; - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -311,7 +311,7 @@ class CompanyBankAccount extends Account else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -325,7 +325,7 @@ class CompanyBankAccount extends Account { $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) { + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic) { if ($this->label && $displayriblabel) { $rib = $this->label." : "; } @@ -345,7 +345,7 @@ class CompanyBankAccount extends Account public function setAsDefault($rib = 0) { $sql1 = "SELECT rowid as id, fk_soc FROM ".MAIN_DB_PREFIX."societe_rib"; - $sql1.= " WHERE rowid = ".($rib?$rib:$this->id); + $sql1 .= " WHERE rowid = ".($rib ? $rib : $this->id); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result1 = $this->db->query($sql1); @@ -362,12 +362,12 @@ class CompanyBankAccount extends Account $this->db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0"; - $sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc; + $sql2 .= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result2 = $this->db->query($sql2); $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; - $sql3.= " WHERE rowid = ".$obj->id; + $sql3 .= " WHERE rowid = ".$obj->id; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result3 = $this->db->query($sql3); diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 0fe4c450fad..4692687220a 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -102,19 +102,19 @@ $stripeacc = $stripe->getStripeAccount($service); }*/ // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('paiementcard','globalcard')); +$hookmanager->initHooks(array('paiementcard', 'globalcard')); /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; @@ -125,7 +125,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); + $tmpinvoice = new Facture($db); foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_') @@ -133,16 +133,16 @@ if (empty($reshook)) $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); if ($amounts[$cursorfacid]) { // Check amount if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -154,23 +154,23 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); + $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); if ($multicurrency_amounts[$cursorfacid]) { // Check amount if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -182,7 +182,7 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => GETPOST($key, 'int')); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); } } @@ -193,7 +193,7 @@ if (empty($reshook)) $error++; }*/ - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // If bank module is on, account is required to enter a payment if (GETPOST('accountid') <= 0) @@ -242,7 +242,7 @@ if (empty($reshook)) */ if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error=0; + $error = 0; $datepaye = dol_now(); @@ -264,7 +264,7 @@ if (empty($reshook)) } } - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement if (GETPOST('accountid') <= 0) @@ -282,34 +282,34 @@ if (empty($reshook)) if (is_object($stripe) && $stripeacc) { - $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); if ($customerstripe->id) { - $listofsources=$customerstripe->sources->data; + $listofsources = $customerstripe->sources->data; } } - $stripeamount=0; + $stripeamount = 0; foreach ($amounts as $key => $value) // How payment is dispatch { - $stripeamount+=price2num($value, 'MT'); + $stripeamount += price2num($value, 'MT'); } if (preg_match('/acct_/i', $source)) { - $paiementcode ="VIR"; + $paiementcode = "VIR"; } elseif (preg_match('/card_/i', $source)) { - $paiementcode ="CB"; + $paiementcode = "CB"; } elseif (preg_match('/src_/i', $source)) { - $customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customer2 = $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); $src = $customer2->sources->retrieve("$source"); - if ($src->type=='card') + if ($src->type == 'card') { - $paiementcode ="CB"; + $paiementcode = "CB"; } } @@ -319,17 +319,17 @@ if (empty($reshook)) $societe->fetch($facture->socid); dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); - $stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_... + $stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_... - $charge=$stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus); + $charge = $stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus); if (!$error) { // Creation of payment line $paiement = new Paiement($db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->amounts = $amounts; // Array with all payments dispatching + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db, $paiementcode, 'c_paiement'); $paiement->num_paiement = $charge->message; $paiement->note = GETPOST('comment'); @@ -337,7 +337,7 @@ if (empty($reshook)) $paiement->ext_payment_site = $service; } - if (! $error) + if (!$error) { $paiement_id = $paiement->create($user, 0); if ($paiement_id < 0) @@ -351,45 +351,45 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $facture->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$facture->modelpdf; + $model = $facture->modelpdf; $ret = $facture->fetch($facid); // Reload to get new records $facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - if (! $error) + if (!$error) { - $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; - $result=$paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', ''); + $label = '(CustomerInvoicePayment)'; + if (GETPOST('type') == 2) $label = '(CustomerInvoicePaymentBack)'; + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', ''); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; } - elseif (GETPOST('closepaidinvoices')=='on') { + elseif (GETPOST('closepaidinvoices') == 'on') { $facture->set_paid($user); } } - if (! $error) + if (!$error) { $db->commit(); // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid=0; + $invoiceid = 0; foreach ($paiement->amounts as $key => $amount) { $facid = $key; if (is_numeric($amount) && $amount <> 0) { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment + else $invoiceid = $facid; } } if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; @@ -417,39 +417,39 @@ $form = new Form($db); llxHeader(); -if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) { +if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; $servicestatus = 0; } else { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } -if (GETPOST('error')){ +if (GETPOST('error')) { setEventMessages(GETPOST('error'), null, 'errors'); } if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { $facture = new Facture($db); - $result=$facture->fetch($facid); + $result = $facture->fetch($facid); if ($result >= 0) { $facture->fetch_thirdparty(); - $title=''; - if ($facture->type != 2) $title.=$langs->trans("EnterPaymentReceivedFromCustomer"); - if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer"); + $title = ''; + if ($facture->type != 2) $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); + if ($facture->type == 2) $title .= $langs->trans("EnterPaymentDueToCustomer"); print load_fiche_titre($title); // Initialize data for confirmation (this is used because data can be change during confirmation) if ($action == 'add_paiement') { - $i=0; + $i = 0; - $formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id); - $formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid); - $formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type); } @@ -544,7 +544,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie '; print ' });'."\n"; - if (!empty($conf->use_javascript_ajax)){ + if (!empty($conf->use_javascript_ajax)) { //Add js for AutoFill print ' $(document).ready(function () {'; print ' $(".AutoFillAmout").on(\'click touchstart\', function(){ @@ -577,7 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '\n"; // Bank account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { //$form->select_comptes($accountid,'accountid',0,'',2); print ''; @@ -615,7 +615,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie dol_fiche_end(); - $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); print '
'; print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); @@ -632,62 +632,62 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; print ''; // Default print ''; @@ -711,32 +711,32 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // $account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid).""); //} - if (($account->type=='custom' or $account->type=='express') && $entity==1) { + if (($account->type == 'custom' or $account->type == 'express') && $entity == 1) { print ''; print ''; print ''; // Default print ''; print ''; } - if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) { + if (empty($input) && !$stripe->getStripeCustomerAccount($facture->socid)) { print ''; } @@ -768,33 +768,33 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie */ $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, '; - $sql.= ' f.datef as df, f.fk_soc as socid'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' f.datef as df, f.fk_soc as socid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; } - $sql.= ' WHERE f.entity IN ('.getEntity('invoice').")"; - $sql.= ' AND (f.fk_soc = '.$facture->socid; + $sql .= ' WHERE f.entity IN ('.getEntity('invoice').")"; + $sql .= ' AND (f.fk_soc = '.$facture->socid; if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { - $sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; + $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; } - $sql.= ') AND f.paye = 0'; - $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled + $sql .= ') AND f.paye = 0'; + $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled if ($facture->type != 2) { - $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation + $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation } else { - $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes + $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes } // Sort invoices by date and serial number: the older one comes first - $sql.=' ORDER BY f.datef ASC, f.ref ASC'; + $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; $resql = $db->query($sql); if ($resql) @@ -802,17 +802,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $num = $db->num_rows($resql); if ($num > 0) { - $sign=1; - if ($facture->type == 2) $sign=-1; + $sign = 1; + if ($facture->type == 2) $sign = -1; - $arraytitle=$langs->trans('Invoice'); - if ($facture->type == 2) $arraytitle=$langs->trans("CreditNotes"); - $alreadypayedlabel=$langs->trans('Received'); - $multicurrencyalreadypayedlabel=$langs->trans('MulticurrencyReceived'); - if ($facture->type == 2) { $alreadypayedlabel=$langs->trans("PaidBack"); $multicurrencyalreadypayedlabel=$langs->trans("MulticurrencyPaidBack"); } - $remaindertopay=$langs->trans('RemainderToTake'); - $multicurrencyremaindertopay=$langs->trans('MulticurrencyRemainderToTake'); - if ($facture->type == 2) { $remaindertopay=$langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay=$langs->trans("MulticurrencyRemainderToPayBack"); } + $arraytitle = $langs->trans('Invoice'); + if ($facture->type == 2) $arraytitle = $langs->trans("CreditNotes"); + $alreadypayedlabel = $langs->trans('Received'); + $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived'); + if ($facture->type == 2) { $alreadypayedlabel = $langs->trans("PaidBack"); $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); } + $remaindertopay = $langs->trans('RemainderToTake'); + $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake'); + if ($facture->type == 2) { $remaindertopay = $langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); } $i = 0; @@ -838,17 +838,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; } - $tmpinvoice =new Facture($db); - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook + $tmpinvoice = new Facture($db); + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook print ''; print "\n"; - $total=0; - $totalrecu=0; - $totalrecucreditnote=0; - $totalrecudeposits=0; + $total = 0; + $totalrecu = 0; + $totalrecucreditnote = 0; + $totalrecudeposits = 0; while ($i < $num) { @@ -857,29 +857,29 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $soc = new Societe($db); $soc->fetch($objp->socid); - $invoice=new Facture($db); + $invoice = new Facture($db); $invoice->fetch($objp->facid); $paiement = $invoice->getSommePaiement(); - $creditnotes=$invoice->getSumCreditNotesUsed(); - $deposits=$invoice->getSumDepositsUsed(); - $alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); + $creditnotes = $invoice->getSumCreditNotesUsed(); + $deposits = $invoice->getSumDepositsUsed(); + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); // Multicurrency Price if (!empty($conf->multicurrency->enabled)) { $multicurrency_payment = $invoice->getSommePaiement(1); - $multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1); - $multicurrency_deposits=$invoice->getSumDepositsUsed(1); - $multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT'); - $multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); + $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1); + $multicurrency_deposits = $invoice->getSumDepositsUsed(1); + $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT'); + $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); } print ''; print '\n"; // Date @@ -946,7 +946,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ""; // Multicurrency Price - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '"; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook // Warning print '\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$paiement; - $totalrecucreditnote+=$creditnotes; - $totalrecudeposits+=$deposits; + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $paiement; + $totalrecucreditnote += $creditnotes; + $totalrecudeposits += $deposits; $i++; } if ($i > 1) { - $amount=round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT'))*100); + $amount = round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')) * 100); // Print total print ''; @@ -1033,10 +1033,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Bouton Enregistrer if ($action != 'add_paiement') { - $checkboxlabel=$langs->trans("ClosePaidInvoicesAutomatically"); - if ($facture->type == 2) $checkboxlabel=$langs->trans("ClosePaidCreditNotesAutomatically"); - $buttontitle=$langs->trans('ToMakePayment'); - if ($facture->type == 2) $buttontitle=$langs->trans('ToMakePaymentBack'); + $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically"); + if ($facture->type == 2) $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically"); + $buttontitle = $langs->trans('ToMakePayment'); + if ($facture->type == 2) $buttontitle = $langs->trans('ToMakePaymentBack'); print '
'; print ' '.$checkboxlabel; @@ -1052,18 +1052,18 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Form to confirm payment if ($action == 'add_paiement') { - $preselectedchoice=$addwarning?'no':'yes'; + $preselectedchoice = $addwarning ? 'no' : 'yes'; print '
'; if (!empty($totalpayment)) { $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency)); } if (!empty($multicurrency_totalpayment)) { - $text.='
'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); + $text .= '
'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); } if (GETPOST('closepaidinvoices')) { - $text.='
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); + $text .= '
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); print ''; } print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); @@ -1078,27 +1078,27 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie * Show list of payments */ -if (! GETPOST('action')) +if (!GETPOST('action')) { - if ($page == -1 || empty($page)) $page = 0 ; - $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; - $offset = $limit * $page ; + if ($page == -1 || empty($page)) $page = 0; + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; + $offset = $limit * $page; - if (! $sortorder) $sortorder='DESC'; - if (! $sortfield) $sortfield='p.datep'; + if (!$sortorder) $sortorder = 'DESC'; + if (!$sortfield) $sortfield = 'p.datep'; $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref'; - $sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; - $sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; - $sql.= ' AND f.entity IN ('.getEntity('invoice').")"; + $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; + $sql .= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; + $sql .= ' AND f.entity IN ('.getEntity('invoice').")"; if ($socid) { - $sql.= ' AND f.fk_soc = '.$socid; + $sql .= ' AND f.fk_soc = '.$socid; } - $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; - $sql.= $db->plimit($limit+1, $offset); + $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; + $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -1115,8 +1115,8 @@ if (! GETPOST('action')) print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right '); $tmpobject = new Paiement($db); - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "
\n"; @@ -1131,8 +1131,8 @@ if (! GETPOST('action')) print '\n"; print ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook print ''; print ''; diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 791ceda79eb..2815b1ac5a9 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -77,25 +77,25 @@ $stripeacc = $stripe->getStripeAccount($service); print $langs->trans('ErrorStripeAccountNotDefined'); }*/ -if (! $rowid) { - print ''; +if (!$rowid) { + print ''; if ($optioncss != '') { - print ''; + print ''; } - print ''; + print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - $title=$langs->trans("StripePayoutList"); - $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'); + $title = $langs->trans("StripePayoutList"); + $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); print '
'; - print '
'.$langs->trans("ThisIsInformationOnDocumentToSign").' :
'.$langs->trans("Creditor"); - print ''.$creditor.''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; print ''; print '
'.$langs->trans("ThirdParty"); - print ''.$proposal->thirdparty->name.''; + print '
'.$langs->trans("ThirdParty"); + print ''.$proposal->thirdparty->name.''; // Object - $text=''.$langs->trans("SignatureProposalRef", $proposal->ref).''; - print '
'.$langs->trans("Designation"); - print ''.$text; + $text = ''.$langs->trans("SignatureProposalRef", $proposal->ref).''; + print '
'.$langs->trans("Designation"); + print ''.$text; print ''; print ''; print '

'.$mesg.'
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print ' disabled'; - } elseif (($customerstripe->default_source==$src->id && $action != 'add_paiement') or ($source==$src->id && $action == 'add_paiement')) { + } elseif (($customerstripe->default_source == $src->id && $action != 'add_paiement') or ($source == $src->id && $action == 'add_paiement')) { print ' checked'; } print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print' >'; - if ($src->object=='card') { + if ($src->object == 'card') { print img_credit_card($src->brand); - } elseif ($src->object=='source' && $src->type=='card') { + } elseif ($src->object == 'source' && $src->type == 'card') { print img_credit_card($src->card->brand); - } elseif ($src->object=='source' && $src->type=='sepa_debit') { + } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print ''; } print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print' >'; - if ($src->object=='card') { + if ($src->object == 'card') { print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; print ''; if ($src->country) { $img = picto_from_langcode($src->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - } elseif ($src->object=='source' && $src->type=='card') { + } elseif ($src->object == 'source' && $src->type == 'card') { print $src->owner->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; print '
'; if ($src->card->country) { $img = picto_from_langcode($src->card->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->card->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - } elseif ($src->object=='source' && $src->type=='sepa_debit') { + } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print 'info sepa'; print ''; if ($src->sepa_debit->country) { $img = picto_from_langcode($src->sepa_debit->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->sepa_debit->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -696,11 +696,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print'>'; - if (($customerstripe->default_source==$src->id)) { + if (($customerstripe->default_source == $src->id)) { print ""; } print '
getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print'>global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { + if ((empty($input) && $action != 'add_paiement') or ($source == $conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { print ' checked'; - } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) { + } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT != $source) { print ' disabled'; } print '>getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print '>getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print'>'.$langs->trans('sold'); print'id!=$source) { + if ($action == 'add_paiement' && $src->id != $source) { print'class="opacitymedium"'; } print'>'; @@ -744,7 +744,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print 'id!=$source) { + if ($action == 'add_paiement' && $src->id != $source) { print'class="opacitymedium"'; } print'>'; @@ -756,7 +756,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'.$langs->trans("None").'
'.$langs->trans('MulticurrencyPaymentAmount').' 
'; print $invoice->getNomUrl(1, ''); - if($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; + if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; print "'; @@ -972,8 +972,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "'; @@ -987,16 +987,16 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "
'.$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount).' 
' . "\n"; + print '
'."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 906d7768bd4..6a0067bf220 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -77,24 +77,24 @@ $stripeacc = $stripe->getStripeAccount($service); print $langs->trans('ErrorStripeAccountNotDefined'); }*/ -if (! $rowid) { - print ''; +if (!$rowid) { + print ''; if ($optioncss != '') - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - $title=$langs->trans("StripeTransactionList"); - $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'); + $title = $langs->trans("StripeTransactionList"); + $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); print '
'; - print '
' . "\n"; + print '
'."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index ee936015352..d1a0c3775a0 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -23,7 +23,7 @@ * \brief Setup page for TakePos module */ -require '../../main.inc.php'; // Load $user and permissions +require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; @@ -49,9 +49,9 @@ if (GETPOST('action', 'alpha') == 'set') dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -68,12 +68,12 @@ if (GETPOST('action', 'alpha') == 'set') * View */ -$form=new Form($db); -$formproduct=new FormProduct($db); +$form = new Form($db); +$formproduct = new FormProduct($db); llxHeader('', $langs->trans("CashDeskSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup'); $head = takepos_prepare_head(); dol_fiche_head($head, 'receipt', 'TakePOS', -1); @@ -81,7 +81,7 @@ print '
'; // Mode -print ''; +print ''; print ''; print ''; @@ -90,16 +90,16 @@ print ''; print ''; print "\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print '\n"; @@ -115,7 +115,7 @@ print "\n"; print '\n"; print ''; // Customer information diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 947cee547b0..5995489184d 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -22,7 +22,7 @@ * \brief Setup page for TakePos module */ -require '../../main.inc.php'; // Load $user and permissions +require '../../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; // If socid provided by ajax company selector -if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) +if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) { $_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); $_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha'); @@ -62,7 +62,7 @@ if ($resql) { if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - if (GETPOST('socid', 'int') < 0) $_POST["socid"]=''; + if (GETPOST('socid', 'int') < 0) $_POST["socid"] = ''; $res = dolibarr_set_const($db, "CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ROOT_CATEGORY_ID", GETPOST('TAKEPOS_ROOT_CATEGORY_ID', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -135,12 +135,12 @@ print "\n"; print '\n"; // Services -if (! empty($conf->service->enabled)) +if (!empty($conf->service->enabled)) { print '\n"; print '\n"; // Direct Payment diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php index 2bd21626f34..5d0346a495c 100644 --- a/htdocs/takepos/phone.php +++ b/htdocs/takepos/phone.php @@ -25,37 +25,37 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -require '../main.inc.php'; // Load $user and permissions +require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant $action = GETPOST('action', 'alpha'); $setterminal = GETPOST('setterminal', 'int'); -if ($setterminal>0) +if ($setterminal > 0) { - $_SESSION["takeposterminal"]=$setterminal; + $_SESSION["takeposterminal"] = $setterminal; } -$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter")); +$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter")); /* * View */ // Title -$title='TakePOS - Dolibarr '.DOL_VERSION; -if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; -$head=' +$title = 'TakePOS - Dolibarr '.DOL_VERSION; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; +$head = ''; @@ -66,14 +66,14 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; print '
'; -$variablename='TAKEPOS_HEADER'; +$variablename = 'TAKEPOS_HEADER'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -107,7 +107,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print "
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; print '
'; -$variablename='TAKEPOS_FOOTER'; +$variablename = 'TAKEPOS_FOOTER'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -123,13 +123,13 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print "
'; -print ''; +print ''; print '
'; print $langs->trans("NumberOfTerminals"); print ''; -$array=array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6", 7=>"7", 8=>"8", 9=>"9"); -print $form->selectarray('TAKEPOS_NUM_TERMINALS', $array, (empty($conf->global->TAKEPOS_NUM_TERMINALS)?'0':$conf->global->TAKEPOS_NUM_TERMINALS), 0); +$array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6", 7=>"7", 8=>"8", 9=>"9"); +print $form->selectarray('TAKEPOS_NUM_TERMINALS', $array, (empty($conf->global->TAKEPOS_NUM_TERMINALS) ? '0' : $conf->global->TAKEPOS_NUM_TERMINALS), 0); print "
'; print $langs->trans("CashdeskShowServices"); @@ -230,8 +230,8 @@ print "
'; print $langs->trans("Paymentnumpad"); print ''; -$array=array(0=>$langs->trans("Numberspad"), 1=>$langs->trans("BillsCoinsPad")); -print $form->selectarray('TAKEPOS_NUMPAD', $array, (empty($conf->global->TAKEPOS_NUMPAD)?'0':$conf->global->TAKEPOS_NUMPAD), 0); +$array = array(0=>$langs->trans("Numberspad"), 1=>$langs->trans("BillsCoinsPad")); +print $form->selectarray('TAKEPOS_NUMPAD', $array, (empty($conf->global->TAKEPOS_NUMPAD) ? '0' : $conf->global->TAKEPOS_NUMPAD), 0); print "