From 1648fc142e97cfca0a5a8a5158b01959ca906203 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Sat, 16 Nov 2019 22:24:29 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .../adherents/class/adherent_type.class.php | 260 ++++----- .../categories/class/api_categories.class.php | 134 ++--- htdocs/categories/class/categorie.class.php | 18 +- htdocs/contrat/card.php | 200 +++---- htdocs/core/class/commonobject.class.php | 528 +++++++++--------- htdocs/core/class/conf.class.php | 372 ++++++------ htdocs/core/class/html.formwebsite.class.php | 82 +-- htdocs/core/class/menubase.class.php | 374 ++++++------- htdocs/core/photos_resize.php | 168 +++--- .../societe/class/api_thirdparties.class.php | 30 +- htdocs/user/class/api_users.class.php | 50 +- 11 files changed, 1108 insertions(+), 1108 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5006becb053..442d8cf091f 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -99,9 +99,9 @@ class AdherentType extends CommonObject public $mail_valid; /** @var array Array of members */ - public $members=array(); + public $members = array(); - public $multilangs=array(); + public $multilangs = array(); /** @@ -127,8 +127,8 @@ class AdherentType extends CommonObject $current_lang = $langs->getDefaultLang(); $sql = "SELECT lang, label, description, email"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql.= " WHERE fk_type=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; $result = $this->db->query($sql); if ($result) { @@ -138,7 +138,7 @@ class AdherentType extends CommonObject if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales. { $this->label = $obj->label; - $this->description = $obj->description; + $this->description = $obj->description; $this->email = $obj->email; } $this->multilangs["$obj->lang"]["label"] = $obj->label; @@ -149,7 +149,7 @@ class AdherentType extends CommonObject } else { - $this->error="Error: ".$this->db->lasterror()." - ".$sql; + $this->error = "Error: ".$this->db->lasterror()." - ".$sql; return -1; } } @@ -171,75 +171,75 @@ class AdherentType extends CommonObject { if ($key == $current_lang) { $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql.= " WHERE fk_type=".$this->id; - $sql.= " AND lang='".$key."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; + $sql .= " AND lang='".$key."'"; $result = $this->db->query($sql); if ($this->db->num_rows($result)) // if there is already a description line for this language { $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql2.= " SET "; - $sql2.= " label='".$this->db->escape($this->label)."',"; - $sql2.= " description='".$this->db->escape($this->description)."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->other)."'"; + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->label)."',"; + $sql2 .= " description='".$this->db->escape($this->description)."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email='".$this->db->escape($this->other)."'"; } - $sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email"; } - $sql2.= ")"; - $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',"; - $sql2.= " '".$this->db->escape($this->description)."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->other)."'"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; + $sql2 .= " '".$this->db->escape($this->description)."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->other)."'"; } - $sql2.= ")"; + $sql2 .= ")"; } dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); - if (! $this->db->query($sql2)) { - $this->error=$this->db->lasterror(); + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); return -1; } } elseif (isset($this->multilangs[$key])) { $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql.= " WHERE fk_type=".$this->id; - $sql.= " AND lang='".$key."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; + $sql .= " WHERE fk_type=".$this->id; + $sql .= " AND lang='".$key."'"; $result = $this->db->query($sql); if ($this->db->num_rows($result)) // if there is already a description line for this language { $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql2.= " SET "; - $sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'"; + $sql2 .= " SET "; + $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email='".$this->db->escape($this->multilangs["$key"]["other"])."'"; } - $sql2.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; + $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'"; } else { $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.=", email"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", email"; } - $sql2.= ")"; - $sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',"; - $sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; + $sql2 .= ")"; + $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; + $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; } - $sql2.= ")"; + $sql2 .= ")"; } // We do not save if main fields are empty if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { - if (! $this->db->query($sql2)) { - $this->error=$this->db->lasterror(); + if (!$this->db->query($sql2)) { + $this->error = $this->db->lasterror(); return -1; } } @@ -272,7 +272,7 @@ class AdherentType extends CommonObject public function delMultiLangs($langtodelete, $user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; - $sql.= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; + $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); $result = $this->db->query($sql); @@ -289,7 +289,7 @@ class AdherentType extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); return -1; } @@ -306,22 +306,22 @@ class AdherentType extends CommonObject { global $langs, $conf; - $error=0; + $error = 0; - $this->statut=(int) $this->statut; - $this->label=trim($this->label); + $this->statut = (int) $this->statut; + $this->label = trim($this->label); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type ("; - $sql.= " morphy"; - $sql.= ", libelle"; - $sql.= ", entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->morphy)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + $sql .= " morphy"; + $sql .= ", libelle"; + $sql .= ", entity"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->morphy)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", ".$conf->entity; + $sql .= ")"; dol_syslog("Adherent_type::create", LOG_DEBUG); $result = $this->db->query($sql); @@ -336,15 +336,15 @@ class AdherentType extends CommonObject return -3; } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_TYPE_CREATE', $user); + $result = $this->call_trigger('MEMBER_TYPE_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -358,7 +358,7 @@ class AdherentType extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -375,23 +375,23 @@ class AdherentType extends CommonObject { global $langs, $conf, $hookmanager; - $error=0; + $error = 0; - $this->label=trim($this->label); + $this->label = trim($this->label); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; - $sql.= "SET "; - $sql.= "statut = ".$this->statut.","; - $sql.= "libelle = '".$this->db->escape($this->label) ."',"; - $sql.= "morphy = '".$this->db->escape($this->morphy) ."',"; - $sql.= "subscription = '".$this->db->escape($this->subscription)."',"; - $sql.= "duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."',"; - $sql.= "note = '".$this->db->escape($this->note)."',"; - $sql.= "vote = ".(integer) $this->db->escape($this->vote).","; - $sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; - $sql.= " WHERE rowid =".$this->id; + $sql .= "SET "; + $sql .= "statut = ".$this->statut.","; + $sql .= "libelle = '".$this->db->escape($this->label)."',"; + $sql .= "morphy = '".$this->db->escape($this->morphy)."',"; + $sql .= "subscription = '".$this->db->escape($this->subscription)."',"; + $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',"; + $sql .= "note = '".$this->db->escape($this->note)."',"; + $sql .= "vote = ".(integer) $this->db->escape($this->vote).","; + $sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; + $sql .= " WHERE rowid =".$this->id; $result = $this->db->query($sql); if ($result) @@ -399,34 +399,34 @@ class AdherentType extends CommonObject $this->description = $this->db->escape($this->note); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { if ($this->setMultiLangs($user) < 0) { - $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -2; } } - $action='update'; + $action = 'update'; // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_TYPE_MODIFY', $user); + $result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -440,7 +440,7 @@ class AdherentType extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -458,13 +458,13 @@ class AdherentType extends CommonObject $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Call trigger - $result=$this->call_trigger('MEMBER_TYPE_DELETE', $user); + $result = $this->call_trigger('MEMBER_TYPE_DELETE', $user); if ($result < 0) { $error++; $this->db->rollback(); return -2; } // End call triggers @@ -474,7 +474,7 @@ class AdherentType extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -495,7 +495,7 @@ class AdherentType extends CommonObject dol_syslog("Adherent_type::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -506,10 +506,10 @@ class AdherentType extends CommonObject $this->ref = $obj->rowid; $this->label = $obj->label; $this->morphy = $obj->morphy; - $this->statut = $obj->status; // deprecated + $this->statut = $obj->status; // deprecated $this->status = $obj->status; $this->duration = $obj->duration; - $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); + $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); $this->duration_unit = substr($obj->duration, -1); $this->subscription = $obj->subscription; $this->mail_valid = $obj->mail_valid; @@ -517,7 +517,7 @@ class AdherentType extends CommonObject $this->vote = $obj->vote; // multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $this->getMultiLangs(); } } @@ -526,7 +526,7 @@ class AdherentType extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -540,15 +540,15 @@ class AdherentType extends CommonObject public function liste_array() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $adherenttypes = array(); $sql = "SELECT rowid, libelle as label"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE entity IN (".getEntity('member_type').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql .= " WHERE entity IN (".getEntity('member_type').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $nump = $this->db->num_rows($resql); @@ -585,13 +585,13 @@ class AdherentType extends CommonObject { global $conf, $user; - $ret=array(); + $ret = array(); $sql = "SELECT a.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; - $sql.= " WHERE a.entity IN (".getEntity('member').")"; - $sql.= " AND a.fk_adherent_type = ".$this->id; - if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; + $sql .= " WHERE a.entity IN (".getEntity('member').")"; + $sql .= " AND a.fk_adherent_type = ".$this->id; + if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')'; dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG); $resql = $this->db->query($sql); @@ -599,31 +599,31 @@ class AdherentType extends CommonObject { while ($obj = $this->db->fetch_object($resql)) { - if (! array_key_exists($obj->rowid, $ret)) + if (!array_key_exists($obj->rowid, $ret)) { if ($mode < 2) { - $memberstatic=new Adherent($this->db); + $memberstatic = new Adherent($this->db); if ($mode == 1) { $memberstatic->fetch($obj->rowid, '', '', '', false, false); } else { $memberstatic->fetch($obj->rowid); } - $ret[$obj->rowid]=$memberstatic; + $ret[$obj->rowid] = $memberstatic; } - else $ret[$obj->rowid]=$obj->rowid; + else $ret[$obj->rowid] = $obj->rowid; } } $this->db->free($resql); - $this->members=$ret; + $this->members = $ret; return $ret; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -655,15 +655,15 @@ class AdherentType extends CommonObject { global $langs; - $result=''; - $label=$langs->trans("ShowTypeCard", $this->label); + $result = ''; + $label = $langs->trans("ShowTypeCard", $this->label); $linkstart = ''; - $linkend=''; + $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.= ($maxlen?dol_trunc($this->label, $maxlen):$this->label); + 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 .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label); $result .= $linkend; return $result; @@ -723,10 +723,10 @@ class AdherentType extends CommonObject { // phpcs:enable global $conf; - $dn=''; - if ($mode==0) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN; - if ($mode==1) $dn=$conf->global->LDAP_MEMBER_TYPE_DN; - if ($mode==2) $dn=$conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES]; + $dn = ''; + if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN; + if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_TYPE_DN; + if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES]; return $dn; } @@ -741,27 +741,27 @@ class AdherentType extends CommonObject public function _load_ldap_info() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $info=array(); + $info = array(); // Object classes - $info["objectclass"]=explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS); + $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS); // Champs - if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label; - if ($this->note && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1); - if (! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) + if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label; + if ($this->note && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note, 0, 'UTF-8', 1); + if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) { - $valueofldapfield=array(); - foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database. + $valueofldapfield = array(); + foreach ($this->members as $key=>$val) // This is array of users for group into dolibarr database. { - $member=new Adherent($this->db); + $member = new Adherent($this->db); $member->fetch($val->id, '', '', '', false, false); $info2 = $member->_load_ldap_info(); $valueofldapfield[] = $member->_load_ldap_dn($info2); } - $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:''); + $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield) ? $valueofldapfield : ''); } return $info; } @@ -780,18 +780,18 @@ class AdherentType extends CommonObject // Initialise parametres $this->id = 0; $this->ref = 'MTSPEC'; - $this->specimen=1; + $this->specimen = 1; - $this->label='MEMBERS TYPE SPECIMEN'; - $this->note='This is a note'; - $this->mail_valid='This is welcome email'; - $this->subscription=1; - $this->vote=0; + $this->label = 'MEMBERS TYPE SPECIMEN'; + $this->note = 'This is a note'; + $this->mail_valid = 'This is welcome email'; + $this->subscription = 1; + $this->vote = 0; - $this->statut=1; + $this->statut = 1; // Members of this member type is just me - $this->members=array( + $this->members = array( $user->id => $user ); } @@ -805,7 +805,7 @@ class AdherentType extends CommonObject { global $conf; - if (! empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) + if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) { return $this->mail_valid; } @@ -823,7 +823,7 @@ class AdherentType extends CommonObject global $conf; // mail_subscription not defined so never used - if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined + if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) // Property not yet defined { return $this->mail_subscription; } @@ -841,7 +841,7 @@ class AdherentType extends CommonObject global $conf; // NOTE mail_resiliate not defined so never used - if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined + if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined { return $this->mail_resiliate; } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e916255f7b5..459b61ba740 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -78,16 +78,16 @@ class Categories extends DolibarrApi */ public function get($id, $include_childs = false) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if ( ! DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { + if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -126,50 +126,50 @@ class Categories extends DolibarrApi $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $sql = "SELECT t.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('category').')'; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('category').')'; if (!empty($type)) { - $sql.= ' AND t.type='.array_search($type, Categories::$TYPES); + $sql .= ' AND t.type='.array_search($type, Categories::$TYPES); } // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) { $obj = $db->fetch_object($result); $category_static = new Categorie($db); - if($category_static->fetch($obj->rowid)) { + if ($category_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($category_static); } $i++; @@ -178,7 +178,7 @@ class Categories extends DolibarrApi else { throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No category found'); } return $obj_ret; @@ -192,14 +192,14 @@ class Categories extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->categorie->creer) { + if (!DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->category->$field = $value; } if ($this->category->create(DolibarrApiAccess::$user) < 0) { @@ -217,20 +217,20 @@ class Categories extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->categorie->creer) { + if (!DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if ( ! DolibarrApi::_checkAccessToResource('category', $this->category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->category->$field = $value; } @@ -253,19 +253,19 @@ class Categories extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->categorie->supprimer) { + if (!DolibarrApiAccess::$user->rights->categorie->supprimer) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if ( ! DolibarrApi::_checkAccessToResource('category', $this->category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (! $this->category->delete(DolibarrApiAccess::$user)) { + if (!$this->category->delete(DolibarrApiAccess::$user)) { throw new RestException(401, 'error when delete category'); } @@ -306,21 +306,21 @@ class Categories extends DolibarrApi throw new RestException(401); } - if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if ($type == Categorie::TYPE_PRODUCT && !(DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { + } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { + } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { + } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { + } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); } $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); - if( ! is_array($categories)) { + if (!is_array($categories)) { if ($categories == 0) { throw new RestException(404, 'No category found for this object'); } @@ -347,37 +347,37 @@ class Categories extends DolibarrApi throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } if ($type === Categorie::TYPE_PRODUCT) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401); } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $object = new Adherent($this->db); @@ -388,7 +388,7 @@ class Categories extends DolibarrApi if (!empty($object)) { $result = $object->fetch($object_id); if ($result > 0) { - $result=$this->category->add_type($object, $type); + $result = $this->category->add_type($object, $type); if ($result < 0) { if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); @@ -427,37 +427,37 @@ class Categories extends DolibarrApi throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } if ($type === Categorie::TYPE_PRODUCT) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401); } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $object = new Adherent($this->db); @@ -468,7 +468,7 @@ class Categories extends DolibarrApi if (!empty($object)) { $result = $object->fetch('', $object_ref); if ($result > 0) { - $result=$this->category->add_type($object, $type); + $result = $this->category->add_type($object, $type); if ($result < 0) { if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors)); @@ -507,37 +507,37 @@ class Categories extends DolibarrApi throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } if ($type === Categorie::TYPE_PRODUCT) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401); } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $object = new Adherent($this->db); @@ -548,7 +548,7 @@ class Categories extends DolibarrApi if (!empty($object)) { $result = $object->fetch((int) $object_id); if ($result > 0) { - $result=$this->category->del_type($object, $type); + $result = $this->category->del_type($object, $type); if ($result < 0) { throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); } @@ -585,37 +585,37 @@ class Categories extends DolibarrApi throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->category->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } if ($type === Categorie::TYPE_PRODUCT) { - if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { throw new RestException(401); } $object = new Contact($this->db); } elseif ($type === Categorie::TYPE_MEMBER) { - if(! DolibarrApiAccess::$user->rights->adherent->creer) { + if (!DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); } $object = new Adherent($this->db); @@ -626,7 +626,7 @@ class Categories extends DolibarrApi if (!empty($object)) { $result = $object->fetch('', (string) $object_ref); if ($result > 0) { - $result=$this->category->del_type($object, $type); + $result = $this->category->del_type($object, $type); if ($result < 0) { throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); } @@ -736,7 +736,7 @@ class Categories extends DolibarrApi { dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG); - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } @@ -746,11 +746,11 @@ class Categories extends DolibarrApi } $result = $this->category->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'category not found'); } - if (! DolibarrApi::_checkAccessToResource('category', $this->category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6bbc0afcb1c..67cd2a4f5e0 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -781,18 +781,18 @@ class Categorie extends CommonObject $objs = array(); - $obj = new $this->MAP_OBJ_CLASS[$type]( $this->db ); + $obj = new $this->MAP_OBJ_CLASS[$type]($this->db); - $sql = "SELECT c.fk_" . $this->MAP_CAT_FK[$type]; - $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c"; - $sql .= ", " . MAIN_DB_PREFIX . $this->MAP_OBJ_TABLE[$type] . " as o"; - $sql .= " WHERE o.entity IN (" . getEntity($obj->element).")"; + $sql = "SELECT c.fk_".$this->MAP_CAT_FK[$type]; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as c"; + $sql .= ", ".MAIN_DB_PREFIX.$this->MAP_OBJ_TABLE[$type]." as o"; + $sql .= " WHERE o.entity IN (".getEntity($obj->element).")"; $sql .= " AND c.fk_categorie = ".$this->id; - $sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid"; + $sql .= " AND c.fk_".$this->MAP_CAT_FK[$type]." = o.rowid"; // Protection for external users if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) { - $sql.= " AND o.rowid = ".$user->socid; + $sql .= " AND o.rowid = ".$user->socid; } if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->order($sortfield, $sortorder); @@ -929,7 +929,7 @@ class Categorie extends CommonObject $categories[$i]['description'] = $category_static->description; $categories[$i]['color'] = $category_static->color; $categories[$i]['socid'] = $category_static->socid; - $categories[$i]['ref_ext'] = $category_static->ref_ext; + $categories[$i]['ref_ext'] = $category_static->ref_ext; $categories[$i]['visible'] = $category_static->visible; $categories[$i]['type'] = $category_static->type; $categories[$i]['entity'] = $category_static->entity; @@ -1569,7 +1569,7 @@ class Categorie extends CommonObject $sql .= " AND rowid = '".$id."'"; } - $res = $this->db->query($sql); + $res = $this->db->query($sql); if ($res) { while ($rec = $this->db->fetch_array($res)) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 8336ce11e17..efd521e9ec0 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -40,39 +40,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array("contracts","orders","companies","bills","products",'compta')); +$langs->loadLangs(array("contracts", "orders", "companies", "bills", "products", 'compta')); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $socid = GETPOST('socid', 'int'); $id = GETPOST('id', 'int'); -$ref=GETPOST('ref', 'alpha'); -$origin=GETPOST('origin', 'alpha'); -$originid=GETPOST('originid', 'int'); +$ref = GETPOST('ref', 'alpha'); +$origin = GETPOST('origin', 'alpha'); +$originid = GETPOST('originid', 'int'); -$datecontrat=''; -$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); +$datecontrat = ''; +$usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0); // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'contrat', $id); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'contrat', $id); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('contractcard','globalcard')); +$hookmanager->initHooks(array('contractcard', 'globalcard')); $object = new Contrat($db); $extrafields = new ExtraFields($db); // Load object -if ($id > 0 || ! empty($ref) && $action!='add') { +if ($id > 0 || !empty($ref) && $action != 'add') { $ret = $object->fetch($id, $ref); if ($ret > 0) $ret = $object->fetch_thirdparty(); @@ -444,8 +444,8 @@ if (empty($reshook)) $error++; } - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) { setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); @@ -528,46 +528,46 @@ if (empty($reshook)) { if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat/100)), 'MU'); + $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } else { - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU'); + $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } - $desc=$prod->description; - $desc=dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + $desc = $prod->description; + $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $fk_unit = $prod->fk_unit; } else { - $pu_ht=GETPOST('price_ht'); + $pu_ht = GETPOST('price_ht'); $price_base_type = 'HT'; - $tva_tx=GETPOST('tva_tx')?str_replace('*', '', GETPOST('tva_tx')):0; // tva_tx field may be disabled, so we use vat rate 0 - $tva_npr=preg_match('/\*/', GETPOST('tva_tx'))?1:0; - $desc=$product_desc; - $fk_unit= GETPOST('units', 'alpha'); + $tva_tx = GETPOST('tva_tx') ?str_replace('*', '', GETPOST('tva_tx')) : 0; // tva_tx field may be disabled, so we use vat rate 0 + $tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0; + $desc = $product_desc; + $fk_unit = GETPOST('units', 'alpha'); } - $localtax1_tx=get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); - $localtax2_tx=get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); // ajout prix achat $fk_fournprice = $_POST['fournprice']; - if ( ! empty($_POST['buying_price']) ) + if (!empty($_POST['buying_price'])) $pa_ht = $_POST['buying_price']; else $pa_ht = null; - $info_bits=0; + $info_bits = 0; if ($tva_npr) $info_bits |= 0x01; - if (((! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) - || empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && ($price_min && (price2num($pu_ht)*(1-price2num($remise_percent)/100) < price2num($price_min)))) + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) + || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); - $result = -1 ; + $result = -1; } else { @@ -1239,34 +1239,34 @@ if ($action == 'create') print ""; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load('projects'); - $formproject=new FormProjets($db); + $formproject = new FormProjets($db); print ''.$langs->trans("Project").''; - $formproject->select_projects(($soc->id>0?$soc->id:-1), $projectid, "projectid", 0, 0, 1, 1); - print '   id).'">' . $langs->trans("AddProject") . ''; + $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, "projectid", 0, 0, 1, 1); + print '   id).'">'.$langs->trans("AddProject").''; print ""; } print ''.$langs->trans("NotePublic").''; - $doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; if (empty($user->socid)) { print ''.$langs->trans("NotePrivate").''; - $doleditor=new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; } // Other attributes - $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Other attributes @@ -1389,62 +1389,62 @@ else // Contract card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref=''; - if (! empty($modCodeContract->code_auto)) { - $morehtmlref.=$object->ref; + $morehtmlref = ''; + if (!empty($modCodeContract->code_auto)) { + $morehtmlref .= $object->ref; } else { - $morehtmlref.=$form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3); - $morehtmlref.=$form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2); + $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3); + $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2); } - $morehtmlref.='
'; + $morehtmlref .= '
'; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); // Ref supplier - $morehtmlref.='
'; - $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); + $morehtmlref .= '
'; + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherContracts").')'; + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->contrat->creer) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); @@ -1619,7 +1619,7 @@ else // Quantity print ''.$objp->qty.''; // Unit - if($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($object->lines[$cursorline-1]->getLabelOfUnit()).''; + if ($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''; // Discount if ($objp->remise_percent > 0) { @@ -1717,32 +1717,32 @@ else print ''; if ($objp->fk_product) { - $productstatic->id=$objp->fk_product; - $productstatic->type=$objp->ptype; - $productstatic->ref=$objp->pref; - $productstatic->entity=$objp->pentity; + $productstatic->id = $objp->fk_product; + $productstatic->type = $objp->ptype; + $productstatic->ref = $objp->pref; + $productstatic->entity = $objp->pentity; print $productstatic->getNomUrl(1, '', 32); - print $objp->label?' - '.dol_trunc($objp->label, 32):''; + print $objp->label ? ' - '.dol_trunc($objp->label, 32) : ''; print '
'; } else { - print $objp->label?$objp->label.'
':''; + print $objp->label ? $objp->label.'
' : ''; } // editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); - $doleditor=new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%'); + $nbrows = ROWS_2; + if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; + $enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0); + $doleditor = new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%'); $doleditor->Create(); print ''; // VAT print ''; - print $form->load_tva("eltva_tx", $objp->tva_tx.($objp->vat_src_code?(' ('.$objp->vat_src_code.')'):''), $mysoc, $object->thirdparty, $objp->fk_product, $objp->info_bits, $objp->product_type, 0, 1); + print $form->load_tva("eltva_tx", $objp->tva_tx.($objp->vat_src_code ? (' ('.$objp->vat_src_code.')') : ''), $mysoc, $object->thirdparty, $objp->fk_product, $objp->info_bits, $objp->product_type, 0, 1); print ''; // Price @@ -1767,7 +1767,7 @@ else // Discount print '%'; - if (! empty($usemargins)) + if (!empty($usemargins)) { print ''; if ($objp->fk_product) print ''; @@ -1885,27 +1885,27 @@ else // Area with status and activation info of line if ($object->statut > 0) { - print ''; + print '
'; print ''; - print ''; + print ''; print '
'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).''.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).''; if ($user->socid == 0) { if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') { - $tmpaction='activateline'; - $tmpactionpicto='play'; - $tmpactiontext=$langs->trans("Activate"); + $tmpaction = 'activateline'; + $tmpactionpicto = 'play'; + $tmpactiontext = $langs->trans("Activate"); if ($objp->statut == 4) { - $tmpaction='unactivateline'; - $tmpactionpicto='playstop'; - $tmpactiontext=$langs->trans("Disable"); + $tmpaction = 'unactivateline'; + $tmpactionpicto = 'playstop'; + $tmpactiontext = $langs->trans("Disable"); } - if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) + if (($tmpaction == 'activateline' && $user->rights->contrat->activer) || ($tmpaction == 'unactivateline' && $user->rights->contrat->desactiver)) { - print ''; + print ''; print img_picto($tmpactiontext, $tmpactionpicto); print ''; } @@ -2060,24 +2060,24 @@ else // Form to add new line if ($user->rights->contrat->creer && ($object->statut == 0)) { - $dateSelector=1; + $dateSelector = 1; print "\n"; - print '
+ print ' - + '; print '
'; - print ''; // Array with (n*2)+1 lines + print '
'; // Array with (n*2)+1 lines // Form to add new line if ($action != 'editline') { - $forcetoshowtitlelines=1; - if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts + $forcetoshowtitlelines = 1; + if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts // Add free products/services $object->formAddObjectLine(1, $mysoc, $soc); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 360ac2f019d..a70cf20503a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -429,12 +429,12 @@ abstract class CommonObject /** * @var integer|string $date_validation; */ - public $date_validation; // Date validation + public $date_validation; // Date validation /** * @var integer|string $date_modification; */ - public $date_modification; // Date last change (tms field) + public $date_modification; // Date last change (tms field) public $next_prev_filter; @@ -574,7 +574,7 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $tmparray = getCountry($this->country_id, 'all'); $this->country_code = $tmparray['code']; - $this->country = $tmparray['label']; + $this->country = $tmparray['label']; } if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_cpde))) @@ -602,123 +602,123 @@ abstract class CommonObject { global $conf, $langs; - $countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS + $countriesusingstate = array('AU', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS - $contactid=0; - $thirdpartyid=0; + $contactid = 0; + $thirdpartyid = 0; if ($this->element == 'societe') { - $thirdpartyid=$this->id; + $thirdpartyid = $this->id; } if ($this->element == 'contact') { - $contactid=$this->id; - $thirdpartyid=$object->fk_soc; + $contactid = $this->id; + $thirdpartyid = $object->fk_soc; } if ($this->element == 'user') { - $contactid=$this->contact_id; - $thirdpartyid=$object->fk_soc; + $contactid = $this->contact_id; + $thirdpartyid = $object->fk_soc; } - $out=''; + $out = ''; - $outdone=0; + $outdone = 0; $coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); if ($coords) { - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { $namecoords = ''; - if ( $this->element == 'contact' && ! empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS)) + if ($this->element == 'contact' && !empty($conf->global->MAIN_SHOW_COMPANY_NAME_IN_BANNER_ADDRESS)) { - $namecoords.= $object->name.'
'; + $namecoords .= $object->name.'
'; } - $namecoords.= $this->getFullName($langs, 1).'
'.$coords; + $namecoords .= $this->getFullName($langs, 1).'
'.$coords; // hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile - $out.=''; - $out.=img_picto($langs->trans("Address"), 'object_address.png'); - $out.=' '; + $out .= ''; + $out .= img_picto($langs->trans("Address"), 'object_address.png'); + $out .= ' '; } - $out.=dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++; + $out .= dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++; $outdone++; } - if (! in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress + if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) { if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { - $out.=($outdone?' - ':'').$this->region.' - '.$this->state; + $out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state; } else { - $out.=($outdone?' - ':'').$this->state; + $out .= ($outdone ? ' - ' : '').$this->state; } $outdone++; } - if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) $out.=($outdone?'
':''); - if (! empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone - $out.=dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; + if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) $out .= ($outdone ? '
' : ''); + if (!empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone + $out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; } - if (! empty($this->phone_pro)) { - $out.=dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; + if (!empty($this->phone_pro)) { + $out .= dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; } - if (! empty($this->phone_mobile)) { - $out.=dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; + if (!empty($this->phone_mobile)) { + $out .= dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; } - if (! empty($this->phone_perso)) { - $out.=dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso")); $outdone++; + if (!empty($this->phone_perso)) { + $out .= dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePerso")); $outdone++; } - if (! empty($this->office_phone)) { - $out.=dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; + if (!empty($this->office_phone)) { + $out .= dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; } - if (! empty($this->user_mobile)) { - $out.=dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; + if (!empty($this->user_mobile)) { + $out .= dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'mobile', $langs->trans("PhoneMobile")); $outdone++; } - if (! empty($this->fax)) { - $out.=dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; + if (!empty($this->fax)) { + $out .= dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; } - if (! empty($this->office_fax)) { - $out.=dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; + if (!empty($this->office_fax)) { + $out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; } - $out.='
'; - $outdone=0; - if (! empty($this->email)) + $out .= '
'; + $outdone = 0; + if (!empty($this->email)) { - $out.=dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1); + $out .= dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1); $outdone++; } - if (! empty($this->url)) + if (!empty($this->url)) { //$out.=dol_print_url($this->url,'_goout',0,1);//steve changed to blank - $out.=dol_print_url($this->url, '_blank', 0, 1); + $out .= dol_print_url($this->url, '_blank', 0, 1); $outdone++; } - $out.='
'; - if (! empty($conf->socialnetworks->enabled)) + $out .= '
'; + if (!empty($conf->socialnetworks->enabled)) { - if (is_array($this->socialnetworks) && count($this->socialnetworks)>0) { + if (is_array($this->socialnetworks) && count($this->socialnetworks) > 0) { foreach ($this->socialnetworks as $key => $value) { - $out.=dol_print_socialnetworks($value, $this->id, $object->id, $key); + $out .= dol_print_socialnetworks($value, $this->id, $object->id, $key); $outdone++; } } else { - if ($this->skype) $out.=dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); + if ($this->skype) $out .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); $outdone++; - if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); + if ($this->jabberid) $out .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); $outdone++; - if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); + if ($this->twitter) $out .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); $outdone++; - if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); + if ($this->facebook) $out .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); $outdone++; - if ($this->linkedin) $out.=dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); + if ($this->linkedin) $out .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); $outdone++; } } - $out.='
'; + $out .= '
'; - $out.=''; + $out .= ''; return $out; } @@ -1086,49 +1086,49 @@ abstract class CommonObject // phpcs:enable global $langs; - $tab=array(); + $tab = array(); - $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user - if ($source == 'internal') $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; - if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid, t.statut as statuscontact"; - $sql.= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; - $sql.= ", tc.source, tc.element, tc.code, tc.libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; - $sql.= ", ".MAIN_DB_PREFIX."element_contact ec"; - if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; - if ($source == 'external'|| $source == 'thirdparty') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; - $sql.= " WHERE ec.element_id =".$this->id; - $sql.= " AND ec.fk_c_type_contact=tc.rowid"; - $sql.= " AND tc.element='".$this->db->escape($this->element)."'"; - if ($code) $sql.= " AND tc.code = '".$this->db->escape($code)."'"; - if ($source == 'internal') $sql.= " AND tc.source = 'internal'"; - if ($source == 'external' || $source == 'thirdparty') $sql.= " AND tc.source = 'external'"; - $sql.= " AND tc.active=1"; - if ($status >= 0) $sql.= " AND ec.statut = ".$status; - $sql.=" ORDER BY t.lastname ASC"; + $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user + if ($source == 'internal') $sql .= ", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; + if ($source == 'external' || $source == 'thirdparty') $sql .= ", t.fk_soc as socid, t.statut as statuscontact"; + $sql .= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; + $sql .= ", tc.source, tc.element, tc.code, tc.libelle"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact ec"; + if ($source == 'internal') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; + if ($source == 'external' || $source == 'thirdparty') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; + $sql .= " WHERE ec.element_id =".$this->id; + $sql .= " AND ec.fk_c_type_contact=tc.rowid"; + $sql .= " AND tc.element='".$this->db->escape($this->element)."'"; + if ($code) $sql .= " AND tc.code = '".$this->db->escape($code)."'"; + if ($source == 'internal') $sql .= " AND tc.source = 'internal'"; + if ($source == 'external' || $source == 'thirdparty') $sql .= " AND tc.source = 'external'"; + $sql .= " AND tc.active=1"; + if ($status >= 0) $sql .= " AND ec.statut = ".$status; + $sql .= " ORDER BY t.lastname ASC"; dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - if (! $list) + if (!$list) { - $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; - $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); - $tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id, - 'nom'=>$obj->lastname, // For backward compatibility + $transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code; + $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); + $tab[$i] = array('source'=>$obj->source, 'socid'=>$obj->socid, 'id'=>$obj->id, + 'nom'=>$obj->lastname, // For backward compatibility 'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact, 'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact); } else { - $tab[$i]=$obj->id; + $tab[$i] = $obj->id; } $i++; @@ -1900,23 +1900,23 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - if (! empty($this->fields['fk_project'])) // Common case + if (!empty($this->fields['fk_project'])) // Common case { - if ($projectid) $sql.= ' SET fk_project = '.$projectid; - else $sql.= ' SET fk_project = NULL'; - $sql.= ' WHERE rowid = '.$this->id; + if ($projectid) $sql .= ' SET fk_project = '.$projectid; + else $sql .= ' SET fk_project = NULL'; + $sql .= ' WHERE rowid = '.$this->id; } elseif ($this->table_element == 'actioncomm') // Special case for actioncomm { - if ($projectid) $sql.= ' SET fk_project = '.$projectid; - else $sql.= ' SET fk_project = NULL'; - $sql.= ' WHERE id = '.$this->id; + if ($projectid) $sql .= ' SET fk_project = '.$projectid; + else $sql .= ' SET fk_project = NULL'; + $sql .= ' WHERE id = '.$this->id; } else // Special case for old architecture objects { - if ($projectid) $sql.= ' SET fk_projet = '.$projectid; - else $sql.= ' SET fk_projet = NULL'; - $sql.= ' WHERE rowid = '.$this->id; + if ($projectid) $sql .= ' SET fk_projet = '.$projectid; + else $sql .= ' SET fk_projet = NULL'; + $sql .= ' WHERE rowid = '.$this->id; } dol_syslog(get_class($this)."::setProject", LOG_DEBUG); @@ -3851,19 +3851,19 @@ abstract class CommonObject $totalWeight += $weight * $qty * $trueWeightUnit; } else { - $totalWeight += $weight * $qty; // This may be wrong if we mix different units + $totalWeight += $weight * $qty; // This may be wrong if we mix different units } } if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { //print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit; - $trueVolumeUnit=pow(10, $volumeUnit); + $trueVolumeUnit = pow(10, $volumeUnit); //print $line->volume; $totalVolume += $volume * $qty * $trueVolumeUnit; } else { - $totalVolume += $volume * $qty; // This may be wrong if we mix different units + $totalVolume += $volume * $qty; // This may be wrong if we mix different units } } @@ -4017,11 +4017,11 @@ abstract class CommonObject */ public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/core/tpl') { - global $conf,$user,$langs,$object,$hookmanager,$extrafields; + global $conf, $user, $langs, $object, $hookmanager, $extrafields; global $form; // Line extrafield - if (! is_object($extrafields)) + if (!is_object($extrafields)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); @@ -4108,15 +4108,15 @@ abstract class CommonObject $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_title.tpl.php'; } if (empty($conf->file->strict_mode)) { - $res=@include $tpl; + $res = @include $tpl; } else { - $res=include $tpl; // for debug + $res = include $tpl; // for debug } if ($res) break; } } - $i = 0; + $i = 0; print "\n"; foreach ($this->lines as $line) @@ -4130,12 +4130,12 @@ abstract class CommonObject if (empty($line->fk_parent_line)) { $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element); - $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } else { $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line); - $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } if (empty($reshook)) @@ -4167,21 +4167,21 @@ abstract class CommonObject */ public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl') { - global $conf,$langs,$user,$object,$hookmanager; + global $conf, $langs, $user, $object, $hookmanager; global $form; - global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! + global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! $object_rights = $this->getRights(); - $element=$this->element; + $element = $this->element; - $text=''; $description=''; $type=0; + $text = ''; $description = ''; $type = 0; // Show product and description - $type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type); + $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type); // Try to enhance type detection using date_start and date_end for free lines where type was not saved. - if (! empty($line->date_start)) $type=1; // deprecated - if (! empty($line->date_end)) $type=1; // deprecated + if (!empty($line->date_start)) $type = 1; // deprecated + if (!empty($line->date_end)) $type = 1; // deprecated // Ligne en mode visu if ($action != 'editline' || $selected != $line->id) @@ -4318,19 +4318,19 @@ abstract class CommonObject print ''; print ''; print ''; - $i = 0; + $i = 0; - if (! empty($this->lines)) + if (!empty($this->lines)) { foreach ($this->lines as $line) { - if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) + if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { if (empty($line->fk_parent_line)) { - $parameters=array('line'=>$line, 'i'=>$i); - $action=''; - $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('line'=>$line, 'i'=>$i); + $action = ''; + $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } } else @@ -4623,48 +4623,48 @@ abstract class CommonObject { global $conf, $langs, $user, $hookmanager, $action; - $srctemplatepath=''; + $srctemplatepath = ''; - $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); + $parameters = array('modelspath'=>$modelspath, 'modele'=>$modele, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'hidedesc'=>$hidedesc, 'hideref'=>$hideref, 'moreparams'=>$moreparams); $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); + dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); // Increase limit for PDF build - $err=error_reporting(); + $err = error_reporting(); error_reporting(0); @set_time_limit(120); error_reporting($err); // If selected model is a filename template (then $modele="modelname" or "modelname:filename") - $tmp=explode(':', $modele, 2); - if (! empty($tmp[1])) + $tmp = explode(':', $modele, 2); + if (!empty($tmp[1])) { - $modele=$tmp[0]; - $srctemplatepath=$tmp[1]; + $modele = $tmp[0]; + $srctemplatepath = $tmp[1]; } // Search template files - $file=''; - $classname=''; - $filefound=0; - $dirmodels=array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; + $classname = ''; + $filefound = 0; + $dirmodels = array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - foreach(array('doc','pdf') as $prefix) + foreach (array('doc', 'pdf') as $prefix) { - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php + if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php else $file = $prefix."_".$modele.".modules.php"; // On verifie l'emplacement du modele - $file=dol_buildpath($reldir.$modelspath.$file, 0); + $file = dol_buildpath($reldir.$modelspath.$file, 0); if (file_exists($file)) { - $filefound=1; - $classname=$prefix.'_'.$modele; + $filefound = 1; + $classname = $prefix.'_'.$modele; break; } } @@ -4674,7 +4674,7 @@ abstract class CommonObject // If generator was found if ($filefound) { - global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. + global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. require_once $file; @@ -4683,32 +4683,32 @@ abstract class CommonObject // If generator is ODT, we must have srctemplatepath defined, if not we set it. if ($obj->type == 'odt' && empty($srctemplatepath)) { - $varfortemplatedir=$obj->scandir; - if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) + $varfortemplatedir = $obj->scandir; + if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir)) { - $dirtoscan=$conf->global->$varfortemplatedir; + $dirtoscan = $conf->global->$varfortemplatedir; - $listoffiles=array(); + $listoffiles = array(); // Now we add first model found in directories scanned - $listofdir=explode(',', $dirtoscan); - foreach($listofdir as $key => $tmpdir) + $listofdir = explode(',', $dirtoscan); + foreach ($listofdir as $key => $tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { unset($listofdir[$key]); continue; } + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } if (is_dir($tmpdir)) { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } if (count($listoffiles)) { - foreach($listoffiles as $record) + foreach ($listoffiles as $record) { - $srctemplatepath=$record['fullname']; + $srctemplatepath = $record['fullname']; break; } } @@ -4716,27 +4716,27 @@ abstract class CommonObject if (empty($srctemplatepath)) { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; + $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; return -1; } } - if ($obj->type == 'odt' && ! empty($srctemplatepath)) + if ($obj->type == 'odt' && !empty($srctemplatepath)) { - if (! dol_is_file($srctemplatepath)) + if (!dol_is_file($srctemplatepath)) { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; + $this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; return -1; } } // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. - $sav_charset_output=$outputlangs->charset_output; + $sav_charset_output = $outputlangs->charset_output; if (in_array(get_class($this), array('Adherent'))) { - $arrayofrecords = array(); // The write_file of templates of adherent class need this var + $arrayofrecords = array(); // The write_file of templates of adherent class need this var $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); } else @@ -4747,46 +4747,46 @@ abstract class CommonObject if ($resultwritefile > 0) { - $outputlangs->charset_output=$sav_charset_output; + $outputlangs->charset_output = $sav_charset_output; // We delete old preview require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_delete_preview($this); // Index file in database - if (! empty($obj->result['fullpath'])) + if (!empty($obj->result['fullpath'])) { $destfull = $obj->result['fullpath']; $upload_dir = dirname($destfull); $destfile = basename($destfull); $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir { $filename = basename($destfile); $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($this->db); - $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); + $ecmfile = new EcmFiles($this->db); + $result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename); // Set the public "share" key $setsharekey = false; if ($this->element == 'propal') { - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok - if ($useonlinesignature) $setsharekey=true; - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + if ($useonlinesignature) $setsharekey = true; + if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true; } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; + if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; } - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; + if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; } - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; + if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; } if ($setsharekey) { @@ -4799,11 +4799,11 @@ abstract class CommonObject if ($result > 0) { - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content $ecmfile->fullpath_orig = ''; $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content $result = $ecmfile->update($user); if ($result < 0) { setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); @@ -4814,11 +4814,11 @@ abstract class CommonObject $ecmfile->entity = $conf->entity; $ecmfile->filepath = $rel_dir; $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content $ecmfile->fullpath_orig = ''; $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content $ecmfile->src_object_type = $this->table_element; $ecmfile->src_object_id = $this->id; @@ -4834,15 +4834,15 @@ abstract class CommonObject //var_dump($obj->update_main_doc_field);exit; // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) - $update_main_doc_field=0; - if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; - if ($update_main_doc_field && ! empty($this->table_element)) + $update_main_doc_field = 0; + if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1; + if ($update_main_doc_field && !empty($this->table_element)) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { dol_print_error($this->db); } else { $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; @@ -4862,14 +4862,14 @@ abstract class CommonObject } else { - $outputlangs->charset_output=$sav_charset_output; + $outputlangs->charset_output = $sav_charset_output; dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); return -1; } } else { - $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); + $this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); dol_print_error('', $this->error); return -1; } @@ -4963,26 +4963,26 @@ abstract class CommonObject public function call_trigger($trigger_name, $user) { // phpcs:enable - global $langs,$conf; + global $langs, $conf; - if (! is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. + if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs = new Translate('', $conf); } - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers($trigger_name, $this, $user, $langs, $conf); + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers($trigger_name, $this, $user, $langs, $conf); if ($result < 0) { if (!empty($this->errors)) { - $this->errors=array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. + $this->errors = array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. } else { - $this->errors=$interface->errors; + $this->errors = $interface->errors; } } return $result; @@ -6088,77 +6088,77 @@ abstract class CommonObject } if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - $data[$obj->rowid]=$labeltoshow; + $data[$obj->rowid] = $labeltoshow; } - if (! empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; + if (!empty($InfoFieldList[3]) && $parentField) { + $parent = $parentName.':'.$obj->{$parentField}; } - $data[$obj->rowid]=$labeltoshow; + $data[$obj->rowid] = $labeltoshow; } - $i ++; + $i++; } $this->db->free($resql); - $out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%'); } else { - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
'; } } } elseif ($type == 'link') { - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' $param_list_array = explode(':', $param_list[0]); - $showempty=(($required && $default != '')?0:1); + $showempty = (($required && $default != '') ? 0 : 1); - $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled'])?0:1); + $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, '', 0, empty($val['disabled']) ? 0 : 1); - if (! empty($param_list_array[2])) // If we set to add a create button + if (!empty($param_list_array[2])) // If we set to add a create button { - if (! GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". + if (!GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". { - list($class,$classfile)=explode(':', $param_list[0]); - if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); - else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); + list($class, $classfile) = explode(':', $param_list[0]); + if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); + else $url_path = dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); $paramforthenewlink = ''; - $paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action', 'aZ09'):''); - $paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id', 'int'):''); + $paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : ''); + $paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : ''); $paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--'; // TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page - $out.=''; + $out .= ''; } } } elseif ($type == 'password') { // If prefix is 'search_', field is used as a filter, we use a common text field. - $out=''; + $out = ''; } elseif ($type == 'array') { $newval = $val; $newval['type'] = 'varchar(256)'; - $out=''; + $out = ''; $inputs = array(); - if(! empty($value)) { - foreach($value as $option) { - $out.= ' '; - $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'
'; + if (!empty($value)) { + foreach ($value as $option) { + $out .= ' '; + $out .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'
'; } } - $out.= ''; + $out .= ''; $newInput = ' '; - $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $morecss).'
'; + $newInput .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $morecss).'
'; - if(! empty($conf->use_javascript_ajax)) { - $out.= ' + if (!empty($conf->use_javascript_ajax)) { + $out .= '
'.$langs->trans('ReductionShort').''.$form->showCheckAddButtons('checkforselect', 1).'