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("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).' | '; + print ''.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).' | '; print ''; 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 'id . '&ligne=' . $object->lines[$cursorline - 1]->id . '&action=' . $tmpaction . '">'; + print 'id.'&ligne='.$object->lines[$cursorline - 1]->id.'&action='.$tmpaction.'">'; 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 ' |