diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index 5658bf8ad0a..bfb81e8d5c4 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -30,27 +30,27 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","members","ldap")); +$langs->loadLangs(array("admin", "members", "ldap")); $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'alpha'); // Security check -$result=restrictedArea($user, 'adherent', $id, 'adherent_type'); +$result = restrictedArea($user, 'adherent', $id, 'adherent_type'); $object = new AdherentType($db); $object->fetch($id); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('membertypeldapcard','globalcard')); +$hookmanager->initHooks(array('membertypeldapcard', 'globalcard')); /* * Actions */ -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -66,7 +66,7 @@ if (empty($reshook)) $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); - $olddn = $dn; // We can say that old dn = dn as we force synchro + $olddn = $dn; // We can say that old dn = dn as we force synchro $result = $ldap->update($dn, $info, $user, $olddn); } @@ -148,12 +148,12 @@ print ''.$langs->trans("Value").''; print ''; // LDAP reading -$ldap=new Ldap(); -$result=$ldap->connect_bind(); +$ldap = new Ldap(); +$result = $ldap->connect_bind(); if ($result > 0) { - $info=$object->_load_ldap_info(); - $dn=$object->_load_ldap_dn($info, 1); + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; $records = $ldap->getAttribute($dn, $search); @@ -161,15 +161,15 @@ if ($result > 0) //print_r($records); // Show tree - if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (! is_array($records)) + if (!is_array($records)) { print ''.$langs->trans("ErrorFailedToReadLDAP").''; } else { - $result=show_ldap_content($records, 0, $records['count'], true); + $result = show_ldap_content($records, 0, $records['count'], true); } } else diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4e77cd09f39..4dce2533bdc 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -22,7 +22,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -86,9 +86,9 @@ class BOM extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), @@ -158,7 +158,7 @@ class BOM extends CommonObject /** * @var array List of child tables. To know object to delete on cascade. */ - protected $childtablesoncascade=array('bom_bomline'); + protected $childtablesoncascade = array('bom_bomline'); /** * @var BOMLine[] Array of subtable lines @@ -178,11 +178,11 @@ class BOM extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -191,13 +191,13 @@ class BOM extends CommonObject } // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -237,7 +237,7 @@ class BOM extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); // Get lines so they will be clone //foreach($object->lines as $line) @@ -249,18 +249,18 @@ class BOM extends CommonObject unset($object->import_key); // Clear fields - $object->ref = empty($this->fields['ref']['default']) ? $langs->trans("copy_of_").$object->ref: $this->fields['ref']['default']; - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->ref = empty($this->fields['ref']['default']) ? $langs->trans("copy_of_").$object->ref : $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($object->table_element); - foreach($object->array_options as $key => $option) + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); @@ -277,7 +277,7 @@ class BOM extends CommonObject $this->errors = $object->errors; } - if (! $error) + if (!$error) { // copy internal contacts if ($this->copy_linked_contact($object, 'internal') < 0) @@ -286,7 +286,7 @@ class BOM extends CommonObject } } - if (! $error) + if (!$error) { // copy external contacts if same company if (property_exists($this, 'socid') && $this->socid == $object->socid) @@ -322,7 +322,7 @@ class BOM extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -333,7 +333,7 @@ class BOM extends CommonObject */ public function fetchLines() { - $this->lines=array(); + $this->lines = array(); $result = $this->fetchLinesCommon(); return $result; @@ -356,40 +356,40 @@ class BOM extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); + $records = array(); $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($this->ismultientitymanaged) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid') { - $sqlwhere[] = $key . '='. $value; + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } - elseif ($key=='customsql') { + elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -407,8 +407,8 @@ class BOM extends CommonObject return $records; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -472,21 +472,21 @@ class BOM extends CommonObject global $langs, $conf; $langs->load("mrp"); - if (! empty($conf->global->BOM_ADDON)) + if (!empty($conf->global->BOM_ADDON)) { - $mybool=false; + $mybool = false; $file = $conf->global->BOM_ADDON.".php"; $classname = $conf->global->BOM_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/bom/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } if ($mybool === false) @@ -504,7 +504,7 @@ class BOM extends CommonObject } else { - $this->error=$obj->error; + $this->error = $obj->error; //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } @@ -529,7 +529,7 @@ class BOM extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; // Protection if ($this->statut == self::STATUS_VALIDATED) @@ -546,12 +546,12 @@ class BOM extends CommonObject return -1; }*/ - $now=dol_now(); + $now = dol_now(); $this->db->begin(); // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $this->fetch_product(); $num = $this->getNextNumRef($this->product); @@ -564,30 +564,30 @@ class BOM extends CommonObject // Validate $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->db->escape($num)."',"; - $sql.= " status = ".self::STATUS_VALIDATED.","; - $sql.= " date_valid='".$this->db->idate($now)."',"; - $sql.= " fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED.","; + $sql .= " date_valid='".$this->db->idate($now)."',"; + $sql .= " fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate()", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { dol_print_error($this->db); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BOM_VALIDATE', $user); + $result = $this->call_trigger('BOM_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -595,17 +595,17 @@ class BOM extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'bom/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'bom/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'bom/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->bom->dir_output.'/'.$oldref; $dirdest = $conf->bom->dir_output.'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); @@ -613,13 +613,13 @@ class BOM extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->bom->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->bom->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -628,13 +628,13 @@ class BOM extends CommonObject } // Set new ref and current status - if (! $error) + if (!$error) { $this->ref = $num; $this->status = self::STATUS_VALIDATED; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -738,34 +738,34 @@ class BOM extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("BillOfMaterials") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("BillOfMaterials").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/bom/bom_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowBillOfMaterials"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowBillOfMaterials"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('bomdao')); @@ -774,22 +774,22 @@ class BOM extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('bomdao')); - $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; @@ -842,10 +842,10 @@ class BOM extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -856,7 +856,7 @@ class BOM 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_valid) @@ -870,7 +870,7 @@ class BOM extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -893,7 +893,7 @@ class BOM extends CommonObject */ public function getLinesArray() { - $this->lines=array(); + $this->lines = array(); $objectline = new BOMLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_bom = '.$this->id)); @@ -924,16 +924,16 @@ class BOM extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("mrp"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'standard'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->BOM_ADDON_PDF)) { + } elseif (!empty($conf->global->BOM_ADDON_PDF)) { $modele = $conf->global->BOM_ADDON_PDF; } } @@ -972,7 +972,7 @@ class BOM extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; dol_syslog(__METHOD__, LOG_DEBUG); @@ -1043,7 +1043,7 @@ class BOMLine extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'LineID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1,), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), @@ -1079,11 +1079,11 @@ class BOMLine extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -1092,13 +1092,13 @@ class BOMLine extends CommonObject } // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -1149,40 +1149,40 @@ class BOMLine extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); + $records = array(); $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($this->ismultientitymanaged) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid') { - $sqlwhere[] = $key . '='. $value; + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } - elseif ($key=='customsql') { + elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -1200,8 +1200,8 @@ class BOMLine extends CommonObject return $records; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -1248,34 +1248,34 @@ class BOMLine extends CommonObject { global $db, $conf, $langs, $hookmanager; - 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("BillOfMaterialsLine") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("BillOfMaterialsLine").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/bom/bomline_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowBillOfMaterialsLine"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowBillOfMaterialsLine"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('bomlinedao')); @@ -1284,22 +1284,22 @@ class BOMLine extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('bomlinedao')); - $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; @@ -1340,10 +1340,10 @@ class BOMLine extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -1354,7 +1354,7 @@ class BOMLine 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_valid) @@ -1368,7 +1368,7 @@ class BOMLine extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 391d4df5cb5..ce582040ac9 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -29,14 +29,14 @@ // $upload_dir must be defined (example $conf->projet->dir_output . "/";) // $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not. -if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $permissioncreate; // For backward compatibility +if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $permissioncreate; // For backward compatibility // Build doc if ($action == 'builddoc' && $permissiontoadd) { if (is_numeric(GETPOST('model', 'alpha'))) { - $error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); + $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); } else { @@ -61,34 +61,34 @@ if ($action == 'builddoc' && $permissiontoadd) if (GETPOST('fk_bank', 'int')) { // this field may come from an external module $object->fk_bank = GETPOST('fk_bank', 'int'); - } elseif (! empty($object->fk_account)) { + } elseif (!empty($object->fk_account)) { $object->fk_bank = $object->fk_account; } //} $outputlangs = $langs; - $newlang=''; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang=$object->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang=$object->default_lang; // for thirdparty - if (! empty($newlang)) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined - if (empty($hidedetails)) $hidedetails=0; - if (empty($hidedesc)) $hidedesc=0; - if (empty($hideref)) $hideref=0; - if (empty($moreparams)) $moreparams=null; + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result= $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } else { @@ -98,7 +98,7 @@ if ($action == 'builddoc' && $permissiontoadd) $urltoredirect = $_SERVER['REQUEST_URI']; $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop + $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop header('Location: '.$urltoredirect.'#builddoc'); exit; @@ -110,10 +110,10 @@ if ($action == 'builddoc' && $permissiontoadd) // Delete file in doc form if ($action == 'remove_file' && $permissiontoadd) { - if (! empty($upload_dir)) { + if (!empty($upload_dir)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (empty($object->id) || ! $object->id > 0) + if (empty($object->id) || !$object->id > 0) { // Reload to get all modified line records and be ready for hooks $ret = $object->fetch($id); @@ -121,9 +121,9 @@ if ($action == 'remove_file' && $permissiontoadd) } $langs->load("other"); - $filetodelete=GETPOST('file', 'alpha'); - $file = $upload_dir . '/' . $filetodelete; - $ret=dol_delete_file($file, 0, 0, 0, $object); + $filetodelete = GETPOST('file', 'alpha'); + $file = $upload_dir.'/'.$filetodelete; + $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 54a2c5825b4..e0a30c271a2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -37,7 +37,7 @@ * This file contains all frequently used functions. */ -include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; /** @@ -53,10 +53,10 @@ include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php'; */ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) { - require_once DOL_DOCUMENT_ROOT ."/core/db/".$type.'.class.php'; + require_once DOL_DOCUMENT_ROOT."/core/db/".$type.'.class.php'; - $class='DoliDB'.ucfirst($type); - $dolidb=new $class($type, $host, $user, $pass, $name, $port); + $class = 'DoliDB'.ucfirst($type); + $dolidb = new $class($type, $host, $user, $pass, $name, $port); return $dolidb; } @@ -87,10 +87,10 @@ function getEntity($element, $shared = 1, $currentobject = null) } else { - $out=''; + $out = ''; $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values'); - if (in_array($element, $addzero)) $out.= '0,'; - $out.= $conf->entity; + if (in_array($element, $addzero)) $out .= '0,'; + $out .= $conf->entity; return $out; } } @@ -135,9 +135,9 @@ function getBrowserInfo($user_agent) { include_once DOL_DOCUMENT_ROOT.'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php'; - $name='unknown'; - $version=''; - $os='unknown'; + $name = 'unknown'; + $version = ''; + $os = 'unknown'; $phone = ''; $detectmobile = new Mobile_Detect(null, $user_agent); @@ -168,22 +168,22 @@ function getBrowserInfo($user_agent) } // OS - if (preg_match('/linux/i', $user_agent)) { $os='linux'; } - elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; } - elseif (preg_match('/windows/i', $user_agent)) { $os='windows'; } + if (preg_match('/linux/i', $user_agent)) { $os = 'linux'; } + elseif (preg_match('/macintosh/i', $user_agent)) { $os = 'macintosh'; } + elseif (preg_match('/windows/i', $user_agent)) { $os = 'windows'; } // Name - if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; } - elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='edge'; $version=$reg[2]; } - elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name='chrome'; $version=$reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string - elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name='chrome'; } - elseif (preg_match('/iceweasel/i', $user_agent)) { $name='iceweasel'; } - elseif (preg_match('/epiphany/i', $user_agent)) { $name='epiphany'; } - elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not. - elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; } - elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end - elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end - elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; } + if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'firefox'; $version = $reg[2]; } + elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'edge'; $version = $reg[2]; } + elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name = 'chrome'; $version = $reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string + elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name = 'chrome'; } + elseif (preg_match('/iceweasel/i', $user_agent)) { $name = 'iceweasel'; } + elseif (preg_match('/epiphany/i', $user_agent)) { $name = 'epiphany'; } + elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'safari'; $version = $reg[2]; } // Safari is often present in string for mobile but its not. + elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name = 'opera'; $version = $reg[2]; } + elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end + elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name = 'ie'; $version = end($reg); } // MS products at end + elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name = 'lynxlinks'; $version = $reg[4]; } if ($tablet) { $layout = 'tablet'; @@ -210,10 +210,10 @@ function getBrowserInfo($user_agent) */ function dol_shutdown() { - global $conf,$user,$langs,$db; - $disconnectdone=false; $depth=0; - if (is_object($db) && ! empty($db->connected)) { $depth=$db->transaction_opened; $disconnectdone=$db->close(); } - dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth)?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), (($disconnectdone && $depth)?LOG_WARNING:LOG_INFO)); + global $conf, $user, $langs, $db; + $disconnectdone = false; $depth = 0; + if (is_object($db) && !empty($db->connected)) { $depth = $db->transaction_opened; $disconnectdone = $db->close(); } + dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ?LOG_WARNING:LOG_INFO)); } /** @@ -253,7 +253,7 @@ function GETPOSTISSET($paramname) */ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $options = null, $noreplace = 0) { - global $mysoc,$user,$conf; + global $mysoc, $user, $conf; if (empty($paramname)) return 'BadFirstParameterForGETPOST'; if (empty($check)) @@ -263,10 +263,10 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti //var_dump(debug_backtrace()[0]); } - if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); - elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; - elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:''; - elseif ($method==3) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:''); + if (empty($method)) $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); + elseif ($method == 1) $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; + elseif ($method == 2) $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; + elseif ($method == 3) $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); else return 'BadThirdParameterForGETPOST'; if (empty($method) || $method == 3 || $method == 4) @@ -281,41 +281,41 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti // Code for search criteria persistence. // Retrieve values if restore_lastsearch_values - if (! empty($_GET['restore_lastsearch_values'])) // Use $_GET here and not GETPOST + if (!empty($_GET['restore_lastsearch_values'])) // Use $_GET here and not GETPOST { - if (! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // If there is saved values + if (!empty($_SESSION['lastsearch_values_'.$relativepathstring])) // If there is saved values { - $tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); + $tmp = json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); if (is_array($tmp)) { - foreach($tmp as $key => $val) + foreach ($tmp as $key => $val) { if ($key == $paramname) // We are on the requested parameter { - $out=$val; + $out = $val; break; } } } } // If there is saved contextpage, page or limit - if ($paramname == 'contextpage' && ! empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) + if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) { $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring]; } - elseif ($paramname == 'page' && ! empty($_SESSION['lastsearch_page_'.$relativepathstring])) + elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_'.$relativepathstring])) { $out = $_SESSION['lastsearch_page_'.$relativepathstring]; } - elseif ($paramname == 'limit' && ! empty($_SESSION['lastsearch_limit_'.$relativepathstring])) + elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_'.$relativepathstring])) { $out = $_SESSION['lastsearch_limit_'.$relativepathstring]; } } // Else, retreive default values if we are not doing a sort - elseif (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set + elseif (!isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set { - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (!empty($_GET['action']) && $_GET['action'] == 'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { // Search default value from $object->field global $object; @@ -324,28 +324,28 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti $out = $object->fields[$paramname]['default']; } } - if (! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) + if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { - if (! empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (!empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { // Now search in setup to overwrite default values - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' + if (!empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' { if (isset($user->default_values[$relativepathstring]['createform'])) { - foreach($user->default_values[$relativepathstring]['createform'] as $defkey => $defval) + foreach ($user->default_values[$relativepathstring]['createform'] as $defkey => $defval) { $qualified = 0; if ($defkey != '_noquery_') { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) + $tmpqueryarraytohave = explode('&', $defkey); + $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru = 0; + foreach ($tmpqueryarraytohave as $tmpquerytohave) { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1; } - if (! $foundintru) $qualified=1; + if (!$foundintru) $qualified = 1; //var_dump($defkey.'-'.$qualified); } else $qualified = 1; @@ -365,45 +365,45 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti } // Management of default search_filters and sort order //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) - elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' + if (!empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' { //var_dump($user->default_values[$relativepathstring]); if ($paramname == 'sortfield' || $paramname == 'sortorder') // Sorted on which fields ? ASC or DESC ? { if (isset($user->default_values[$relativepathstring]['sortorder'])) // Even if paramname is sortfield, data are stored into ['sortorder...'] { - foreach($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) + foreach ($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) { $qualified = 0; if ($defkey != '_noquery_') { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) + $tmpqueryarraytohave = explode('&', $defkey); + $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru = 0; + foreach ($tmpqueryarraytohave as $tmpquerytohave) { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1; } - if (! $foundintru) $qualified=1; + if (!$foundintru) $qualified = 1; //var_dump($defkey.'-'.$qualified); } else $qualified = 1; if ($qualified) { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , - foreach($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) + $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and , + foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) { - if ($out) $out.=', '; + if ($out) $out .= ', '; if ($paramname == 'sortfield') { - $out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace); + $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace); } if ($paramname == 'sortorder') { - $out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace); + $out .= dol_string_nospecial($val, '', $forbidden_chars_to_replace); } } //break; // No break for sortfield and sortorder so we can cumulate fields (is it realy usefull ?) @@ -413,19 +413,19 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti } elseif (isset($user->default_values[$relativepathstring]['filters'])) { - foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) // $defkey is a querystring like 'a=b&c=d', $defval is key of user + foreach ($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) // $defkey is a querystring like 'a=b&c=d', $defval is key of user { $qualified = 0; if ($defkey != '_noquery_') { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) + $tmpqueryarraytohave = explode('&', $defkey); + $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru = 0; + foreach ($tmpqueryarraytohave as $tmpquerytohave) { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1; } - if (! $foundintru) $qualified=1; + if (!$foundintru) $qualified = 1; //var_dump($defkey.'-'.$qualified); } else $qualified = 1; @@ -437,13 +437,13 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti // We made a search from quick search menu, do we still use default filter ? if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and , $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); } } else { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and , $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); } break; @@ -459,22 +459,22 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti // Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable parameters) // Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOMPANY_COUNTRY_ID__, __USER_ID__, ... // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text. - if (! is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) + if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) { - $maxloop=20; $loopnb=0; // Protection against infinite loop + $maxloop = 20; $loopnb = 0; // Protection against infinite loop while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side. { $loopnb++; $newout = ''; - if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; } - elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; } - elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; } - elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } - elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } - elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } - elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } - elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } - elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } + if ($reg[1] == 'DAY') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['mday']; } + elseif ($reg[1] == 'MONTH') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['mon']; } + elseif ($reg[1] == 'YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['year']; } + elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } + elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_prev_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } + elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } + elseif ($reg[1] == 'NEXT_DAY') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } + elseif ($reg[1] == 'NEXT_MONTH') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_next_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } + elseif ($reg[1] == 'NEXT_YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') { $newout = $mysoc->country_id; @@ -491,7 +491,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti { $newout = $conf->entity; } - else $newout = ''; // Key not found, we replace with empty string + else $newout = ''; // Key not found, we replace with empty string //var_dump('__'.$reg[1].'__ -> '.$newout); $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out); } @@ -503,68 +503,68 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti case 'none': break; case 'int': // Check param is a numeric value (integer but also float or hexadecimal) - if (! is_numeric($out)) { $out=''; } + if (!is_numeric($out)) { $out = ''; } break; case 'intcomma': - if (preg_match('/[^0-9,-]+/i', $out)) $out=''; + if (preg_match('/[^0-9,-]+/i', $out)) $out = ''; break; case 'alpha': - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); + $out = trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - if (preg_match('/"/', $out)) $out=''; - elseif (preg_match('/\.\.\//', $out)) $out=''; + if (preg_match('/"/', $out)) $out = ''; + elseif (preg_match('/\.\.\//', $out)) $out = ''; } break; case 'san_alpha': - $out=filter_var($out, FILTER_SANITIZE_STRING); + $out = filter_var($out, FILTER_SANITIZE_STRING); break; case 'aZ': - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); - if (preg_match('/[^a-z]+/i', $out)) $out=''; + $out = trim($out); + if (preg_match('/[^a-z]+/i', $out)) $out = ''; } break; case 'aZ09': - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); - if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) $out=''; + $out = trim($out); + if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) $out = ''; } break; case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); - if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) $out=''; + $out = trim($out); + if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) $out = ''; } break; case 'array': - if (! is_array($out) || empty($out)) $out=array(); + if (!is_array($out) || empty($out)) $out = array(); break; case 'nohtml': // Recommended for most scalar parameters - $out=dol_string_nohtmltag($out, 0); + $out = dol_string_nohtmltag($out, 0); break; case 'alphanohtml': // Recommended for search parameters - if (! is_array($out)) + if (!is_array($out)) { - $out=trim($out); + $out = trim($out); // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - if (preg_match('/"/', $out)) $out=''; - elseif (preg_match('/\.\.\//', $out)) $out=''; - $out=dol_string_nohtmltag($out); + if (preg_match('/"/', $out)) $out = ''; + elseif (preg_match('/\.\.\//', $out)) $out = ''; + $out = dol_string_nohtmltag($out); } break; case 'restricthtml': // Recommended for most html textarea - $out=dol_string_onlythesehtmltags($out, 0); + $out = dol_string_onlythesehtmltags($out, 0); break; case 'custom': if (empty($filter)) return 'BadFourthParameterForGETPOST'; - $out=filter_var($out, $filter, $options); + $out = filter_var($out, $filter, $options); break; } @@ -572,7 +572,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti // Save data into session if key start with 'search_' or is 'smonth', 'syear', 'month', 'year' if (empty($method) || $method == 3 || $method == 4) { - if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder','sortfield'))) + if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder', 'sortfield'))) { //var_dump($paramname.' - '.$out.' '.$user->default_values[$relativepathstring]['filters'][$paramname]); @@ -582,7 +582,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti if ($out != '') // $out = '0' or 'abc', it is a search criteria to keep { - $user->lastsearch_values_tmp[$relativepathstring][$paramname]=$out; + $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out; } } } @@ -591,7 +591,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti } -if (! function_exists('dol_getprefix')) +if (!function_exists('dol_getprefix')) { /** * Return a prefix to use for this Dolibarr instance, for session/cookie names or email id. @@ -608,21 +608,21 @@ if (! function_exists('dol_getprefix')) // If prefix is for email if ($mode == 'email') { - if (! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended) + if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended) { if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; elseif (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"]; } // The recommended value (may be not defined for old versions) - if (! empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id; + if (!empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id; // For backward compatibility return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3'); } // The recommended value (may be not defined for old versions) - if (! empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id; + if (!empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id; // For backward compatibility if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) @@ -646,7 +646,7 @@ if (! function_exists('dol_getprefix')) */ function dol_include_once($relpath, $classname = '') { - global $conf,$langs,$user,$mysoc; // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var'] + global $conf, $langs, $user, $mysoc; // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var'] $fullpath = dol_buildpath($relpath); @@ -655,7 +655,7 @@ function dol_include_once($relpath, $classname = '') return false; } - if (! empty($classname) && ! class_exists($classname)) { + if (!empty($classname) && !class_exists($classname)) { return include $fullpath; } else { return include_once $fullpath; @@ -677,11 +677,11 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) { global $conf; - $path=preg_replace('/^\//', '', $path); + $path = preg_replace('/^\//', '', $path); if (empty($type)) // For a filesystem path { - $res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path + $res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path if (is_array($conf->file->dol_document_root)) { foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array("main"=>"/home/main/htdocs", "alt0"=>"/home/dirmod/htdocs", ...) @@ -692,14 +692,14 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) } if (file_exists($dirroot.'/'.$path)) { - $res=$dirroot.'/'.$path; + $res = $dirroot.'/'.$path; return $res; } } } if ($returnemptyifnotfound) // Not found into alternate dir { - if ($returnemptyifnotfound == 1 || ! file_exists($res)) return ''; + if ($returnemptyifnotfound == 1 || !file_exists($res)) return ''; } } else // For an url path @@ -708,9 +708,9 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) // Note that trying to know if a file on disk exist by forging path on disk from url // works only for some web server and some setup. This is bugged when // using proxy, rewriting, virtual path, etc... - $res=''; - if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value - if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value + $res = ''; + if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value + if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value if ($type == 3) $res = DOL_URL_ROOT.'/'.$path; foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) @@ -722,38 +722,38 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $res=(preg_match('/^http/i', $conf->file->dol_url_root[$key])?'':$urlwithroot).'/'.$path; // Test on start with http is for old conf syntax + $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot).'/'.$path; // Test on start with http is for old conf syntax } continue; } - preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs); // Take part before '?' - if (! empty($regs[1])) + preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs); // Take part before '?' + if (!empty($regs[1])) { //print $key.'-'.$dirroot.'/'.$path.'-'.$conf->file->dol_url_root[$type].'
'."\n"; if (file_exists($dirroot.'/'.$regs[1])) { if ($type == 1) { - $res=(preg_match('/^http/i', $conf->file->dol_url_root[$key])?'':DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; + $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; } if ($type == 2) { - $res=(preg_match('/^http/i', $conf->file->dol_url_root[$key])?'':DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; + $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; } if ($type == 3) { global $dolibarr_main_url_root; // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $res=(preg_match('/^http/i', $conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax + $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax } break; } @@ -778,11 +778,11 @@ function dol_clone($object, $native = 0) { if (empty($native)) { - $myclone=unserialize(serialize($object)); + $myclone = unserialize(serialize($object)); } else { - $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable) + $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable) } return $myclone; @@ -822,7 +822,7 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) // Char '>' '<' '|' '$' and ';' are special chars for shells. // Char '/' and '\' are file delimiters. $filesystem_forbidden_chars = array('<', '>', '/', '\\', '?', '*', '|', '"', ':', '°', '$', ';'); - return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); + return dol_string_nospecial($unaccent ?dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); } /** @@ -837,8 +837,8 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1) */ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1) { - $filesystem_forbidden_chars = array('<','>','?','*','|','"','°'); - return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); + $filesystem_forbidden_chars = array('<', '>', '?', '*', '|', '"', '°'); + return dol_string_nospecial($unaccent ?dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars); } /** @@ -856,21 +856,21 @@ function dol_string_unaccent($str) // See http://www.utf8-chartable.de/ $string = rawurlencode($str); $replacements = array( - '%C3%80' => 'A','%C3%81' => 'A','%C3%82' => 'A','%C3%83' => 'A','%C3%84' => 'A','%C3%85' => 'A', - '%C3%88' => 'E','%C3%89' => 'E','%C3%8A' => 'E','%C3%8B' => 'E', - '%C3%8C' => 'I','%C3%8D' => 'I','%C3%8E' => 'I','%C3%8F' => 'I', - '%C3%92' => 'O','%C3%93' => 'O','%C3%94' => 'O','%C3%95' => 'O','%C3%96' => 'O', - '%C3%99' => 'U','%C3%9A' => 'U','%C3%9B' => 'U','%C3%9C' => 'U', - '%C3%A0' => 'a','%C3%A1' => 'a','%C3%A2' => 'a','%C3%A3' => 'a','%C3%A4' => 'a','%C3%A5' => 'a', + '%C3%80' => 'A', '%C3%81' => 'A', '%C3%82' => 'A', '%C3%83' => 'A', '%C3%84' => 'A', '%C3%85' => 'A', + '%C3%88' => 'E', '%C3%89' => 'E', '%C3%8A' => 'E', '%C3%8B' => 'E', + '%C3%8C' => 'I', '%C3%8D' => 'I', '%C3%8E' => 'I', '%C3%8F' => 'I', + '%C3%92' => 'O', '%C3%93' => 'O', '%C3%94' => 'O', '%C3%95' => 'O', '%C3%96' => 'O', + '%C3%99' => 'U', '%C3%9A' => 'U', '%C3%9B' => 'U', '%C3%9C' => 'U', + '%C3%A0' => 'a', '%C3%A1' => 'a', '%C3%A2' => 'a', '%C3%A3' => 'a', '%C3%A4' => 'a', '%C3%A5' => 'a', '%C3%A7' => 'c', - '%C3%A8' => 'e','%C3%A9' => 'e','%C3%AA' => 'e','%C3%AB' => 'e', - '%C3%AC' => 'i','%C3%AD' => 'i','%C3%AE' => 'i','%C3%AF' => 'i', + '%C3%A8' => 'e', '%C3%A9' => 'e', '%C3%AA' => 'e', '%C3%AB' => 'e', + '%C3%AC' => 'i', '%C3%AD' => 'i', '%C3%AE' => 'i', '%C3%AF' => 'i', '%C3%B1' => 'n', - '%C3%B2' => 'o','%C3%B3' => 'o','%C3%B4' => 'o','%C3%B5' => 'o','%C3%B6' => 'o', - '%C3%B9' => 'u','%C3%BA' => 'u','%C3%BB' => 'u','%C3%BC' => 'u', + '%C3%B2' => 'o', '%C3%B3' => 'o', '%C3%B4' => 'o', '%C3%B5' => 'o', '%C3%B6' => 'o', + '%C3%B9' => 'u', '%C3%BA' => 'u', '%C3%BB' => 'u', '%C3%BC' => 'u', '%C3%BF' => 'y' ); - $string=strtr($string, $replacements); + $string = strtr($string, $replacements); return rawurldecode($string); } else @@ -909,9 +909,9 @@ function dol_string_unaccent($str) */ function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '') { - $forbidden_chars_to_replace=array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName - $forbidden_chars_to_remove=array(); - if (is_array($badcharstoreplace)) $forbidden_chars_to_replace=$badcharstoreplace; + $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName + $forbidden_chars_to_remove = array(); + if (is_array($badcharstoreplace)) $forbidden_chars_to_replace = $badcharstoreplace; //$forbidden_chars_to_remove=array("(",")"); return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str)); @@ -929,13 +929,13 @@ function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '') function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0) { // escape quotes and backslashes, newlines, etc. - $substitjs=array("'"=>"\\'","\r"=>'\\r'); + $substitjs = array("'"=>"\\'", "\r"=>'\\r'); //$substitjs['"=>'',''=>'')); - if (! $keepn) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); - return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags + $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags + if (!$keepb) $tmp = strtr($tmp, array(""=>'', ''=>'')); + if (!$keepn) $tmp = strtr($tmp, array("\r"=>'\\r', "\n"=>'\\n')); + return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags } @@ -1022,28 +1022,28 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = } } - if (! empty($message)) + if (!empty($message)) { // Test log level $logLevels = array(LOG_EMERG=>'EMERG', LOG_ALERT=>'ALERT', LOG_CRIT=>'CRITICAL', LOG_ERR=>'ERR', LOG_WARNING=>'WARN', LOG_NOTICE=>'NOTICE', LOG_INFO=>'INFO', LOG_DEBUG=>'DEBUG'); - if (! array_key_exists($level, $logLevels)) + if (!array_key_exists($level, $logLevels)) { throw new Exception('Incorrect log level'); } if ($level > $conf->global->SYSLOG_LEVEL) return; - $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log + $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log // If adding log inside HTML page is required - if ((! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML)) - || (! empty($user->rights->debugbar->read) && is_object($debugbar))) + if ((!empty($_REQUEST['logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML)) + || (!empty($user->rights->debugbar->read) && is_object($debugbar))) { $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S")." ".$logLevels[$level]." ".$message; } //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output // If html log tag enabled and url parameter log defined, we show output log on HTML comments - if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"])) + if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET["log"])) { print "\n\n'; - if ((! empty($title) && $showtitle) || $morehtmlright || ! empty($links)) { - $out.= '
'."\n"; + if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) { + $out .= '
'."\n"; } // Show right part - if ($morehtmlright) $out.='
'.$morehtmlright.'
'; // Output right area first so when space is missing, text is in front of tabs and not under. + if ($morehtmlright) $out .= '
'.$morehtmlright.'
'; // Output right area first so when space is missing, text is in front of tabs and not under. // Show title - if (! empty($title) && $showtitle) + if (!empty($title) && $showtitle) { - $limittitle=30; - $out.=''; - if ($picto) $out.=img_picto($title, ($pictoisfullpath?'':'object_').$picto, '', $pictoisfullpath).' '; - $out.=''.dol_trunc($title, $limittitle).''; - $out.=''; + $limittitle = 30; + $out .= ''; + if ($picto) $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath).' '; + $out .= ''.dol_trunc($title, $limittitle).''; + $out .= ''; } // Show tabs // Define max of key (max may be higher than sizeof because of hole due to module disabling some tabs). - $maxkey=-1; - if (is_array($links) && ! empty($links)) + $maxkey = -1; + if (is_array($links) && !empty($links)) { - $keys=array_keys($links); - if (count($keys)) $maxkey=max($keys); + $keys = array_keys($links); + if (count($keys)) $maxkey = max($keys); } - if (! empty($conf->dol_optimize_smallscreen)) $conf->global->MAIN_MAXTABS_IN_CARD=2; + if (!empty($conf->dol_optimize_smallscreen)) $conf->global->MAIN_MAXTABS_IN_CARD = 2; // Show tabs // if =0 we don't use the feature - $limittoshow=(empty($conf->global->MAIN_MAXTABS_IN_CARD)?99:$conf->global->MAIN_MAXTABS_IN_CARD); - $displaytab=0; - $nbintab=0; - $popuptab=0; - $outmore=''; - for ($i = 0 ; $i <= $maxkey ; $i++) + $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD); + $displaytab = 0; + $nbintab = 0; + $popuptab = 0; + $outmore = ''; + for ($i = 0; $i <= $maxkey; $i++) { - if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) { + if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) { // If active tab is already present if ($i >= $limittoshow) $limittoshow--; } } - for ($i = 0 ; $i <= $maxkey ; $i++) + for ($i = 0; $i <= $maxkey; $i++) { - if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) { - $isactive=true; + if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) { + $isactive = true; } else { - $isactive=false; + $isactive = false; } if ($i < $limittoshow || $isactive) { - $out.='
'; + $out .= '
'; if (isset($links[$i][2]) && $links[$i][2] == 'image') { if (!empty($links[$i][0])) { - $out.=''.$links[$i][1].''."\n"; + $out .= ''.$links[$i][1].''."\n"; } else { - $out.=''.$links[$i][1].''."\n"; + $out .= ''.$links[$i][1].''."\n"; } } - elseif (! empty($links[$i][1])) + elseif (!empty($links[$i][1])) { //print "x $i $active ".$links[$i][2]." z"; if ($isactive) { - $out.=''; - $out.=$links[$i][1]; - $out.=''."\n"; + $out .= ''; + $out .= $links[$i][1]; + $out .= ''."\n"; } else { - $out.=''; - $out.=$links[$i][1]; - $out.=''."\n"; + $out .= ''; + $out .= $links[$i][1]; + $out .= ''."\n"; } } - $out.='
'; + $out .= '
'; } else { // The popup with the other tabs - if (! $popuptab) + if (!$popuptab) { - $popuptab=1; - $outmore.='
'; // The css used to hide/show popup + $popuptab = 1; + $outmore .= '
'; // The css used to hide/show popup } - $outmore.='
'; + $outmore .= '
'; if (isset($links[$i][2]) && $links[$i][2] == 'image') { if (!empty($links[$i][0])) - $outmore.=''.$links[$i][1].''."\n"; + $outmore .= ''.$links[$i][1].''."\n"; else - $outmore.=''.$links[$i][1].''."\n"; + $outmore .= ''.$links[$i][1].''."\n"; } - elseif (! empty($links[$i][1])) + elseif (!empty($links[$i][1])) { - $outmore.=''; - $outmore.=preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. - $outmore.=''."\n"; + $outmore .= ''; + $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. + $outmore .= ''."\n"; } - $outmore.='
'; + $outmore .= '
'; $nbintab++; } - $displaytab=$i; + $displaytab = $i; } - if ($popuptab) $outmore.='
'; + if ($popuptab) $outmore .= '
'; if ($popuptab) // If there is some tabs not shown { - $left=($langs->trans("DIRECTION") == 'rtl'?'right':'left'); - $right=($langs->trans("DIRECTION") == 'rtl'?'left':'right'); + $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); + $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right'); - $tabsname=str_replace("@", "", $picto); - $out.='
'; - $out.=''.$langs->trans("More").'... ('.$nbintab.')'; - $out.='
'; - $out.=$outmore; - $out.='
'; - $out.='
'; - $out.="
\n"; + $tabsname = str_replace("@", "", $picto); + $out .= '
'; + $out .= ''.$langs->trans("More").'... ('.$nbintab.')'; + $out .= '
'; + $out .= $outmore; + $out .= '
'; + $out .= '
'; + $out .= "
\n"; - $out.=""; + $out .= ""; } - if ((! empty($title) && $showtitle) || $morehtmlright || ! empty($links)) { - $out.="
\n"; + if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) { + $out .= "
\n"; } - if (! $notab || $notab == -1 || $notab == -2) $out.="\n".'
'."\n"; + if (!$notab || $notab == -1 || $notab == -2) $out .= "\n".'
'."\n"; - $parameters=array('tabname' => $active, 'out' => $out); - $reshook=$hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead" + $parameters = array('tabname' => $active, 'out' => $out); + $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead" if ($reshook > 0) { $out = $hookmanager->resPrint; @@ -1298,7 +1298,7 @@ function dol_fiche_end($notab = 0) */ function dol_get_fiche_end($notab = 0) { - if (! $notab || $notab == -1) return "\n
\n"; + if (!$notab || $notab == -1) return "\n
\n"; else return ''; } @@ -1327,79 +1327,79 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $error = 0; - $maxvisiblephotos=1; - $showimage=1; - $entity=(empty($object->entity)?$conf->entity:$object->entity); - $showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0); - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; - $modulepart='unknown'; + $maxvisiblephotos = 1; + $showimage = 1; + $entity = (empty($object->entity) ? $conf->entity : $object->entity); + $showbarcode = empty($conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0); + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; + $modulepart = 'unknown'; - if ($object->element == 'societe') $modulepart='societe'; - if ($object->element == 'contact') $modulepart='contact'; - if ($object->element == 'member') $modulepart='memberphoto'; - if ($object->element == 'user') $modulepart='userphoto'; - if ($object->element == 'product') $modulepart='product'; - if ($object->element == 'ticket') $modulepart='ticket'; + if ($object->element == 'societe') $modulepart = 'societe'; + if ($object->element == 'contact') $modulepart = 'contact'; + if ($object->element == 'member') $modulepart = 'memberphoto'; + if ($object->element == 'user') $modulepart = 'userphoto'; + if ($object->element == 'product') $modulepart = 'product'; + if ($object->element == 'ticket') $modulepart = 'ticket'; if (class_exists("Imagick")) { - if ($object->element == 'propal') $modulepart='propal'; - if ($object->element == 'commande') $modulepart='commande'; - if ($object->element == 'facture') $modulepart='facture'; - if ($object->element == 'fichinter') $modulepart='ficheinter'; - if ($object->element == 'contrat') $modulepart='contract'; - if ($object->element == 'supplier_proposal') $modulepart='supplier_proposal'; - if ($object->element == 'order_supplier') $modulepart='supplier_order'; - if ($object->element == 'invoice_supplier') $modulepart='supplier_invoice'; - if ($object->element == 'expensereport') $modulepart='expensereport'; + if ($object->element == 'propal') $modulepart = 'propal'; + if ($object->element == 'commande') $modulepart = 'commande'; + if ($object->element == 'facture') $modulepart = 'facture'; + if ($object->element == 'fichinter') $modulepart = 'ficheinter'; + if ($object->element == 'contrat') $modulepart = 'contract'; + if ($object->element == 'supplier_proposal') $modulepart = 'supplier_proposal'; + if ($object->element == 'order_supplier') $modulepart = 'supplier_order'; + if ($object->element == 'invoice_supplier') $modulepart = 'supplier_invoice'; + if ($object->element == 'expensereport') $modulepart = 'expensereport'; } if ($object->element == 'product') { - $width=80; $cssclass='photoref'; - $showimage=$object->is_photo_available($conf->product->multidir_output[$entity]); - $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); - if ($conf->browser->layout == 'phone') $maxvisiblephotos=1; - if ($showimage) $morehtmlleft.='
'.$object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'
'; + $width = 80; $cssclass = 'photoref'; + $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]); + $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5); + if ($conf->browser->layout == 'phone') $maxvisiblephotos = 1; + if ($showimage) $morehtmlleft .= '
'.$object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'
'; else { if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { - $nophoto=''; - $morehtmlleft.='
'; + $nophoto = ''; + $morehtmlleft .= '
'; } else { // Show no photo link - $nophoto='/public/theme/common/nophoto.png'; - $morehtmlleft.='
No photo
'; + $nophoto = '/public/theme/common/nophoto.png'; + $morehtmlleft .= '
No photo
'; } } } elseif ($object->element == 'ticket') { - $width=80; $cssclass='photoref'; - $showimage=$object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->ref); - $maxvisiblephotos=(isset($conf->global->TICKET_MAX_VISIBLE_PHOTO)?$conf->global->TICKET_MAX_VISIBLE_PHOTO:2); - if ($conf->browser->layout == 'phone') $maxvisiblephotos=1; + $width = 80; $cssclass = 'photoref'; + $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->ref); + $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2); + if ($conf->browser->layout == 'phone') $maxvisiblephotos = 1; if ($showimage) { $showphoto = $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0); if ($object->nbphoto > 0) { - $morehtmlleft.='
'.$showphoto.'
'; + $morehtmlleft .= '
'.$showphoto.'
'; } else { $showimage = 0; } } - if (! $showimage) + if (!$showimage) { if (!empty($conf->global->TICKET_NODISPLAYIFNOPHOTO)) { - $nophoto=''; - $morehtmlleft.='
'; + $nophoto = ''; + $morehtmlleft .= '
'; } else { // Show no photo link - $nophoto='/public/theme/common/nophoto.png'; - $morehtmlleft.='
No photo
'; + $nophoto = '/public/theme/common/nophoto.png'; + $morehtmlleft .= '
No photo
'; } } } @@ -1409,26 +1409,26 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi { if ($modulepart != 'unknown') { - $phototoshow=''; + $phototoshow = ''; // Check if a preview file is available if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) { $objectref = dol_sanitizeFileName($object->ref); - $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]) . "/"; + $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity])."/"; if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) { $subdir = get_exdir($object->id, 2, 0, 1, $object, $modulepart); - $subdir.= ((! empty($subdir) && ! preg_match('/\/$/', $subdir))?'/':'').$objectref; // the objectref dir is not included into get_exdir when used with level=2, so we add it at end + $subdir .= ((!empty($subdir) && !preg_match('/\/$/', $subdir)) ? '/' : '').$objectref; // the objectref dir is not included into get_exdir when used with level=2, so we add it at end } else { $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart); } - if (empty($subdir)) $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path + if (empty($subdir)) $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path - $filepath = $dir_output . $subdir . "/"; + $filepath = $dir_output.$subdir."/"; - $filepdf = $filepath . $objectref . ".pdf"; + $filepdf = $filepath.$objectref.".pdf"; $relativepath = $subdir.'/'.$objectref.'.pdf'; // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png") @@ -1441,159 +1441,159 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if ($pdfexists) { // Conversion du PDF en image png si fichier png non existant - if (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) + if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) { if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here. { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png + $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png if ($ret < 0) $error++; } } } - if ($pdfexists && ! $error) + if ($pdfexists && !$error) { - $heightforphotref=70; - if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; + $heightforphotref = 70; + if (!empty($conf->dol_optimize_smallscreen)) $heightforphotref = 60; // If the preview file is found if (file_exists($fileimage)) { $phototoshow = '
'; - $phototoshow.= ''; - $phototoshow.= '
'; + $phototoshow .= ''; + $phototoshow .= ''; } } } - elseif (! $phototoshow) + elseif (!$phototoshow) { - $phototoshow.= $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos); + $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0, 'photoref', 'small', 1, 0, $maxvisiblephotos); } if ($phototoshow) { - $morehtmlleft.='
'; - $morehtmlleft.=$phototoshow; - $morehtmlleft.='
'; + $morehtmlleft .= '
'; + $morehtmlleft .= $phototoshow; + $morehtmlleft .= '
'; } } - if (! $phototoshow) // Show No photo link (picto of pbject) + if (!$phototoshow) // Show No photo link (picto of pbject) { - $morehtmlleft.='
'; + $morehtmlleft .= '
'; if ($object->element == 'action') { - $width=80; - $cssclass='photorefcenter'; - $nophoto=img_picto('', 'title_agenda', '', false, 1); + $width = 80; + $cssclass = 'photorefcenter'; + $nophoto = img_picto('', 'title_agenda', '', false, 1); } else { - $width=14; $cssclass='photorefcenter'; + $width = 14; $cssclass = 'photorefcenter'; $picto = $object->picto; - if ($object->element == 'project' && ! $object->public) $picto = 'project'; // instead of projectpub - $nophoto=img_picto('', 'object_'.$picto, '', false, 1); + if ($object->element == 'project' && !$object->public) $picto = 'project'; // instead of projectpub + $nophoto = img_picto('', 'object_'.$picto, '', false, 1); } - $morehtmlleft.=''; - $morehtmlleft.='
No photo
'; + $morehtmlleft .= ''; + $morehtmlleft .= '
No photo
'; - $morehtmlleft.='
'; + $morehtmlleft .= '
'; } } } - if ($showbarcode) $morehtmlleft.='
'.$form->showbarcode($object).'
'; + if ($showbarcode) $morehtmlleft .= '
'.$form->showbarcode($object).'
'; if ($object->element == 'societe') { - if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) + if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - $morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); + $morehtmlstatus .= ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); } else { - $morehtmlstatus.=$object->getLibStatut(6); + $morehtmlstatus .= $object->getLibStatut(6); } } elseif ($object->element == 'product') { //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - $morehtmlstatus.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + $morehtmlstatus .= ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { - $morehtmlstatus.=''.$object->getLibStatut(6, 0).''; + $morehtmlstatus .= ''.$object->getLibStatut(6, 0).''; } - $morehtmlstatus.='   '; + $morehtmlstatus .= '   '; //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - $morehtmlstatus.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + $morehtmlstatus .= ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { - $morehtmlstatus.=''.$object->getLibStatut(6, 1).''; + $morehtmlstatus .= ''.$object->getLibStatut(6, 1).''; } } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) { - $tmptxt=$object->getLibStatut(6, $object->totalpaye); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt=$object->getLibStatut(5, $object->totalpaye); - $morehtmlstatus.=$tmptxt; + $tmptxt = $object->getLibStatut(6, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5, $object->totalpaye); + $morehtmlstatus .= $tmptxt; } elseif ($object->element == 'contrat' || $object->element == 'contract') { - if ($object->statut == 0) $morehtmlstatus.=$object->getLibStatut(5); - else $morehtmlstatus.=$object->getLibStatut(4); + if ($object->statut == 0) $morehtmlstatus .= $object->getLibStatut(5); + else $morehtmlstatus .= $object->getLibStatut(4); } elseif ($object->element == 'facturerec') { - if ($object->frequency == 0) $morehtmlstatus.=$object->getLibStatut(2); - else $morehtmlstatus.=$object->getLibStatut(5); + if ($object->frequency == 0) $morehtmlstatus .= $object->getLibStatut(2); + else $morehtmlstatus .= $object->getLibStatut(5); } elseif ($object->element == 'project_task') { $object->fk_statut = 1; if ($object->progress > 0) $object->fk_statut = 2; if ($object->progress >= 100) $object->fk_statut = 3; - $tmptxt=$object->getLibStatut(5); - $morehtmlstatus.=$tmptxt; // No status on task + $tmptxt = $object->getLibStatut(5); + $morehtmlstatus .= $tmptxt; // No status on task } else { // Generic case - $tmptxt=$object->getLibStatut(6); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt=$object->getLibStatut(5); - $morehtmlstatus.=$tmptxt; + $tmptxt = $object->getLibStatut(6); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5); + $morehtmlstatus .= $tmptxt; } // Add if object was dispatched "into accountancy" - if (! empty($conf->accounting->enabled) && in_array($object->element, array('bank', 'facture', 'invoice', 'invoice_supplier', 'expensereport'))) + if (!empty($conf->accounting->enabled) && in_array($object->element, array('bank', 'facture', 'invoice', 'invoice_supplier', 'expensereport'))) { if (method_exists($object, 'getVentilExportCompta')) { $accounted = $object->getVentilExportCompta(); $langs->load("accountancy"); - $morehtmlstatus.='
'.($accounted > 0 ? $langs->trans("Accounted") : ''.$langs->trans("NotYetAccounted").''); + $morehtmlstatus .= '
'.($accounted > 0 ? $langs->trans("Accounted") : ''.$langs->trans("NotYetAccounted").''); } } // Add alias for thirdparty - if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; + if (!empty($object->name_alias)) $morehtmlref .= '
'.$object->name_alias.'
'; // Add label if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') { - if (! empty($object->label)) $morehtmlref.='
'.$object->label.'
'; + if (!empty($object->label)) $morehtmlref .= '
'.$object->label.'
'; } if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') { - $morehtmlref.='
'; - $morehtmlref.=$object->getBannerAddress('refaddress', $object); - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= $object->getBannerAddress('refaddress', $object); + $morehtmlref .= '
'; } - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) { - $morehtmlref.='
'; - $morehtmlref.=$langs->trans("TechnicalID").': '.$object->id; - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= $langs->trans("TechnicalID").': '.$object->id; + $morehtmlref .= '
'; } - print '
'; + print '
'; print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright); print '
'; print '
'; @@ -1611,12 +1611,12 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi function fieldLabel($langkey, $fieldkey, $fieldrequired = 0) { global $langs; - $ret=''; - if ($fieldrequired) $ret.=''; - $ret.=''; - if ($fieldrequired) $ret.=''; + $ret = ''; + if ($fieldrequired) $ret .= ''; + $ret .= ''; + if ($fieldrequired) $ret .= ''; return $ret; } @@ -1630,8 +1630,8 @@ function fieldLabel($langkey, $fieldkey, $fieldrequired = 0) function dol_bc($var, $moreclass = '') { global $bc; - $ret=' '.$bc[$var]; - if ($moreclass) $ret=preg_replace('/class=\"/', 'class="'.$moreclass.' ', $ret); + $ret = ' '.$bc[$var]; + if ($moreclass) $ret = preg_replace('/class=\"/', 'class="'.$moreclass.' ', $ret); return $ret; } @@ -1648,63 +1648,63 @@ function dol_bc($var, $moreclass = '') */ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0) { - global $conf,$langs; + global $conf, $langs; - $ret=''; - $countriesusingstate=array('AU','CA','US','IN','GB','ES','UK','TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS + $ret = ''; + $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS // Address if (empty($mode)) { $ret .= $object->address; } // Zip/Town/State - if (in_array($object->country_code, array('AU', 'CA', 'US')) || ! empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) // US: title firstname name \n address lines \n town, state, zip \n country + if (in_array($object->country_code, array('AU', 'CA', 'US')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) // US: title firstname name \n address lines \n town, state, zip \n country { - $ret .= ($ret ? $sep : '' ).$object->town; + $ret .= ($ret ? $sep : '').$object->town; if ($object->state) { - $ret.=($ret?", ":'').$object->state; + $ret .= ($ret ? ", " : '').$object->state; } - if ($object->zip) $ret .= ($ret?", ":'').$object->zip; + if ($object->zip) $ret .= ($ret ? ", " : '').$object->zip; } - elseif (in_array($object->country_code, array('GB','UK'))) // UK: title firstname name \n address lines \n town state \n zip \n country + elseif (in_array($object->country_code, array('GB', 'UK'))) // UK: title firstname name \n address lines \n town state \n zip \n country { - $ret .= ($ret ? $sep : '' ).$object->town; + $ret .= ($ret ? $sep : '').$object->town; if ($object->state) { - $ret.=($ret?", ":'').$object->state; + $ret .= ($ret ? ", " : '').$object->state; } - if ($object->zip) $ret .= ($ret ? $sep : '' ).$object->zip; + if ($object->zip) $ret .= ($ret ? $sep : '').$object->zip; } - elseif (in_array($object->country_code, array('ES','TR'))) // ES: title firstname name \n address lines \n zip town \n state \n country + elseif (in_array($object->country_code, array('ES', 'TR'))) // ES: title firstname name \n address lines \n zip town \n state \n country { - $ret .= ($ret ? $sep : '' ).$object->zip; - $ret .= ($object->town?(($object->zip?' ':'').$object->town):''); + $ret .= ($ret ? $sep : '').$object->zip; + $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : ''); if ($object->state) { - $ret.="\n".$object->state; + $ret .= "\n".$object->state; } } elseif (in_array($object->country_code, array('IT'))) // IT: tile firstname name\n address lines \n zip (Code Departement) \n country { - $ret .= ($ret ? $sep : '' ).$object->zip; - $ret .= ($object->town?(($object->zip?' ':'').$object->town):''); - $ret .= ($object->state_id?(' ('.($object->state_id).')'):''); + $ret .= ($ret ? $sep : '').$object->zip; + $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : ''); + $ret .= ($object->state_id ? (' ('.($object->state_id).')') : ''); } else // Other: title firstname name \n address lines \n zip town \n country { - $ret .= $object->zip ? (($ret ? $sep : '' ).$object->zip) : ''; - $ret .= ($object->town?(($object->zip?' ':($ret ? $sep : '' )).$object->town):''); + $ret .= $object->zip ? (($ret ? $sep : '').$object->zip) : ''; + $ret .= ($object->town ? (($object->zip ? ' ' : ($ret ? $sep : '')).$object->town) : ''); if ($object->state && in_array($object->country_code, $countriesusingstate)) { - $ret.=($ret?", ":'').$object->state; + $ret .= ($ret ? ", " : '').$object->state; } } - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; if ($withcountry) { $langs->load("dict"); - $ret.=($object->country_code?($ret?$sep:'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); + $ret .= ($object->country_code ? ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)) : ''); } return $ret; @@ -1723,7 +1723,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs function dol_strftime($fmt, $ts = false, $is_gmt = false) { if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range - return ($is_gmt)? @gmstrftime($fmt, $ts): @strftime($fmt, $ts); + return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts); } else return 'Error date into a not supported range'; } @@ -1751,83 +1751,83 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false) */ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlangs = '', $encodetooutput = false) { - global $conf,$langs; + global $conf, $langs; // Clean parameters - $to_gmt=false; - $offsettz=$offsetdst=0; + $to_gmt = false; + $offsettz = $offsetdst = 0; if ($tzoutput) { - $to_gmt=true; // For backward compatibility + $to_gmt = true; // For backward compatibility if (is_string($tzoutput)) { if ($tzoutput == 'tzserver') { - $to_gmt=false; - $offsettzstring=@date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' - $offsettz=0; - $offsetdst=0; + $to_gmt = false; + $offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' + $offsettz = 0; + $offsetdst = 0; } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') { - $to_gmt=true; - $offsettzstring=(empty($_SESSION['dol_tz_string'])?'UTC':$_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' - $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; // Will not be used anymore - $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; // Will not be used anymore + $to_gmt = true; + $offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' + $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore + $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; // Will not be used anymore } } } - if (! is_object($outputlangs)) $outputlangs=$langs; - if (! $format) $format='daytextshort'; - $reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format, array('day','dayhour')))?1:0; + if (!is_object($outputlangs)) $outputlangs = $langs; + if (!$format) $format = 'daytextshort'; + $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0; $formatwithoutreduce = preg_replace('/reduceformat/', '', $format); - if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day + if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat = 1; } // so format 'dayreduceformat' is processed like day // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. // TODO Add format daysmallyear and dayhoursmallyear - if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); - elseif ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); - elseif ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration); - elseif ($format == 'daytext') $format=($outputlangs->trans("FormatDateText")!="FormatDateText"?$outputlangs->trans("FormatDateText"):$conf->format_date_text); - elseif ($format == 'daytextshort') $format=($outputlangs->trans("FormatDateTextShort")!="FormatDateTextShort"?$outputlangs->trans("FormatDateTextShort"):$conf->format_date_text_short); - elseif ($format == 'dayhour') $format=($outputlangs->trans("FormatDateHourShort")!="FormatDateHourShort"?$outputlangs->trans("FormatDateHourShort"):$conf->format_date_hour_short); - elseif ($format == 'dayhoursec') $format=($outputlangs->trans("FormatDateHourSecShort")!="FormatDateHourSecShort"?$outputlangs->trans("FormatDateHourSecShort"):$conf->format_date_hour_sec_short); - elseif ($format == 'dayhourtext') $format=($outputlangs->trans("FormatDateHourText")!="FormatDateHourText"?$outputlangs->trans("FormatDateHourText"):$conf->format_date_hour_text); - elseif ($format == 'dayhourtextshort') $format=($outputlangs->trans("FormatDateHourTextShort")!="FormatDateHourTextShort"?$outputlangs->trans("FormatDateHourTextShort"):$conf->format_date_hour_text_short); + if ($format == 'day') $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); + elseif ($format == 'hour') $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); + elseif ($format == 'hourduration') $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); + elseif ($format == 'daytext') $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); + elseif ($format == 'daytextshort') $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); + elseif ($format == 'dayhour') $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); + elseif ($format == 'dayhoursec') $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); + elseif ($format == 'dayhourtext') $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); + elseif ($format == 'dayhourtextshort') $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); // Format not sensitive to language - elseif ($format == 'dayhourlog') $format='%Y%m%d%H%M%S'; - elseif ($format == 'dayhourldap') $format='%Y%m%d%H%M%SZ'; - elseif ($format == 'dayhourxcard') $format='%Y%m%dT%H%M%SZ'; - elseif ($format == 'dayxcard') $format='%Y%m%d'; - elseif ($format == 'dayrfc') $format='%Y-%m-%d'; // DATE_RFC3339 - elseif ($format == 'dayhourrfc') $format='%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 - elseif ($format == 'standard') $format='%Y-%m-%d %H:%M:%S'; + elseif ($format == 'dayhourlog') $format = '%Y%m%d%H%M%S'; + elseif ($format == 'dayhourldap') $format = '%Y%m%d%H%M%SZ'; + elseif ($format == 'dayhourxcard') $format = '%Y%m%dT%H%M%SZ'; + elseif ($format == 'dayxcard') $format = '%Y%m%d'; + elseif ($format == 'dayrfc') $format = '%Y-%m-%d'; // DATE_RFC3339 + elseif ($format == 'dayhourrfc') $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 + elseif ($format == 'standard') $format = '%Y-%m-%d %H:%M:%S'; if ($reduceformat) { - $format=str_replace('%Y', '%y', $format); - $format=str_replace('yyyy', 'yy', $format); + $format = str_replace('%Y', '%y', $format); + $format = str_replace('yyyy', 'yy', $format); } // If date undefined or "", we return "" - if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) + if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) // Clean format if (preg_match('/%b/i', $format)) // There is some text to translate { // We inhibate translation to text made by strftime functions. We will use trans instead later. - $format=str_replace('%b', '__b__', $format); - $format=str_replace('%B', '__B__', $format); + $format = str_replace('%b', '__b__', $format); + $format = str_replace('%B', '__B__', $format); } if (preg_match('/%a/i', $format)) // There is some text to translate { // We inhibate translation to text made by strftime functions. We will use trans instead later. - $format=str_replace('%a', '__a__', $format); - $format=str_replace('%A', '__A__', $format); + $format = str_replace('%a', '__a__', $format); + $format = str_replace('%A', '__A__', $format); } // Analyze date - $reg=array(); + $reg = array(); if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 { dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]); @@ -1839,59 +1839,59 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang dol_syslog("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"], LOG_WARNING); //if (function_exists('debug_print_backtrace')) debug_print_backtrace(); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' - $syear = (! empty($reg[1]) ? $reg[1] : ''); - $smonth = (! empty($reg[2]) ? $reg[2] : ''); - $sday = (! empty($reg[3]) ? $reg[3] : ''); - $shour = (! empty($reg[4]) ? $reg[4] : ''); - $smin = (! empty($reg[5]) ? $reg[5] : ''); - $ssec = (! empty($reg[6]) ? $reg[6] : ''); + $syear = (!empty($reg[1]) ? $reg[1] : ''); + $smonth = (!empty($reg[2]) ? $reg[2] : ''); + $sday = (!empty($reg[3]) ? $reg[3] : ''); + $shour = (!empty($reg[4]) ? $reg[4] : ''); + $smin = (!empty($reg[5]) ? $reg[5] : ''); + $ssec = (!empty($reg[6]) ? $reg[6] : ''); - $time=dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true); - $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt); + $time = dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear, true); + $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt); } else { // Date is a timestamps if ($time < 100000000000) // Protection against bad date values { - $timetouse = $time+$offsettz+$offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $ret=adodb_strftime($format, $timetouse, $to_gmt); + $ret = adodb_strftime($format, $timetouse, $to_gmt); } - else $ret='Bad value '.$time.' for date'; + else $ret = 'Bad value '.$time.' for date'; } if (preg_match('/__b__/i', $format)) { - $timetouse = $time+$offsettz+$offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. - $month=adodb_strftime('%m', $timetouse); - $month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. + $month = adodb_strftime('%m', $timetouse); + $month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. if ($encodetooutput) { - $monthtext=$outputlangs->transnoentities('Month'.$month); - $monthtextshort=$outputlangs->transnoentities('MonthShort'.$month); + $monthtext = $outputlangs->transnoentities('Month'.$month); + $monthtextshort = $outputlangs->transnoentities('MonthShort'.$month); } else { - $monthtext=$outputlangs->transnoentitiesnoconv('Month'.$month); - $monthtextshort=$outputlangs->transnoentitiesnoconv('MonthShort'.$month); + $monthtext = $outputlangs->transnoentitiesnoconv('Month'.$month); + $monthtextshort = $outputlangs->transnoentitiesnoconv('MonthShort'.$month); } //print 'monthtext='.$monthtext.' monthtextshort='.$monthtextshort; - $ret=str_replace('__b__', $monthtextshort, $ret); - $ret=str_replace('__B__', $monthtext, $ret); + $ret = str_replace('__b__', $monthtextshort, $ret); + $ret = str_replace('__B__', $monthtext, $ret); //print 'x'.$outputlangs->charset_output.'-'.$ret.'x'; //return $ret; } if (preg_match('/__a__/i', $format)) { - $timetouse = $time+$offsettz+$offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $w=adodb_strftime('%w', $timetouse); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $dayweek=$outputlangs->transnoentitiesnoconv('Day'.$w); - $ret=str_replace('__A__', $dayweek, $ret); - $ret=str_replace('__a__', dol_substr($dayweek, 0, 3), $ret); + $w = adodb_strftime('%w', $timetouse); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w); + $ret = str_replace('__A__', $dayweek, $ret); + $ret = str_replace('__a__', dol_substr($dayweek, 0, 3), $ret); } return $ret; @@ -1935,17 +1935,17 @@ function dol_getdate($timestamp, $fast = false) { global $conf; - $usealternatemethod=false; - if ($timestamp <= 0) $usealternatemethod=true; // <= 1970 - if ($timestamp >= 2145913200) $usealternatemethod=true; // >= 2038 + $usealternatemethod = false; + if ($timestamp <= 0) $usealternatemethod = true; // <= 1970 + if ($timestamp >= 2145913200) $usealternatemethod = true; // >= 2038 if ($usealternatemethod) { - $arrayinfo=adodb_getdate($timestamp, $fast); + $arrayinfo = adodb_getdate($timestamp, $fast); } else { - $arrayinfo=getdate($timestamp); + $arrayinfo = getdate($timestamp); } return $arrayinfo; @@ -1976,47 +1976,47 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; // Clean parameters - if ($hour == -1 || empty($hour)) $hour=0; - if ($minute == -1 || empty($minute)) $minute=0; - if ($second == -1 || empty($second)) $second=0; + if ($hour == -1 || empty($hour)) $hour = 0; + if ($minute == -1 || empty($minute)) $minute = 0; + if ($second == -1 || empty($second)) $second = 0; // Check parameters if ($check) { - if (! $month || ! $day) return ''; - if ($day > 31) return ''; + if (!$month || !$day) return ''; + if ($day > 31) return ''; if ($month > 12) return ''; - if ($hour < 0 || $hour > 24) return ''; - if ($minute< 0 || $minute > 60) return ''; - if ($second< 0 || $second > 60) return ''; + if ($hour < 0 || $hour > 24) return ''; + if ($minute < 0 || $minute > 60) return ''; + if ($second < 0 || $second > 60) return ''; } if (empty($gm) || $gm === 'server') { - $default_timezone=@date_default_timezone_get(); // Example 'Europe/Berlin' + $default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin' $localtz = new DateTimeZone($default_timezone); } elseif ($gm === 'user') { // We use dol_tz_string first because it is more reliable. - $default_timezone=(empty($_SESSION["dol_tz_string"])?@date_default_timezone_get():$_SESSION["dol_tz_string"]); // Example 'Europe/Berlin' + $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin' try { $localtz = new DateTimeZone($default_timezone); } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING); - $default_timezone=@date_default_timezone_get(); + $default_timezone = @date_default_timezone_get(); } } elseif (strrpos($gm, "tz,") !== false) { - $timezone=str_replace("tz,", "", $gm); // Example 'tz,Europe/Berlin' + $timezone = str_replace("tz,", "", $gm); // Example 'tz,Europe/Berlin' try { $localtz = new DateTimeZone($timezone); } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING); } @@ -2030,7 +2030,7 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ $dt = new DateTime(null, $localtz); $dt->setDate((int) $year, (int) $month, (int) $day); $dt->setTime((int) $hour, (int) $minute, (int) $second); - $date=$dt->getTimestamp(); // should include daylight saving time + $date = $dt->getTimestamp(); // should include daylight saving time //var_dump($date); return $date; } @@ -2047,16 +2047,16 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $ */ function dol_now($mode = 'gmt') { - $ret=0; + $ret = 0; // Note that gmmktime and mktime return same value (GMT) when used without parameters //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead - if ($mode == 'gmt') $ret=time(); // Time for now at greenwich. + if ($mode == 'gmt') $ret = time(); // Time for now at greenwich. elseif ($mode == 'tzserver') // Time for now with PHP server timezone added { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $tzsecond=getServerTimeZoneInt('now'); // Contains tz+dayling saving time - $ret=(int) (dol_now('gmt')+($tzsecond*3600)); + $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time + $ret = (int) (dol_now('gmt') + ($tzsecond * 3600)); } /*else if ($mode == 'tzref') // Time for now with parent company timezone is added { @@ -2067,9 +2067,9 @@ function dol_now($mode = 'gmt') elseif ($mode == 'tzuser') // Time for now with user timezone added { //print 'time: '.time().'-'.mktime().'-'.gmmktime(); - $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; - $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; - $ret=(int) (dol_now('gmt')+($offsettz+$offsetdst)); + $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; + $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; + $ret = (int) (dol_now('gmt') + ($offsettz + $offsetdst)); } return $ret; @@ -2086,27 +2086,27 @@ function dol_now($mode = 'gmt') */ function dol_print_size($size, $shortvalue = 0, $shortunit = 0) { - global $conf,$langs; - $level=1024; + global $conf, $langs; + $level = 1024; - if (! empty($conf->dol_optimize_smallscreen)) $shortunit=1; + if (!empty($conf->dol_optimize_smallscreen)) $shortunit = 1; // Set value text - if (empty($shortvalue) || $size < ($level*10)) + if (empty($shortvalue) || $size < ($level * 10)) { - $ret=$size; - $textunitshort=$langs->trans("b"); - $textunitlong=$langs->trans("Bytes"); + $ret = $size; + $textunitshort = $langs->trans("b"); + $textunitlong = $langs->trans("Bytes"); } else { - $ret=round($size/$level, 0); - $textunitshort=$langs->trans("Kb"); - $textunitlong=$langs->trans("KiloBytes"); + $ret = round($size / $level, 0); + $textunitshort = $langs->trans("Kb"); + $textunitlong = $langs->trans("KiloBytes"); } // Use long or short text unit - if (empty($shortunit)) { $ret.=' '.$textunitlong; } - else { $ret.=' '.$textunitshort; } + if (empty($shortunit)) { $ret .= ' '.$textunitlong; } + else { $ret .= ' '.$textunitshort; } return $ret; } @@ -2126,16 +2126,16 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0) if (empty($url)) return ''; - $link=''.($withpicto?img_picto($langs->trans("Url"), 'globe').' ':'').$link.'
'; + $link = ''.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'
'; } /** @@ -2152,47 +2152,47 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0) */ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0) { - global $conf,$user,$langs,$hookmanager; + global $conf, $user, $langs, $hookmanager; - $newemail=$email; + $newemail = $email; if (empty($email)) return ' '; - if (! empty($addlink)) + if (!empty($addlink)) { - $newemail=''; - $newemail.=dol_trunc($email, $max); - $newemail.=''; - if ($showinvalid && ! isValidEmail($email)) + $newemail = ''; + $newemail .= dol_trunc($email, $max); + $newemail .= ''; + if ($showinvalid && !isValidEmail($email)) { $langs->load("errors"); - $newemail.=img_warning($langs->trans("ErrorBadEMail", $email)); + $newemail .= img_warning($langs->trans("ErrorBadEMail", $email)); } - if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { - $type='AC_EMAIL'; $link=''; - if (! empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link=''.img_object($langs->trans("AddAction"), "calendar").''; - if ($link) $newemail='
'.$newemail.' '.$link.'
'; + $type = 'AC_EMAIL'; $link = ''; + if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link = ''.img_object($langs->trans("AddAction"), "calendar").''; + if ($link) $newemail = '
'.$newemail.' '.$link.'
'; } } else { - if ($showinvalid && ! isValidEmail($email)) + if ($showinvalid && !isValidEmail($email)) { $langs->load("errors"); - $newemail.=img_warning($langs->trans("ErrorBadEMail", $email)); + $newemail .= img_warning($langs->trans("ErrorBadEMail", $email)); } } - $rep = '
'.($withpicto?img_picto($langs->trans("EMail"), 'object_email.png').' ':'').$newemail.'
'; + $rep = '
'.($withpicto ?img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'
'; if ($hookmanager) { - $parameters = array('cid' => $cid, 'socid' => $socid,'addlink' => $addlink, 'picto' => $withpicto); + $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto); $reshook = $hookmanager->executeHooks('printEmail', $parameters, $email); - $rep.=$hookmanager->resPrint; + $rep .= $hookmanager->resPrint; } return $rep; @@ -2207,7 +2207,7 @@ function getArrayOfSocialNetworks() { global $conf, $db; $sql = "SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; - $sql.= " WHERE entity=".$conf->entity; + $sql .= " WHERE entity=".$conf->entity; $socialnetworks = array(); $resql = $db->query($sql); if ($resql) { @@ -2235,43 +2235,43 @@ function getArrayOfSocialNetworks() */ function dol_print_socialnetworks($value, $cid, $socid, $type) { - global $conf,$user,$langs; + global $conf, $user, $langs; - $htmllink=$value; + $htmllink = $value; if (empty($value)) return ' '; - if (! empty($type)) + if (!empty($type)) { $htmllink = '
'; $htmllink .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); $htmllink .= $value; if ($type == 'skype') { - $htmllink.= ' '; - $htmllink.=''; - $htmllink.=''; - $htmllink.=''; - $htmllink.=''; - $htmllink.=''; + $htmllink .= ' '; + $htmllink .= ''; + $htmllink .= ''; + $htmllink .= ''; + $htmllink .= ''; + $htmllink .= ''; } - if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type=='skype') + if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') { - $addlink='AC_SKYPE'; - $link=''; - if (! empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link=''.img_object($langs->trans("AddAction"), "calendar").''; - $htmllink.=($link?' '.$link:''); + $addlink = 'AC_SKYPE'; + $link = ''; + if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link = ''.img_object($langs->trans("AddAction"), "calendar").''; + $htmllink .= ($link ? ' '.$link : ''); } - $htmllink.='
'; + $htmllink .= ''; } else { $langs->load("errors"); - $htmllink.=img_warning($langs->trans("ErrorBadSocialNetworkValue", $value)); + $htmllink .= img_warning($langs->trans("ErrorBadSocialNetworkValue", $value)); } return $htmllink; } @@ -2297,104 +2297,104 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli // Clean phone parameter $phone = preg_replace("/[\s.-]/", "", trim($phone)); if (empty($phone)) { return ''; } - if (empty($countrycode)) $countrycode=$mysoc->country_code; + if (empty($countrycode)) $countrycode = $mysoc->country_code; // Short format for small screens - if ($conf->dol_optimize_smallscreen) $separ=''; + if ($conf->dol_optimize_smallscreen) $separ = ''; - $newphone=$phone; + $newphone = $phone; if (strtoupper($countrycode) == "FR") { // France if (dol_strlen($phone) == 10) { - $newphone=substr($newphone, 0, 2).$separ.substr($newphone, 2, 2).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2); + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 2).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2); } elseif (dol_strlen($phone) == 7) { - $newphone=substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2); } elseif (dol_strlen($phone) == 9) { - $newphone=substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2); + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2); } elseif (dol_strlen($phone) == 11) { - $newphone=substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); } elseif (dol_strlen($phone) == 12) { - $newphone=substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "CA") { if (dol_strlen($phone) == 10) { - $newphone=($separ!=''?'(':'').substr($newphone, 0, 3).($separ!=''?')':'').$separ.substr($newphone, 3, 3).($separ!=''?'-':'').substr($newphone, 6, 4); + $newphone = ($separ != '' ? '(' : '').substr($newphone, 0, 3).($separ != '' ? ')' : '').$separ.substr($newphone, 3, 3).($separ != '' ? '-' : '').substr($newphone, 6, 4); } } - elseif (strtoupper($countrycode) == "PT" ) + elseif (strtoupper($countrycode) == "PT") {//Portugal if (dol_strlen($phone) == 13) {//ex: +351_ABC_DEF_GHI - $newphone= substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); } } - elseif (strtoupper($countrycode) == "SR" ) + elseif (strtoupper($countrycode) == "SR") {//Suriname if (dol_strlen($phone) == 10) {//ex: +597_ABC_DEF - $newphone= substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3); + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3); } elseif (dol_strlen($phone) == 11) {//ex: +597_ABC_DEFG - $newphone= substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4); + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4); } } - elseif (strtoupper($countrycode) == "DE" ) + elseif (strtoupper($countrycode) == "DE") {//Allemagne if (dol_strlen($phone) == 14) {//ex: +49_ABCD_EFGH_IJK - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3); } elseif (dol_strlen($phone) == 13) {//ex: +49_ABC_DEFG_HIJ - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "ES") {//Espagne if (dol_strlen($phone) == 12) {//ex: +34_ABC_DEF_GHI - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); } } elseif (strtoupper($countrycode) == "BF") {// Burkina Faso if (dol_strlen($phone) == 12) {//ex : +22 A BC_DE_FG_HI - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "RO") {// Roumanie if (dol_strlen($phone) == 12) {//ex : +40 AB_CDE_FG_HI - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "TR") {//Turquie if (dol_strlen($phone) == 13) {//ex : +90 ABC_DEF_GHIJ - $newphone= substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4); + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4); } } elseif (strtoupper($countrycode) == "US") {//Etat-Unis if (dol_strlen($phone) == 12) {//ex: +1 ABC_DEF_GHIJ - $newphone= substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); } } elseif (strtoupper($countrycode) == "MX") @@ -2414,18 +2414,18 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } elseif (strtoupper($countrycode) == "ML") {//Mali - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +223 AB_CD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "TH") {//Thaïlande - if(dol_strlen($phone) == 11) + if (dol_strlen($phone) == 11) {//ex: +66_ABC_DE_FGH $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3); } - elseif(dol_strlen($phone) == 12) + elseif (dol_strlen($phone) == 12) {//ex: +66_A_BCD_EF_GHI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 3); } @@ -2433,240 +2433,240 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli elseif (strtoupper($countrycode) == "MU") { //Maurice - if(dol_strlen($phone) == 11) + if (dol_strlen($phone) == 11) {//ex: +230_ABC_DE_FG $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); } - elseif(dol_strlen($phone) == 12) + elseif (dol_strlen($phone) == 12) {//ex: +230_ABCD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "ZA") {//Afrique du sud - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +27_AB_CDE_FG_HI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "SY") {//Syrie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +963_AB_CD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } - elseif(dol_strlen($phone) == 13) + elseif (dol_strlen($phone) == 13) {//ex: +963_AB_CD_EF_GHI $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "AE") {//Emirats Arabes Unis - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +971_ABC_DEF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2); } - elseif(dol_strlen($phone) == 13) + elseif (dol_strlen($phone) == 13) {//ex: +971_ABC_DEF_GHI $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); } - elseif(dol_strlen($phone) == 14) + elseif (dol_strlen($phone) == 14) {//ex: +971_ABC_DEF_GHIK $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4); } } elseif (strtoupper($countrycode) == "DZ") {//Algérie - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +213_ABC_DEF_GHI $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "BE") {//Belgique - if(dol_strlen($phone) == 11) + if (dol_strlen($phone) == 11) {//ex: +32_ABC_DE_FGH $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3); } - elseif(dol_strlen($phone) == 12) + elseif (dol_strlen($phone) == 12) {//ex: +32_ABC_DEF_GHI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); } } elseif (strtoupper($countrycode) == "PF") {//Polynésie française - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +689_AB_CD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } } elseif (strtoupper($countrycode) == "CO") {//Colombie - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +57_ABC_DEF_GH_IJ $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } elseif (strtoupper($countrycode) == "JO") {//Jordanie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +962_A_BCD_EF_GH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); } } elseif (strtoupper($countrycode) == "JM") {//Jamaïque - if(dol_strlen($newphone) == 12) + if (dol_strlen($newphone) == 12) {//ex: +1867_ABC_DEFG $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); } } elseif (strtoupper($countrycode) == "MG") {//Madagascar - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EF_GHI $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "GB") {//Royaume uni - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +44_ABCD_EFG_HIJ $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); } } elseif (strtoupper($countrycode) == "CH") {//Suisse - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +41_AB_CDE_FG_HI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); } - elseif(dol_strlen($phone) == 15) + elseif (dol_strlen($phone) == 15) {// +41_AB_CDE_FGH_IJKL - $newphone =$newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 4); + $newphone = $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 4); } } elseif (strtoupper($countrycode) == "TN") {//Tunisie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +216_AB_CDE_FGH $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); } } elseif (strtoupper($countrycode) == "GF") {//Guyane francaise - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +594_ABC_DE_FG_HI (ABC=594 de nouveau) $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } elseif (strtoupper($countrycode) == "GP") {//Guadeloupe - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +590_ABC_DE_FG_HI (ABC=590 de nouveau) $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } elseif (strtoupper($countrycode) == "MQ") {//Martinique - if(dol_strlen($phone) == 13) + if (dol_strlen($phone) == 13) {//ex: +596_ABC_DE_FG_HI (ABC=596 de nouveau) $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } elseif (strtoupper($countrycode) == "IT") {//Italie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) {//ex: +39_ABC_DEF_GHI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); } - elseif(dol_strlen($phone) == 13) + elseif (dol_strlen($phone) == 13) {//ex: +39_ABC_DEF_GH_IJ $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); } } - elseif(strtoupper($countrycode) == "AU") + elseif (strtoupper($countrycode) == "AU") { //Australie - if(dol_strlen($phone) == 12) + if (dol_strlen($phone) == 12) { //ex: +61_A_BCDE_FGHI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4); } } - if (! empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) + if (!empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) { - if ($conf->browser->layout == 'phone' || (! empty($conf->clicktodial->enabled) && ! empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone + if ($conf->browser->layout == 'phone' || (!empty($conf->clicktodial->enabled) && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone { - $newphone =''; + $newphone = ''; } - elseif (! empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') // If click to dial, we use click to dial url + elseif (!empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') // If click to dial, we use click to dial url { if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial(); // Define urlmask - $urlmask='ErrorClickToDialModuleNotConfigured'; - if (! empty($conf->global->CLICKTODIAL_URL)) $urlmask=$conf->global->CLICKTODIAL_URL; - if (! empty($user->clicktodial_url)) $urlmask=$user->clicktodial_url; + $urlmask = 'ErrorClickToDialModuleNotConfigured'; + if (!empty($conf->global->CLICKTODIAL_URL)) $urlmask = $conf->global->CLICKTODIAL_URL; + if (!empty($user->clicktodial_url)) $urlmask = $user->clicktodial_url; - $clicktodial_poste=(! empty($user->clicktodial_poste)?urlencode($user->clicktodial_poste):''); - $clicktodial_login=(! empty($user->clicktodial_login)?urlencode($user->clicktodial_login):''); - $clicktodial_password=(! empty($user->clicktodial_password)?urlencode($user->clicktodial_password):''); + $clicktodial_poste = (!empty($user->clicktodial_poste) ?urlencode($user->clicktodial_poste) : ''); + $clicktodial_login = (!empty($user->clicktodial_login) ?urlencode($user->clicktodial_login) : ''); + $clicktodial_password = (!empty($user->clicktodial_password) ?urlencode($user->clicktodial_password) : ''); // This line is for backward compatibility $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password); // Thoose lines are for substitution - $substitarray=array('__PHONEFROM__'=>$clicktodial_poste, + $substitarray = array('__PHONEFROM__'=>$clicktodial_poste, '__PHONETO__'=>urlencode($phone), '__LOGIN__'=>$clicktodial_login, '__PASS__'=>$clicktodial_password); $url = make_substitutions($url, $substitarray); - $newphonesav=$newphone; - $newphone ='global->CLICKTODIAL_FORCENEWTARGET)) $newphone.=' target="_blank"'; - $newphone.='>'.$newphonesav.''; + $newphonesav = $newphone; + $newphone = 'global->CLICKTODIAL_FORCENEWTARGET)) $newphone .= ' target="_blank"'; + $newphone .= '>'.$newphonesav.''; } //if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) - if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) + if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { - $type='AC_TEL'; $link=''; - if ($addlink == 'AC_FAX') $type='AC_FAX'; - if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link=''.img_object($langs->trans("AddAction"), "calendar").''; - if ($link) $newphone='
'.$newphone.' '.$link.'
'; + $type = 'AC_TEL'; $link = ''; + if ($addlink == 'AC_FAX') $type = 'AC_FAX'; + if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link = ''.img_object($langs->trans("AddAction"), "calendar").''; + if ($link) $newphone = '
'.$newphone.' '.$link.'
'; } } if (empty($titlealt)) { - $titlealt=($withpicto=='fax'?$langs->trans("Fax"):$langs->trans("Phone")); + $titlealt = ($withpicto == 'fax' ? $langs->trans("Fax") : $langs->trans("Phone")); } - $rep=''; + $rep = ''; if ($hookmanager) { - $parameters = array('countrycode' => $countrycode, 'cid' => $cid, 'socid' => $socid,'titlealt' => $titlealt, 'picto' => $withpicto); + $parameters = array('countrycode' => $countrycode, 'cid' => $cid, 'socid' => $socid, 'titlealt' => $titlealt, 'picto' => $withpicto); $reshook = $hookmanager->executeHooks('printPhone', $parameters, $phone); - $rep.=$hookmanager->resPrint; + $rep .= $hookmanager->resPrint; } if (empty($reshook)) { $picto = ''; - if($withpicto){ - if($withpicto=='fax'){ + if ($withpicto) { + if ($withpicto == 'fax') { $picto = 'phoning_fax'; - }elseif($withpicto=='phone'){ + }elseif ($withpicto == 'phone') { $picto = 'phoning'; - }elseif($withpicto=='mobile'){ + }elseif ($withpicto == 'mobile') { $picto = 'phoning_mobile'; - }else{ + } else { $picto = ''; } } - if ($adddivfloat) $rep.='
'; - else $rep.=''; - $rep.=($withpicto?img_picto($titlealt, 'object_'.$picto.'.png').' ':'').$newphone; - if ($adddivfloat) $rep.='
'; - else $rep.=''; + if ($adddivfloat) $rep .= '
'; + else $rep .= ''; + $rep .= ($withpicto ?img_picto($titlealt, 'object_'.$picto.'.png').' ' : '').$newphone; + if ($adddivfloat) $rep .= '
'; + else $rep .= ''; } return $rep; @@ -2681,22 +2681,22 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli */ function dol_print_ip($ip, $mode = 0) { - global $conf,$langs; + global $conf, $langs; - $ret=''; + $ret = ''; - if (empty($mode)) $ret.=$ip; + if (empty($mode)) $ret .= $ip; if ($mode != 2) { - $countrycode=dolGetCountryCodeFromIp($ip); + $countrycode = dolGetCountryCodeFromIp($ip); if ($countrycode) // If success, countrycode is us, fr, ... { if (file_exists(DOL_DOCUMENT_ROOT.'/theme/common/flags/'.$countrycode.'.png')) { - $ret.=' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"), DOL_URL_ROOT.'/theme/common/flags/'.$countrycode.'.png', '', 1); + $ret .= ' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"), DOL_URL_ROOT.'/theme/common/flags/'.$countrycode.'.png', '', 1); } - else $ret.=' ('.$countrycode.')'; + else $ret .= ' ('.$countrycode.')'; } else { @@ -2717,7 +2717,7 @@ function dol_print_ip($ip, $mode = 0) */ function getUserRemoteIP() { - $ip = empty($_SERVER['HTTP_X_FORWARDED_FOR'])? (empty($_SERVER['HTTP_CLIENT_IP'])?(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']):$_SERVER['HTTP_CLIENT_IP']) : $_SERVER['HTTP_X_FORWARDED_FOR']; + $ip = empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? (empty($_SERVER['HTTP_CLIENT_IP']) ? (empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']) : $_SERVER['HTTP_CLIENT_IP']) : $_SERVER['HTTP_X_FORWARDED_FOR']; return $ip; } @@ -2731,17 +2731,17 @@ function dolGetCountryCodeFromIp($ip) { global $conf; - $countrycode=''; + $countrycode = ''; - if (! empty($conf->geoipmaxmind->enabled)) + if (!empty($conf->geoipmaxmind->enabled)) { - $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; + $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; //$ip='24.24.24.24'; //$datafile='/usr/share/GeoIP/GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; - $geoip=new DolGeoIP('country', $datafile); + $geoip = new DolGeoIP('country', $datafile); //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n"; - $countrycode=$geoip->getCountryCodeFromIP($ip); + $countrycode = $geoip->getCountryCodeFromIP($ip); } return $countrycode; @@ -2756,20 +2756,20 @@ function dolGetCountryCodeFromIp($ip) */ function dol_user_country() { - global $conf,$langs,$user; + global $conf, $langs, $user; //$ret=$user->xxx; - $ret=''; - if (! empty($conf->geoipmaxmind->enabled)) + $ret = ''; + if (!empty($conf->geoipmaxmind->enabled)) { - $ip=getUserRemoteIP(); - $datafile=$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; + $ip = getUserRemoteIP(); + $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; //$ip='24.24.24.24'; //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; - $geoip=new DolGeoIP('country', $datafile); - $countrycode=$geoip->getCountryCodeFromIP($ip); - $ret=$countrycode; + $geoip = new DolGeoIP('country', $datafile); + $countrycode = $geoip->getCountryCodeFromIP($ip); + $ret = $countrycode; } return $ret; } @@ -2797,32 +2797,32 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint = 0, $charfor if ($hookmanager) { $parameters = array('element' => $mode, 'id' => $id); $reshook = $hookmanager->executeHooks('printAddress', $parameters, $address); - $out.=$hookmanager->resPrint; + $out .= $hookmanager->resPrint; } if (empty($reshook)) { - if (empty($charfornl)) $out.=nl2br($address); - else $out.=preg_replace('/[\r\n]+/', $charfornl, $address); + if (empty($charfornl)) $out .= nl2br($address); + else $out .= preg_replace('/[\r\n]+/', $charfornl, $address); - $showgmap=$showomap=0; + $showgmap = $showomap = 0; // TODO Add a hook here - if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; - if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap=1; - if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap=1; - if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; - if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap=1; - if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap=1; + if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap = 1; + if ($mode == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap = 1; + if ($mode == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap = 1; + if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap = 1; + if ($mode == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap = 1; + if ($mode == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap = 1; if ($showgmap) { - $url=dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id, 1); - $out.=' '; + $url = dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id, 1); + $out .= ' '; } if ($showomap) { - $url=dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id, 1); - $out.=' '; + $url = dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id, 1); + $out .= ' '; } } } @@ -2857,17 +2857,17 @@ function isValidMXRecord($domain) { if (function_exists('idn_to_ascii') && function_exists('checkdnsrr')) { - if (! checkdnsrr(idn_to_ascii($domain), 'MX')) + if (!checkdnsrr(idn_to_ascii($domain), 'MX')) { return 0; } if (function_exists('getmxrr')) { - $mxhosts=array(); - $weight=array(); + $mxhosts = array(); + $weight = array(); getmxrr(idn_to_ascii($domain), $mxhosts, $weight); if (count($mxhosts) > 1) return 1; - if (count($mxhosts) == 1 && ! empty($mxhosts[0])) return 1; + if (count($mxhosts) == 1 && !empty($mxhosts[0])) return 1; return 0; } @@ -2915,29 +2915,29 @@ function dol_substr($string, $start, $length, $stringencoding = '', $trunconbyte { global $langs; - if (empty($stringencoding)) $stringencoding=$langs->charset_output; + if (empty($stringencoding)) $stringencoding = $langs->charset_output; - $ret=''; + $ret = ''; if (empty($trunconbytes)) { if (function_exists('mb_substr')) { - $ret=mb_substr($string, $start, $length, $stringencoding); + $ret = mb_substr($string, $start, $length, $stringencoding); } else { - $ret=substr($string, $start, $length); + $ret = substr($string, $start, $length); } } else { if (function_exists('mb_strcut')) { - $ret=mb_strcut($string, $start, $length, $stringencoding); + $ret = mb_strcut($string, $start, $length, $stringencoding); } else { - $ret=substr($string, $start, $length); + $ret = substr($string, $start, $length); } } return $ret; @@ -2961,29 +2961,29 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF { global $conf; - if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; + if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; - if (empty($stringencoding)) $stringencoding='UTF-8'; + if (empty($stringencoding)) $stringencoding = 'UTF-8'; // reduce for small screen - if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3); + if ($conf->dol_optimize_smallscreen == 1 && $display == 1) $size = round($size / 3); // We go always here if ($trunc == 'right') { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string, 1):$string; - if (dol_strlen($newstring, $stringencoding) > ($size+($nodot?0:3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... - return dol_substr($newstring, 0, $size, $stringencoding).($nodot?'':'...'); + $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... + return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '...'); else //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; return $string; } elseif ($trunc == 'middle') { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string, 1):$string; - if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size+1)) + $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) { - $size1=round($size/2); - $size2=round($size/2); + $size1 = round($size / 2); + $size2 = round($size / 2); return dol_substr($newstring, 0, $size1, $stringencoding).'...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); } else @@ -2991,17 +2991,17 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF } elseif ($trunc == 'left') { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string, 1):$string; - if (dol_strlen($newstring, $stringencoding) > ($size+($nodot?0:3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... + $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... return '...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); else return $string; } elseif ($trunc == 'wrap') { - $newstring=dol_textishtml($string)?dol_string_nohtmltag($string, 1):$string; - if (dol_strlen($newstring, $stringencoding) > ($size+1)) - return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding)-$size, $stringencoding), $size, $trunc); + $newstring = dol_textishtml($string) ?dol_string_nohtmltag($string, 1) : $string; + if (dol_strlen($newstring, $stringencoding) > ($size + 1)) + return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); else return $string; } @@ -3039,13 +3039,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ // Define fullpathpicto to use into src if ($pictoisfullpath) { // Clean parameters - if (! preg_match('/(\.png|\.gif|\.svg)$/i', $picto)) { + if (!preg_match('/(\.png|\.gif|\.svg)$/i', $picto)) { $picto .= '.png'; } $fullpathpicto = $picto; - $reg=array(); + $reg = array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { - $morecss .= ($morecss ? ' ' : '') . $reg[1]; + $morecss .= ($morecss ? ' ' : '').$reg[1]; $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); } } else { @@ -3056,25 +3056,25 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'address', 'bank', 'bookmark', 'building', 'cash-register', 'close_title', 'cubes', 'delete', 'dolly', 'edit', 'ellipsis-h', 'filter', 'file-code', 'grip', 'grip_title', 'list', 'listlight', 'note', - 'object_bookmark', 'object_list','object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', + 'object_bookmark', 'object_list', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'stats', 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'wrench', 'globe', - 'jabber','skype','twitter','facebook','linkedin', - 'instagram', 'snapchat', 'youtube', 'google-plus-g','whatsapp', - 'chevron-left','chevron-right','chevron-down','chevron-top', + 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', + 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', + 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'home', 'companies', 'products', 'commercial', 'invoicing', 'accountancy', 'project', 'hrm', 'members', 'ticket', 'generic', - 'error','warning', + 'error', 'warning', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda' ) )) { $fakey = $pictowithouttext; $facolor = ''; $fasize = ''; - $fa='fas'; + $fa = 'fas'; if (in_array($pictowithouttext, array('off', 'on', 'object_bookmark', 'bookmark'))) { - $fa='far'; + $fa = 'far'; } - if (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram','snapchat','youtube','google-plus-g','whatsapp'))) { - $fa='fab'; + if (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp'))) { + $fa = 'fab'; } $arrayconvpictotofa = array( @@ -3082,7 +3082,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'hrm'=>'umbrella-beach', 'members'=>'users', 'ticket'=>'ticket-alt', 'generic'=>'folder-open', 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'object_bookmark'=>'star', 'bookmark'=>'star', 'stats' => 'chart-bar', 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil', 'filter'=>'filter', 'split'=>'code-fork', - 'object_list'=>'list-alt','object_calendar'=>'calendar-alt', 'object_calendarweek'=>'calendar-week', 'object_calendarmonth'=>'calendar-alt', 'object_calendarday'=>'calendar-day', 'object_calendarperuser'=>'table', + 'object_list'=>'list-alt', 'object_calendar'=>'calendar-alt', 'object_calendarweek'=>'calendar-week', 'object_calendarmonth'=>'calendar-alt', 'object_calendarday'=>'calendar-day', 'object_calendarperuser'=>'table', 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt' ); @@ -3129,7 +3129,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithouttext == 'listlight') { $fakey = 'fa-download'; $facolor = '#999'; - $marginleftonlyshort=1; + $marginleftonlyshort = 1; } elseif ($pictowithouttext == 'printer') { $fakey = 'fa-print'; @@ -3144,21 +3144,21 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-sticky-note'; $fa = 'far'; $facolor = '#999'; - $marginleftonlyshort=1; + $marginleftonlyshort = 1; } elseif ($pictowithouttext == 'uparrow') { $fakey = 'fa-mail-forward'; $facolor = '#555'; } elseif (in_array($pictowithouttext, array('1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected'))) { - $convertarray=array('1uparrow'=>'caret-up', '1downarrow'=>'caret-down', '1leftarrow'=>'caret-left', '1rightarrow'=>'caret-right', '1uparrow_selected'=>'caret-up', '1downarrow_selected'=>'caret-down', '1leftarrow_selected'=>'caret-left', '1rightarrow_selected'=>'caret-right'); + $convertarray = array('1uparrow'=>'caret-up', '1downarrow'=>'caret-down', '1leftarrow'=>'caret-left', '1rightarrow'=>'caret-right', '1uparrow_selected'=>'caret-up', '1downarrow_selected'=>'caret-down', '1leftarrow_selected'=>'caret-left', '1rightarrow_selected'=>'caret-right'); $fakey = 'fa-'.$convertarray[$pictowithouttext]; if (preg_match('/selected/', $pictowithouttext)) $facolor = '#888'; $marginleftonlyshort = 1; } elseif ($pictowithouttext == 'sign-out') { $fakey = 'fa-sign-out-alt'; - $marginleftonlyshort=0; + $marginleftonlyshort = 0; } elseif ($pictowithouttext == 'unlink') { $fakey = 'fa-unlink'; @@ -3178,61 +3178,61 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ // Img for type of views elseif (in_array($pictowithouttext, array('object_list', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser'))) { $fakey = 'imgforviewmode fa-'.$arrayconvpictotofa[$pictowithouttext]; - $marginleftonlyshort=0; + $marginleftonlyshort = 0; } - elseif (! empty($arrayconvpictotofa[$pictowithouttext])) + elseif (!empty($arrayconvpictotofa[$pictowithouttext])) { $fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext]; //$facolor = '#444'; - $marginleftonlyshort=0; + $marginleftonlyshort = 0; } else { $fakey = 'fa-'.$pictowithouttext; //$facolor = '#444'; - $marginleftonlyshort=0; + $marginleftonlyshort = 0; } //this snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only. //class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes - $reg=array(); + $reg = array(); if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { - $morecss .= ($morecss ? ' ' : '') . $reg[1]; + $morecss .= ($morecss ? ' ' : '').$reg[1]; $moreatt = str_replace('class="'.$reg[1].'"', '', $moreatt); } if (preg_match('/style="([^"]+)"/', $moreatt, $reg)) { - $morestyle = ' '. $reg[1]; + $morestyle = ' '.$reg[1]; $moreatt = str_replace('style="'.$reg[1].'"', '', $moreatt); } - $moreatt=trim($moreatt); + $moreatt = trim($moreatt); - $enabledisablehtml = ''; - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $enabledisablehtml.= $titlealt; + $enabledisablehtml = ''; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $enabledisablehtml .= $titlealt; } - $enabledisablehtml.= ''; + $enabledisablehtml .= ''; return $enabledisablehtml; } - if (! empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) { - $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module + if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) { + $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module } - elseif (! empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { - $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme + elseif (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { + $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme } - elseif (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { - $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module + elseif (!empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { + $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module } // If we ask an image into $url/$mymodule/img (instead of default path) if (preg_match('/^([^@]+)@([^@]+)$/i', $picto, $regs)) { $picto = $regs[1]; - $path = $regs[2]; // $path is $mymodule + $path = $regs[2]; // $path is $mymodule } // Clean parameters - if (! preg_match('/(\.png|\.gif|\.svg)$/i', $picto)) { + if (!preg_match('/(\.png|\.gif|\.svg)$/i', $picto)) { $picto .= '.png'; } // If alt path are defined, define url where img file is, according to physical path @@ -3256,7 +3256,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ return $fullpathpicto; } // tag title is used for tooltip on , tag alt can be used with very simple text on image for blind people - return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup + return ''.dol_escape_htmltag($alt).''; // Alt is used for accessibility, title for popup } /** @@ -3294,11 +3294,11 @@ function img_weather($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $mo if (is_numeric($picto)) { - $leveltopicto=array(0=>'weather-clear.png', 1=>'weather-few-clouds.png', 2=>'weather-clouds.png', 3=>'weather-many-clouds.png', 4=>'weather-storm.png'); + $leveltopicto = array(0=>'weather-clear.png', 1=>'weather-few-clouds.png', 2=>'weather-clouds.png', 3=>'weather-many-clouds.png', 4=>'weather-storm.png'); //return ''; $picto = $leveltopicto[$picto]; } - elseif (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; + elseif (!preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; $path = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/weather/'.$picto; @@ -3319,14 +3319,14 @@ function img_picto_common($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0 { global $conf; - if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; + if (!preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; if ($pictoisfullpath) $path = $picto; else { $path = DOL_URL_ROOT.'/theme/common/'.$picto; - if (! empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) + if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) { $themepath = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto; @@ -3350,14 +3350,14 @@ function img_action($titlealt, $numaction) if (empty($titlealt) || $titlealt == 'default') { - if ($numaction == '-1' || $numaction == 'ST_NO') { $numaction = -1; $titlealt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); } - elseif ($numaction == '0' || $numaction == 'ST_NEVER') { $numaction = 0; $titlealt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); } - elseif ($numaction == '1' || $numaction == 'ST_TODO') { $numaction = 1; $titlealt = $langs->transnoentitiesnoconv('ChangeToContact'); } - elseif ($numaction == '2' || $numaction == 'ST_PEND') { $numaction = 2; $titlealt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); } - elseif ($numaction == '3' || $numaction == 'ST_DONE') { $numaction = 3; $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone'); } + if ($numaction == '-1' || $numaction == 'ST_NO') { $numaction = -1; $titlealt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); } + elseif ($numaction == '0' || $numaction == 'ST_NEVER') { $numaction = 0; $titlealt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); } + elseif ($numaction == '1' || $numaction == 'ST_TODO') { $numaction = 1; $titlealt = $langs->transnoentitiesnoconv('ChangeToContact'); } + elseif ($numaction == '2' || $numaction == 'ST_PEND') { $numaction = 2; $titlealt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); } + elseif ($numaction == '3' || $numaction == 'ST_DONE') { $numaction = 3; $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone'); } else { $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction); $numaction = 0; } } - if (! is_numeric($numaction)) $numaction=0; + if (!is_numeric($numaction)) $numaction = 0; return img_picto($titlealt, 'stcomm'.$numaction.'.png'); } @@ -3423,7 +3423,7 @@ function img_edit($titlealt = 'default', $float = 0, $other = '') if ($titlealt == 'default') $titlealt = $langs->trans('Modify'); - return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl'?'left':'right').'"' : "") . ($other?' '.$other:'')); + return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right').'"' : "").($other ? ' '.$other : '')); } /** @@ -3471,8 +3471,8 @@ function img_delete($titlealt = 'default', $other = 'class="pictodelete"') */ function img_printer($titlealt = "default", $other = '') { - global $conf,$langs; - if ($titlealt=="default") $titlealt=$langs->trans("Print"); + global $conf, $langs; + if ($titlealt == "default") $titlealt = $langs->trans("Print"); return img_picto($titlealt, 'printer.png', $other); } @@ -3509,7 +3509,7 @@ function img_help($usehelpcursor = 1, $usealttitle = 1) else $usealttitle = $langs->trans('Info'); } - return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;'.($usehelpcursor == 1 ? ' cursor: help': ($usehelpcursor == 2 ? ' cursor: pointer':'')).'"'); + return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;'.($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')).'"'); } /** @@ -3542,7 +3542,7 @@ function img_warning($titlealt = 'default', $moreatt = '', $morecss = 'pictowarn if ($titlealt == 'default') $titlealt = $langs->trans('Warning'); //return '
'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'
'; - return img_picto($titlealt, 'warning.png', 'class="'.$morecss.'"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')); + return img_picto($titlealt, 'warning.png', 'class="'.$morecss.'"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt) : '')); } /** @@ -3608,7 +3608,7 @@ function img_down($titlealt = 'default', $selected = 0, $moreclass = '') if ($titlealt == 'default') $titlealt = $langs->trans('Down'); - return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass?" ".$moreclass:"").'"'); + return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass ? " ".$moreclass : "").'"'); } /** @@ -3625,7 +3625,7 @@ function img_up($titlealt = 'default', $selected = 0, $moreclass = '') if ($titlealt == 'default') $titlealt = $langs->trans('Up'); - return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass?" ".$moreclass:"").'"'); + return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass ? " ".$moreclass : "").'"'); } /** @@ -3688,13 +3688,13 @@ function img_allow($allow, $titlealt = 'default') */ function img_credit_card($brand) { - if ($brand == 'visa' || $brand == 'Visa') {$brand='cc-visa';} - elseif ($brand == 'mastercard' || $brand == 'MasterCard') {$brand='cc-mastercard';} - elseif ($brand == 'amex' || $brand == 'American Express') {$brand='cc-amex';} - elseif ($brand == 'discover' || $brand == 'Discover') {$brand='cc-discover';} - elseif ($brand == 'jcb' || $brand == 'JCB') {$brand='cc-jcb';} - elseif ($brand == 'diners' || $brand == 'Diners club') {$brand='cc-diners-club';} - elseif (! in_array($brand, array('cc-visa','cc-mastercard','cc-amex','cc-discover','cc-jcb','cc-diners-club'))) {$brand='credit-card';} + if ($brand == 'visa' || $brand == 'Visa') {$brand = 'cc-visa'; } + elseif ($brand == 'mastercard' || $brand == 'MasterCard') {$brand = 'cc-mastercard'; } + elseif ($brand == 'amex' || $brand == 'American Express') {$brand = 'cc-amex'; } + elseif ($brand == 'discover' || $brand == 'Discover') {$brand = 'cc-discover'; } + elseif ($brand == 'jcb' || $brand == 'JCB') {$brand = 'cc-jcb'; } + elseif ($brand == 'diners' || $brand == 'Diners club') {$brand = 'cc-diners-club'; } + elseif (!in_array($brand, array('cc-visa', 'cc-mastercard', 'cc-amex', 'cc-discover', 'cc-jcb', 'cc-diners-club'))) {$brand = 'credit-card'; } return ''; } @@ -3738,7 +3738,7 @@ function img_search($titlealt = 'default', $other = '') $img = img_picto($titlealt, 'search.png', $other, false, 1); $input = ''; + $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >'; return $input; } @@ -3759,7 +3759,7 @@ function img_searchclear($titlealt = 'default', $other = '') $img = img_picto($titlealt, 'searchclear.png', $other, false, 1); $input = ''; + $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >'; return $input; } @@ -3780,10 +3780,10 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss if ($infoonimgalt) { - return img_picto($text, 'info', 'class="hideonsmartphone'.($morecss?' '.$morecss:'').'"'); + return img_picto($text, 'info', 'class="hideonsmartphone'.($morecss ? ' '.$morecss : '').'"'); } - return ($nodiv?'':'
').' '.$text.($nodiv?'':'
'); + return ($nodiv ? '' : '
').' '.$text.($nodiv ? '' : '
'); } @@ -3800,16 +3800,16 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss */ function dol_print_error($db = '', $error = '', $errors = null) { - global $conf,$langs,$argv; + global $conf, $langs, $argv; global $dolibarr_main_prod; $out = ''; $syslog = ''; // Si erreur intervenue avant chargement langue - if (! $langs) + if (!$langs) { - require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); $langs->load("main"); } @@ -3818,62 +3818,62 @@ function dol_print_error($db = '', $error = '', $errors = null) if ($_SERVER['DOCUMENT_ROOT']) // Mode web { - $out.=$langs->trans("DolibarrHasDetectedError").".
\n"; - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $out.="You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.
\n"; - $out.=$langs->trans("InformationToHelpDiagnose").":
\n"; + $out .= $langs->trans("DolibarrHasDetectedError").".
\n"; + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.
\n"; + $out .= $langs->trans("InformationToHelpDiagnose").":
\n"; - $out.="".$langs->trans("Date").": ".dol_print_date(time(), 'dayhourlog')."
\n"; - $out.="".$langs->trans("Dolibarr").": ".DOL_VERSION."
\n"; - if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="".$langs->trans("LevelOfFeature").": ".$conf->global->MAIN_FEATURES_LEVEL."
\n"; + $out .= "".$langs->trans("Date").": ".dol_print_date(time(), 'dayhourlog')."
\n"; + $out .= "".$langs->trans("Dolibarr").": ".DOL_VERSION."
\n"; + if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out .= "".$langs->trans("LevelOfFeature").": ".$conf->global->MAIN_FEATURES_LEVEL."
\n"; if (function_exists("phpversion")) { - $out.="".$langs->trans("PHP").": ".phpversion()."
\n"; + $out .= "".$langs->trans("PHP").": ".phpversion()."
\n"; } - $out.="".$langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."
\n"; + $out .= "".$langs->trans("Server").": ".$_SERVER["SERVER_SOFTWARE"]."
\n"; if (function_exists("php_uname")) { - $out.="".$langs->trans("OS").": ".php_uname()."
\n"; + $out .= "".$langs->trans("OS").": ".php_uname()."
\n"; } - $out.="".$langs->trans("UserAgent").": ".$_SERVER["HTTP_USER_AGENT"]."
\n"; - $out.="
\n"; - $out.="".$langs->trans("RequestedUrl").": ".dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8')."
\n"; - $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8'):'')."
\n"; - $out.="".$langs->trans("MenuManager").": ".(isset($conf->standard_menu)?$conf->standard_menu:'')."
\n"; - $out.="
\n"; - $syslog.="url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]); - $syslog.=", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]); + $out .= "".$langs->trans("UserAgent").": ".$_SERVER["HTTP_USER_AGENT"]."
\n"; + $out .= "
\n"; + $out .= "".$langs->trans("RequestedUrl").": ".dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8')."
\n"; + $out .= "".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"]) ?dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '')."
\n"; + $out .= "".$langs->trans("MenuManager").": ".(isset($conf->standard_menu) ? $conf->standard_menu : '')."
\n"; + $out .= "
\n"; + $syslog .= "url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]); + $syslog .= ", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]); } else // Mode CLI { - $out.='> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; - $syslog.="pid=".dol_getmypid(); + $out .= '> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; + $syslog .= "pid=".dol_getmypid(); } - if (! empty($conf->modules)) + if (!empty($conf->modules)) { - $out.="".$langs->trans("Modules").": ".join(', ', $conf->modules)."
\n"; + $out .= "".$langs->trans("Modules").": ".join(', ', $conf->modules)."
\n"; } if (is_object($db)) { if ($_SERVER['DOCUMENT_ROOT']) // Mode web { - $out.="".$langs->trans("DatabaseTypeManager").": ".$db->type."
\n"; - $out.="".$langs->trans("RequestLastAccessInError").": ".($db->lastqueryerror()?dol_escape_htmltag($db->lastqueryerror()):$langs->trans("ErrorNoRequestInError"))."
\n"; - $out.="".$langs->trans("ReturnCodeLastAccessInError").": ".($db->lasterrno()?dol_escape_htmltag($db->lasterrno()):$langs->trans("ErrorNoRequestInError"))."
\n"; - $out.="".$langs->trans("InformationLastAccessInError").": ".($db->lasterror()?dol_escape_htmltag($db->lasterror()):$langs->trans("ErrorNoRequestInError"))."
\n"; - $out.="
\n"; + $out .= "".$langs->trans("DatabaseTypeManager").": ".$db->type."
\n"; + $out .= "".$langs->trans("RequestLastAccessInError").": ".($db->lastqueryerror() ?dol_escape_htmltag($db->lastqueryerror()) : $langs->trans("ErrorNoRequestInError"))."
\n"; + $out .= "".$langs->trans("ReturnCodeLastAccessInError").": ".($db->lasterrno() ?dol_escape_htmltag($db->lasterrno()) : $langs->trans("ErrorNoRequestInError"))."
\n"; + $out .= "".$langs->trans("InformationLastAccessInError").": ".($db->lasterror() ?dol_escape_htmltag($db->lasterror()) : $langs->trans("ErrorNoRequestInError"))."
\n"; + $out .= "
\n"; } else // Mode CLI { // No dol_escape_htmltag for output, we are in CLI mode - $out.='> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n"; - $out.='> '.$langs->transnoentities("RequestLastAccessInError").":\n".($db->lastqueryerror()?$db->lastqueryerror():$langs->transnoentities("ErrorNoRequestInError"))."\n"; - $out.='> '.$langs->transnoentities("ReturnCodeLastAccessInError").":\n".($db->lasterrno()?$db->lasterrno():$langs->transnoentities("ErrorNoRequestInError"))."\n"; - $out.='> '.$langs->transnoentities("InformationLastAccessInError").":\n".($db->lasterror()?$db->lasterror():$langs->transnoentities("ErrorNoRequestInError"))."\n"; + $out .= '> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n"; + $out .= '> '.$langs->transnoentities("RequestLastAccessInError").":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities("ErrorNoRequestInError"))."\n"; + $out .= '> '.$langs->transnoentities("ReturnCodeLastAccessInError").":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities("ErrorNoRequestInError"))."\n"; + $out .= '> '.$langs->transnoentities("InformationLastAccessInError").":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities("ErrorNoRequestInError"))."\n"; } - $syslog.=", sql=".$db->lastquery(); - $syslog.=", db_error=".$db->lasterror(); + $syslog .= ", sql=".$db->lastquery(); + $syslog .= ", db_error=".$db->lasterror(); } if ($error || $errors) @@ -3881,33 +3881,33 @@ function dol_print_error($db = '', $error = '', $errors = null) $langs->load("errors"); // Merge all into $errors array - if (is_array($error) && is_array($errors)) $errors=array_merge($error, $errors); - elseif (is_array($error)) $errors=$error; - elseif (is_array($errors)) $errors=array_merge(array($error), $errors); - else $errors=array_merge(array($error)); + if (is_array($error) && is_array($errors)) $errors = array_merge($error, $errors); + elseif (is_array($error)) $errors = $error; + elseif (is_array($errors)) $errors = array_merge(array($error), $errors); + else $errors = array_merge(array($error)); - foreach($errors as $msg) + foreach ($errors as $msg) { if (empty($msg)) continue; if ($_SERVER['DOCUMENT_ROOT']) // Mode web { - $out.="".$langs->trans("Message").": ".dol_escape_htmltag($msg)."
\n" ; + $out .= "".$langs->trans("Message").": ".dol_escape_htmltag($msg)."
\n"; } else // Mode CLI { - $out.='> '.$langs->transnoentities("Message").":\n".$msg."\n" ; + $out .= '> '.$langs->transnoentities("Message").":\n".$msg."\n"; } - $syslog.=", msg=".$msg; + $syslog .= ", msg=".$msg; } } if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_print_function_stack') && function_exists('xdebug_call_file')) { xdebug_print_function_stack(); - $out.='XDebug informations:'."
\n"; - $out.='File: '.xdebug_call_file()."
\n"; - $out.='Line: '.xdebug_call_line()."
\n"; - $out.='Function: '.xdebug_call_function()."
\n"; - $out.="
\n"; + $out .= 'XDebug informations:'."
\n"; + $out .= 'File: '.xdebug_call_file()."
\n"; + $out .= 'Line: '.xdebug_call_line()."
\n"; + $out .= 'Function: '.xdebug_call_function()."
\n"; + $out .= "
\n"; } if (empty($dolibarr_main_prod)) print $out; @@ -3935,19 +3935,19 @@ function dol_print_error($db = '', $error = '', $errors = null) */ function dol_print_error_email($prefixcode, $errormessage = '', $errormessages = array(), $morecss = 'error', $email = '') { - global $langs,$conf; + global $langs, $conf; - if (empty($email)) $email=$conf->global->MAIN_INFO_SOCIETE_MAIL; + if (empty($email)) $email = $conf->global->MAIN_INFO_SOCIETE_MAIL; $langs->load("errors"); - $now=dol_now(); + $now = dol_now(); print '
'; print $langs->trans("ErrorContactEMail", $email, $prefixcode.dol_print_date($now, '%Y%m%d%H%M%S')); if ($errormessage) print '

'.$errormessage; if (is_array($errormessages) && count($errormessages)) { - foreach($errormessages as $mesgtoshow) + foreach ($errormessages as $mesgtoshow) { print '

'.$mesgtoshow; } @@ -3997,76 +3997,76 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin global $conf, $langs, $form; //print "$name, $file, $field, $begin, $options, $moreattrib, $sortfield, $sortorder
\n"; - if ($moreattrib == 'class="right"') $prefix.='right '; // For backward compatibility + if ($moreattrib == 'class="right"') $prefix .= 'right '; // For backward compatibility - $sortorder=strtoupper($sortorder); - $out=''; - $sortimg=''; + $sortorder = strtoupper($sortorder); + $out = ''; + $sortimg = ''; - $tag='th'; - if ($thead==2) $tag='div'; + $tag = 'th'; + if ($thead == 2) $tag = 'div'; - $tmpsortfield=explode(',', $sortfield); - $sortfield1=trim($tmpsortfield[0]); // If $sortfield is 'd.datep,d.id', it becomes 'd.datep' - $tmpfield=explode(',', $field); - $field1=trim($tmpfield[0]); // If $field is 'd.datep,d.id', it becomes 'd.datep' + $tmpsortfield = explode(',', $sortfield); + $sortfield1 = trim($tmpsortfield[0]); // If $sortfield is 'd.datep,d.id', it becomes 'd.datep' + $tmpfield = explode(',', $field); + $field1 = trim($tmpfield[0]); // If $field is 'd.datep,d.id', it becomes 'd.datep' //var_dump('field='.$field.' field1='.$field1.' sortfield='.$sortfield.' sortfield1='.$sortfield1); // If field is used as sort criteria we use a specific css class liste_titre_sel // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") - if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./", "", $field1))) $out.= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '. $moreattrib.'>'; - else $out.= '<'.$tag.' class="'.$prefix.'liste_titre" '. $moreattrib.'>'; + if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./", "", $field1))) $out .= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '.$moreattrib.'>'; + else $out .= '<'.$tag.' class="'.$prefix.'liste_titre" '.$moreattrib.'>'; if (empty($thead) && $field && empty($disablesortlink)) // If this is a sort field { - $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i', '', $moreparam); - $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options); - $options=preg_replace('/&+/i', '&', $options); - if (! preg_match('/^&/', $options)) $options='&'.$options; + $options = preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i', '', $moreparam); + $options = preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options); + $options = preg_replace('/&+/i', '&', $options); + if (!preg_match('/^&/', $options)) $options = '&'.$options; - $sortordertouseinlink=''; + $sortordertouseinlink = ''; if ($field1 != $sortfield1) // We are on another field than current sorted field { if (preg_match('/^DESC/i', $sortorder)) { - $sortordertouseinlink.=str_repeat('desc,', count(explode(',', $field))); + $sortordertouseinlink .= str_repeat('desc,', count(explode(',', $field))); } else // We reverse the var $sortordertouseinlink { - $sortordertouseinlink.=str_repeat('asc,', count(explode(',', $field))); + $sortordertouseinlink .= str_repeat('asc,', count(explode(',', $field))); } } else // We are on field that is the first current sorting criteria { if (preg_match('/^ASC/i', $sortorder)) // We reverse the var $sortordertouseinlink { - $sortordertouseinlink.=str_repeat('desc,', count(explode(',', $field))); + $sortordertouseinlink .= str_repeat('desc,', count(explode(',', $field))); } else { - $sortordertouseinlink.=str_repeat('asc,', count(explode(',', $field))); + $sortordertouseinlink .= str_repeat('asc,', count(explode(',', $field))); } } - $sortordertouseinlink=preg_replace('/,$/', '', $sortordertouseinlink); - $out.= '
'; + $sortordertouseinlink = preg_replace('/,$/', '', $sortordertouseinlink); + $out .= ''; } - if ($tooltip) $out.=$form->textwithpicto($langs->trans($name), $langs->trans($tooltip)); - else $out.=$langs->trans($name); + if ($tooltip) $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tooltip)); + else $out .= $langs->trans($name); if (empty($thead) && $field && empty($disablesortlink)) // If this is a sort field { - $out.=''; + $out .= ''; } if (empty($thead) && $field) // If this is a sort field { - $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i', '', $moreparam); - $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options); - $options=preg_replace('/&+/i', '&', $options); - if (! preg_match('/^&/', $options)) $options='&'.$options; + $options = preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i', '', $moreparam); + $options = preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options); + $options = preg_replace('/&+/i', '&', $options); + if (!preg_match('/^&/', $options)) $options = '&'.$options; - if (! $sortorder || $field1 != $sortfield1) + if (!$sortorder || $field1 != $sortfield1) { //$out.= ''.img_down("A-Z",0).''; //$out.= ''.img_up("Z-A",0).''; @@ -4076,19 +4076,19 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin if (preg_match('/^DESC/', $sortorder)) { //$out.= ''.img_down("A-Z",0).''; //$out.= ''.img_up("Z-A",1).''; - $sortimg.= ''.img_up("Z-A", 0).''; + $sortimg .= ''.img_up("Z-A", 0).''; } if (preg_match('/^ASC/', $sortorder)) { //$out.= ''.img_down("A-Z",1).''; //$out.= ''.img_up("Z-A",0).''; - $sortimg.= ''.img_down("A-Z", 0).''; + $sortimg .= ''.img_down("A-Z", 0).''; } } } - $out.=$sortimg; + $out .= $sortimg; - $out.=''; + $out .= ''; return $out; } @@ -4103,7 +4103,7 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin */ function print_titre($title) { - dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); + dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING); print '
'.$title.'
'; } @@ -4141,25 +4141,25 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict { global $conf; - $return=''; + $return = ''; - if ($picto == 'setup') $picto='generic'; + if ($picto == 'setup') $picto = 'generic'; - $return.= "\n"; - $return.= ''; // maring bottom must be same than into print_barre_list - if ($picto) $return.= ''; - $return.= ''; + $return .= "\n"; + $return .= '
'.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).''; - $return.= '
'.$titre.'
'; - $return.= '
'; // maring bottom must be same than into print_barre_list + if ($picto) $return .= ''; + $return .= ''; if (dol_strlen($morehtmlcenter)) { - $return.= ''; + $return .= ''; } if (dol_strlen($morehtmlright)) { - $return.= ''; + $return .= ''; } - $return.= '
'.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).''; + $return .= '
'.$titre.'
'; + $return .= '
'.$morehtmlcenter.''.$morehtmlcenter.''.$morehtmlright.''.$morehtmlright.'
'."\n"; + $return .= ''."\n"; return $return; } @@ -4187,14 +4187,14 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict */ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', $sortorder = '', $morehtmlcenter = '', $num = -1, $totalnboflines = '', $picto = 'generic', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0) { - global $conf,$langs; + global $conf, $langs; $savlimit = $limit; $savtotalnboflines = $totalnboflines; - $totalnboflines=abs($totalnboflines); + $totalnboflines = abs($totalnboflines); - if ($picto == 'setup') $picto='title_setup.png'; - if (($conf->browser->name == 'ie') && $picto=='generic') $picto='title.gif'; + if ($picto == 'setup') $picto = 'title_setup.png'; + if (($conf->browser->name == 'ie') && $picto == 'generic') $picto = 'title.gif'; if ($limit < 0) $limit = $conf->liste_limit; if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) { @@ -4208,7 +4208,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', print "\n"; print "\n"; - print ''; // maring bottom must be same than into load_fiche_tire + print '
'; // maring bottom must be same than into load_fiche_tire // Left print ''; @@ -4304,26 +4304,26 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be print '
'; @@ -4234,48 +4234,48 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', if ($totalnboflines) // If we know total nb of lines { // Define nb of extra page links before and after selected page + ... + first or last - $maxnbofpage=(empty($conf->dol_optimize_smallscreen) ? 4 : 1); + $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 1); - if ($limit > 0) $nbpages=ceil($totalnboflines/$limit); - else $nbpages=1; - $cpt=($page-$maxnbofpage); - if ($cpt < 0) { $cpt=0; } + if ($limit > 0) $nbpages = ceil($totalnboflines / $limit); + else $nbpages = 1; + $cpt = ($page - $maxnbofpage); + if ($cpt < 0) { $cpt = 0; } - if ($cpt>=1) + if ($cpt >= 1) { - $pagelist.= ''; - if ($cpt > 2) $pagelist.=''; - elseif ($cpt == 2) $pagelist.=''; + $pagelist .= ''; + if ($cpt > 2) $pagelist .= ''; + elseif ($cpt == 2) $pagelist .= ''; } do { - if ($cpt==$page) + if ($cpt == $page) { - $pagelist.= ''; + $pagelist .= ''; } else { - $pagelist.= ''; + $pagelist .= ''; } $cpt++; } - while ($cpt < $nbpages && $cpt<=$page+$maxnbofpage); + while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage); - if ($cpt<$nbpages) + if ($cpt < $nbpages) { - if ($cpt<$nbpages-2) $pagelist.= ''; - elseif ($cpt == $nbpages-2) $pagelist.= ''; - $pagelist.= ''; + if ($cpt < $nbpages - 2) $pagelist .= ''; + elseif ($cpt == $nbpages - 2) $pagelist .= ''; + $pagelist .= ''; } } else { - $pagelist.= '"; + $pagelist .= '"; } } - 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_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 '
'; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->BOM_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->BOM_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->BOM_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->BOM_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= ''; + $texte .= ''; + $texte .= ''; return $texte; } @@ -199,7 +199,7 @@ class doc_generic_bom_odt extends ModelePDFBom public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -208,28 +208,28 @@ class doc_generic_bom_odt extends ModelePDFBom } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->bom->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Bom($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -237,16 +237,16 @@ class doc_generic_bom_odt extends ModelePDFBom } } - $dir = $conf->bom->multidir_output[isset($object->entity)?$object->entity:1]; + $dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -254,25 +254,25 @@ class doc_generic_bom_odt extends ModelePDFBom if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -282,20 +282,20 @@ class doc_generic_bom_odt extends ModelePDFBom // If CUSTOMER contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -304,24 +304,24 @@ class doc_generic_bom_odt extends ModelePDFBom } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__QTY_TO_PRODUCE__' => $object->qty, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='BOM_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'BOM_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -331,15 +331,15 @@ class doc_generic_bom_odt extends ModelePDFBom $srctemplatepath, array( 'PATH_TO_TMP' => $conf->bom->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -354,31 +354,31 @@ class doc_generic_bom_odt extends ModelePDFBom try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -391,7 +391,7 @@ class doc_generic_bom_odt extends ModelePDFBom $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -403,7 +403,7 @@ class doc_generic_bom_odt extends ModelePDFBom try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -413,22 +413,22 @@ class doc_generic_bom_odt extends ModelePDFBom { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -438,21 +438,21 @@ class doc_generic_bom_odt extends ModelePDFBom $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -460,15 +460,15 @@ class doc_generic_bom_odt extends ModelePDFBom // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - }catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -477,27 +477,27 @@ class doc_generic_bom_odt extends ModelePDFBom try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 07a1d542644..ef61306c692 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -68,37 +68,37 @@ class doc_generic_mo_odt extends ModelePDFMo global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'MRP_MO_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'MRP_MO_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -110,83 +110,83 @@ class doc_generic_mo_odt extends ModelePDFMo */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MRP_MO_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MRP_MO_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->MRP_MO_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->MRP_MO_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -206,7 +206,7 @@ class doc_generic_mo_odt extends ModelePDFMo public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -215,28 +215,28 @@ class doc_generic_mo_odt extends ModelePDFMo } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->mrp->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new MO($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -244,16 +244,16 @@ class doc_generic_mo_odt extends ModelePDFMo } } - $dir = $conf->mrp->multidir_output[isset($object->entity)?$object->entity:1]; + $dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -261,25 +261,25 @@ class doc_generic_mo_odt extends ModelePDFMo if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -289,20 +289,20 @@ class doc_generic_mo_odt extends ModelePDFMo // If CUSTOMER contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -311,24 +311,24 @@ class doc_generic_mo_odt extends ModelePDFMo } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__QTY_TO_PRODUCE__' => $object->qty, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='MRP_MO_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'MRP_MO_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -338,15 +338,15 @@ class doc_generic_mo_odt extends ModelePDFMo $srctemplatepath, array( 'PATH_TO_TMP' => $conf->mrp->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -361,31 +361,31 @@ class doc_generic_mo_odt extends ModelePDFMo try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -398,7 +398,7 @@ class doc_generic_mo_odt extends ModelePDFMo $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -410,7 +410,7 @@ class doc_generic_mo_odt extends ModelePDFMo try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -420,22 +420,22 @@ class doc_generic_mo_odt extends ModelePDFMo { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -445,21 +445,21 @@ class doc_generic_mo_odt extends ModelePDFMo $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -467,15 +467,15 @@ class doc_generic_mo_odt extends ModelePDFMo // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - }catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -484,27 +484,27 @@ class doc_generic_mo_odt extends ModelePDFMo try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/mrp/mod_mo_advanced.php b/htdocs/core/modules/mrp/mod_mo_advanced.php index 1059ec4a9c5..54e82467900 100644 --- a/htdocs/core/modules/mrp/mod_mo_advanced.php +++ b/htdocs/core/modules/mrp/mod_mo_advanced.php @@ -26,7 +26,7 @@ * \brief File containing class for numbering model of MOs advanced */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/mrp/modules_mo.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php'; /** @@ -38,7 +38,7 @@ class mod_mo_advanced extends ModeleNumRefMos * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error message @@ -48,7 +48,7 @@ class mod_mo_advanced extends ModeleNumRefMos /** * @var string name */ - public $name='advanced'; + public $name = 'advanced'; /** @@ -65,28 +65,28 @@ class mod_mo_advanced extends ModeleNumRefMos $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -98,17 +98,17 @@ class mod_mo_advanced extends ModeleNumRefMos */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $old_code_type=$mysoc->typent_code; - $mysoc->code_client='CCCCCCCCCC'; - $mysoc->typent_code='TTTTTTTTTT'; + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; - $mysoc->typent_code=$old_code_type; + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -124,22 +124,22 @@ class mod_mo_advanced extends ModeleNumRefMos */ public function getNextValue($objprod, $object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask=$conf->global->MRP_MO_ADVANCED_MASK; + $mask = $conf->global->MRP_MO_ADVANCED_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } $date = ($object->date_mo ? $object->date_mo : $object->date); - $numFinal=get_next_value($db, $mask, 'mrp_mo', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'mrp_mo', 'ref', '', null, $date); return $numFinal; } diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index 9546748387b..05b13525023 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -22,7 +22,7 @@ * \ingroup mrp * \brief File of class to manage MO numbering rules standard */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/mrp/modules_mo.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php'; /** * Class to manage MO numbering rules standard @@ -33,19 +33,19 @@ class mod_mo_standard extends ModeleNumRefMos * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $prefix='MO'; + public $prefix = 'MO'; /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string name */ - public $name='standard'; + public $name = 'standard'; /** @@ -79,26 +79,26 @@ class mod_mo_standard extends ModeleNumRefMos */ public function canBeActivated() { - global $conf,$langs,$db; + global $conf, $langs, $db; - $coyymm=''; $max=''; + $coyymm = ''; $max = ''; - $posindice=8; + $posindice = 8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."mrp_mo"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $row = $db->fetch_row($resql); - if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } + if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; } } - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { $langs->load("errors"); - $this->error=$langs->trans('ErrorNumRefModel', $max); + $this->error = $langs->trans('ErrorNumRefModel', $max); return false; } @@ -114,21 +114,21 @@ class mod_mo_standard extends ModeleNumRefMos */ public function getNextValue($objprod, $object) { - global $db,$conf; + global $db, $conf; // D'abord on recupere la valeur max - $posindice=9; + $posindice = 9; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."mrp_mo"; - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo"; + $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $max = intval($obj->max); - else $max=0; + else $max = 0; } else { @@ -137,11 +137,11 @@ class mod_mo_standard extends ModeleNumRefMos } //$date=time(); - $date=$object->date_creation; + $date = $object->date_creation; $yymm = strftime("%y%m", $date); - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is - else $num = sprintf("%04s", $max+1); + if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max + 1); dol_syslog("mod_mo_standard::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index 96268b11f67..2eae2655fbb 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -24,12 +24,12 @@ */ // 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; } -if (! is_object($form)) $form=new Form($db); +if (!is_object($form)) $form = new Form($db); ?> @@ -37,22 +37,22 @@ if (! is_object($form)) $form=new Form($db); $object->fields = dol_sort_array($object->fields, 'position'); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { // Discard if extrafield is a hidden field on form if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) continue; - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue; // We don't want this field - if (in_array($key, array('ref','status'))) continue; // Ref and status are already in dol_banner + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field + if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner - $value=$object->$key; + $value = $object->$key; print ''; - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); else print $langs->trans($val['label']); print ''; print '
'; print ''; $alreadyoutput = 1; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { if ($alreadyoutput) { - if (! empty($keyforbreak) && $key == $keyforbreak) $alreadyoutput = 0; // key used for break on second column + if (!empty($keyforbreak) && $key == $keyforbreak) $alreadyoutput = 0; // key used for break on second column continue; } - if (abs($val['visible']) != 1) continue; // Discard such field from form - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field - if (in_array($key, array('ref','status'))) continue; // Ref and status are already in dol_banner + if (abs($val['visible']) != 1) continue; // Discard such field from form + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) continue; // We don't want this field + if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner - $value=$object->$key; + $value = $object->$key; print ''; - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); + if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); else print $langs->trans($val['label']); print ''; print '
'; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 8e53cffd020..96cb662fe0b 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -23,7 +23,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; @@ -59,7 +59,7 @@ class Mo extends CommonObject const STATUS_DRAFT = 0; - const STATUS_VALIDATED = 1; // To produce + const STATUS_VALIDATED = 1; // To produce const STATUS_INPROGRESS = 2; const STATUS_PRODUCED = 3; const STATUS_CANCELED = -1; @@ -90,7 +90,7 @@ class Mo extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1,), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), @@ -197,11 +197,11 @@ class Mo extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -210,13 +210,13 @@ class Mo extends CommonObject } // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -254,7 +254,7 @@ class Mo extends CommonObject // Load source object $result = $object->fetchCommon($fromid); - if ($result > 0 && ! empty($object->table_element_line)) $object->fetchLines(); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); // get lines so they will be clone //foreach($this->lines as $line) @@ -266,18 +266,18 @@ class Mo extends CommonObject unset($object->import_key); // Clear fields - $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach($object->array_options as $key => $option) + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); @@ -294,7 +294,7 @@ class Mo extends CommonObject $this->errors = $object->errors; } - if (! $error) + if (!$error) { // copy internal contacts if ($this->copy_linked_contact($object, 'internal') < 0) @@ -303,7 +303,7 @@ class Mo extends CommonObject } } - if (! $error) + if (!$error) { // copy external contacts if same company if (property_exists($this, 'socid') && $this->socid == $object->socid) @@ -335,7 +335,7 @@ class Mo extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -346,7 +346,7 @@ class Mo extends CommonObject */ public function fetchLines() { - $this->lines=array(); + $this->lines = array(); $result = $this->fetchLinesCommon(); return $result; @@ -370,40 +370,40 @@ class Mo extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); + $records = array(); $sql = 'SELECT '; $sql .= $this->getFieldList(); - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; else $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid') { - $sqlwhere[] = $key . '='. $value; + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; } - elseif ($key=='customsql') { + elseif ($key == 'customsql') { $sqlwhere[] = $value; } else { - $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } } } if (count($sqlwhere) > 0) { - $sql .= ' AND (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' '.$this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); @@ -425,8 +425,8 @@ class Mo extends CommonObject return $records; } else { - $this->errors[] = 'Error ' . $this->db->lasterror(); - dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); return -1; } @@ -490,51 +490,51 @@ class Mo extends CommonObject { global $conf, $langs, $hookmanager; - 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("MO") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("MO").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/mrp/mo_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMo"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMo"); + $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->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('modao')); - $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; @@ -589,10 +589,10 @@ class Mo extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -603,7 +603,7 @@ class Mo 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_valid) @@ -617,7 +617,7 @@ class Mo extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); @@ -651,7 +651,7 @@ class Mo extends CommonObject */ public function getLinesArray() { - $this->lines=array(); + $this->lines = array(); $objectline = new MoLine($this->db); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_mo = '.$this->id)); @@ -682,16 +682,16 @@ class Mo extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("mrp"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'standard'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->MO_ADDON_PDF)) { + } elseif (!empty($conf->global->MO_ADDON_PDF)) { $modele = $conf->global->MO_ADDON_PDF; } } @@ -716,7 +716,7 @@ class Mo extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; dol_syslog(__METHOD__, LOG_DEBUG);