diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 4f93aa18875..c59e87dfd93 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -36,7 +36,7 @@ class AccountancySystem /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var int ID @@ -48,7 +48,14 @@ class AccountancySystem */ public $fk_pcg_version; + /** + * @var string pcg type + */ public $pcg_type; + + /** + * @var string pcg subtype + */ public $pcg_subtype; /** @@ -61,7 +68,14 @@ class AccountancySystem */ public $label; + /** + * @var string account number + */ public $account_number; + + /** + * @var string account parent + */ public $account_parent; /** diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 886b2ade2d4..1191187a139 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -42,8 +42,7 @@ class AccountingJournal extends CommonObject public $fk_element = ''; /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int + * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 0; @@ -57,6 +56,9 @@ class AccountingJournal extends CommonObject */ public $rowid; + /** + * @var string Accounting journal code + */ public $code; /** @@ -64,9 +66,19 @@ class AccountingJournal extends CommonObject */ public $label; - public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + /** + * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new + */ + public $nature; + + /** + * @var int is active or not + */ public $active; + /** + * @var array array of lines + */ public $lines; /** diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 69c17f3484e..d8a33ac1054 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -38,7 +38,7 @@ class BookKeeping extends CommonObject public $error; /** - * @var string[] Error codes (or messages) + * @var string[] Array of Error codes (or messages) */ public $errors = array(); @@ -67,7 +67,14 @@ class BookKeeping extends CommonObject */ public $id; + /** + * @var string Date of source document, in db date NOT NULL + */ public $doc_date; + + /** + * @var int Deadline for payment + */ public $date_lim_reglement; /** @@ -119,9 +126,25 @@ class BookKeeping extends CommonObject * @var string label operation */ public $label_operation; + + /** + * @var float FEC:Debit + */ public $debit; + + /** + * @var float FEC:Credit + */ public $credit; + + /** + * @var float FEC:Amount (Not necessary) + */ public $montant; + + /** + * @var string FEC:Sens (Not necessary) + */ public $sens; /** @@ -129,9 +152,24 @@ class BookKeeping extends CommonObject */ public $fk_user_author; + /** + * @var string key for import + */ public $import_key; + + /** + * @var string code journal + */ public $code_journal; + + /** + * @var string label journal + */ public $journal_label; + + /** + * @var int accounting transaction id + */ public $piece_num; /** @@ -140,7 +178,6 @@ class BookKeeping extends CommonObject public $picto = 'generic'; - /** * Constructor * diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a501a97f8b2..924e6045533 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1077,7 +1077,7 @@ else print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; 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/adherents/type.php b/htdocs/adherents/type.php index b1b18e3ed31..ecfd12142f4 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -373,11 +373,11 @@ if ($action == 'create') // Other attributes $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; print "\n"; @@ -823,7 +823,7 @@ if ($rowid > 0) print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index add400b6aef..64b11125d91 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -321,13 +321,15 @@ print ''; print ''; print ''; +$linkback=''.$langs->trans("BackToModuleList").''; + $newcardbutton = ''; //if ($user->rights->emailcollector->creer) //{ $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'])); //} -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton.' '.$linkback, '', $limit); // Add code for pre mass action (confirmation or email presend form) /*$topicmail=""; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 70191b5eb28..1ca019f5988 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -391,11 +391,11 @@ if ($action == 'create') // Other attributes $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; print "\n"; @@ -606,7 +606,7 @@ if ($rowid > 0) print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 524fd5c0f93..be4e9eed510 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -95,7 +95,7 @@ class BOM extends CommonObject 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'), 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'), 'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), - 'duration' => array('type'=>'real', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'), + 'duration' => array('type'=>'duration', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>102), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-2, 'position'=>161, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-2, 'position'=>162, 'notnull'=>-1,), diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 3578e0e0c60..d252171b38f 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -278,7 +278,7 @@ if ($user->rights->categorie->creer) print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 47110da8a92..868d149691a 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -83,16 +83,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); } @@ -131,50 +131,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++; @@ -183,7 +183,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; @@ -197,14 +197,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) { @@ -222,20 +222,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; } @@ -258,19 +258,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'); } @@ -311,21 +311,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'); } @@ -352,37 +352,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); @@ -393,7 +393,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)); @@ -432,37 +432,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); @@ -473,7 +473,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)); @@ -512,37 +512,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); @@ -553,7 +553,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)); } @@ -590,37 +590,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); @@ -631,7 +631,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)); } @@ -741,7 +741,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); } @@ -751,11 +751,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 525ee23c8bf..c9937d4eca9 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -789,18 +789,19 @@ class Categorie extends CommonObject $objs = array(); - $obj = new $this->MAP_OBJ_CLASS[$type]( $this->db ); + $tmpclass = $this->MAP_OBJ_CLASS[$type]; + $obj = new $tmpclass($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); @@ -937,7 +938,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; @@ -1577,7 +1578,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/categories/edit.php b/htdocs/categories/edit.php index a45ca818dbc..9c653decdff 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -180,7 +180,7 @@ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index fdf06497355..afd71d59932 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1132,7 +1132,7 @@ if ($action == 'create') print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; @@ -1549,7 +1549,7 @@ if ($id > 0) print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index a2d8c0a373b..8deb8100c72 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1242,7 +1242,7 @@ else print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f949e118599..803d699077f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1771,7 +1771,7 @@ if ($action == 'create' && $usercancreate) } }; - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } // Template to use by default diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 07d18855c86..21bcbf5bf26 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -443,7 +443,7 @@ if ($action == 'create') print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; @@ -945,7 +945,7 @@ else print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print ''; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index c80a0cd0ab8..ab93b2f0f97 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -344,8 +344,6 @@ if ($action == 'create') $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print ''; - // Category if (is_array($options) && count($options) && $conf->categorie->enabled) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 48cd8e81054..b6997922e2a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3282,11 +3282,11 @@ if ($action == 'create') } // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="2"', 'cols'=>2); + $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="2"', 'cols' => '2'); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } // Template to use by default diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 1e2050c5a47..c693aa89b4c 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -42,12 +42,12 @@ class BonPrelevement extends CommonObject /** * @var string ID to identify managed object */ - public $element='widthdraw'; + public $element = 'widthdraw'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='prelevement_bons'; + public $table_element = 'prelevement_bons'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -68,11 +68,11 @@ class BonPrelevement extends CommonObject public $total; public $fetched; - public $statut; // 0-Wait, 1-Trans, 2-Done - public $labelStatus=array(); + public $statut; // 0-Wait, 1-Trans, 2-Done + public $labelStatus = array(); - public $invoice_in_error=array(); - public $thirdparty_in_error=array(); + public $invoice_in_error = array(); + public $thirdparty_in_error = array(); const STATUS_DRAFT = 0; const STATUS_TRANSFERED = 1; @@ -87,12 +87,12 @@ class BonPrelevement extends CommonObject */ public function __construct($db, $filename = '') { - global $conf,$langs; + global $conf, $langs; $error = 0; $this->db = $db; - $this->filename=$filename; + $this->filename = $filename; $this->date_echeance = time(); $this->raison_sociale = ""; @@ -143,12 +143,12 @@ class BonPrelevement extends CommonObject if ($line_id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture ("; - $sql.= "fk_facture"; - $sql.= ",fk_prelevement_lignes"; - $sql.= ") VALUES ("; - $sql.= $facture_id; - $sql.= ", ".$line_id; - $sql.= ")"; + $sql .= "fk_facture"; + $sql .= ",fk_prelevement_lignes"; + $sql .= ") VALUES ("; + $sql .= $facture_id; + $sql .= ", ".$line_id; + $sql .= ")"; if ($this->db->query($sql)) { @@ -199,14 +199,14 @@ class BonPrelevement extends CommonObject * We aggregate the lines */ $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes"; - $sql.= " WHERE fk_prelevement_bons = ".$this->id; - $sql.= " AND fk_soc =".$client_id; - $sql.= " AND code_banque ='".$code_banque."'"; - $sql.= " AND code_guichet ='".$code_guichet."'"; - $sql.= " AND number ='".$number."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes"; + $sql .= " WHERE fk_prelevement_bons = ".$this->id; + $sql .= " AND fk_soc =".$client_id; + $sql .= " AND code_banque ='".$code_banque."'"; + $sql .= " AND code_guichet ='".$code_guichet."'"; + $sql .= " AND number ='".$number."'"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -222,24 +222,24 @@ class BonPrelevement extends CommonObject * No aggregate */ $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_lignes ("; - $sql.= "fk_prelevement_bons"; - $sql.= ", fk_soc"; - $sql.= ", client_nom"; - $sql.= ", amount"; - $sql.= ", code_banque"; - $sql.= ", code_guichet"; - $sql.= ", number"; - $sql.= ", cle_rib"; - $sql.= ") VALUES ("; - $sql.= $this->id; - $sql.= ", ".$client_id; - $sql.= ", '".$this->db->escape($client_nom)."'"; - $sql.= ", '".price2num($amount)."'"; - $sql.= ", '".$code_banque."'"; - $sql.= ", '".$code_guichet."'"; - $sql.= ", '".$number."'"; - $sql.= ", '".$number_key."'"; - $sql.= ")"; + $sql .= "fk_prelevement_bons"; + $sql .= ", fk_soc"; + $sql .= ", client_nom"; + $sql .= ", amount"; + $sql .= ", code_banque"; + $sql .= ", code_guichet"; + $sql .= ", number"; + $sql .= ", cle_rib"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", ".$client_id; + $sql .= ", '".$this->db->escape($client_nom)."'"; + $sql .= ", '".price2num($amount)."'"; + $sql .= ", '".$code_banque."'"; + $sql .= ", '".$code_guichet."'"; + $sql .= ", '".$number."'"; + $sql .= ", '".$number_key."'"; + $sql .= ")"; if ($this->db->query($sql)) { @@ -285,19 +285,19 @@ class BonPrelevement extends CommonObject global $conf; $sql = "SELECT p.rowid, p.ref, p.amount, p.note"; - $sql.= ", p.datec as dc"; - $sql.= ", p.date_trans as date_trans"; - $sql.= ", p.method_trans, p.fk_user_trans"; - $sql.= ", p.date_credit as date_credit"; - $sql.= ", p.fk_user_credit"; - $sql.= ", p.statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; - $sql.= " WHERE p.entity IN (".getEntity('invoice').")"; - if ($rowid > 0) $sql.= " AND p.rowid = ".$rowid; - else $sql.= " AND p.ref = '".$this->db->escape($ref)."'"; + $sql .= ", p.datec as dc"; + $sql .= ", p.date_trans as date_trans"; + $sql .= ", p.method_trans, p.fk_user_trans"; + $sql .= ", p.date_credit as date_credit"; + $sql .= ", p.fk_user_credit"; + $sql .= ", p.statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; + $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; + if ($rowid > 0) $sql .= " AND p.rowid = ".$rowid; + else $sql .= " AND p.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -344,30 +344,30 @@ class BonPrelevement extends CommonObject public function set_credite() { // phpcs:enable - global $user,$conf; + global $user, $conf; $error = 0; if ($this->db->begin()) { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; - $sql.= " SET statut = 1"; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND entity = ".$conf->entity; + $sql .= " SET statut = 1"; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; - $result=$this->db->query($sql); - if (! $result) + $result = $this->db->query($sql); + if (!$result) { dol_syslog(get_class($this)."::set_credite Erreur 1"); $error++; } - if (! $error) + if (!$error) { $facs = array(); $facs = $this->getListInvoices(); - $num=count($facs); + $num = count($facs); for ($i = 0; $i < $num; $i++) { /* Tag invoice as payed */ @@ -378,13 +378,13 @@ class BonPrelevement extends CommonObject } } - if (! $error) + if (!$error) { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; - $sql.= " SET statut = 2"; - $sql.= " WHERE fk_prelevement_bons = ".$this->id; + $sql .= " SET statut = 2"; + $sql .= " WHERE fk_prelevement_bons = ".$this->id; - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { dol_syslog(get_class($this)."::set_credite Erreur 1"); $error++; @@ -394,7 +394,7 @@ class BonPrelevement extends CommonObject /* * End of procedure */ - if (! $error) + if (!$error) { $this->db->commit(); return 0; @@ -425,7 +425,7 @@ class BonPrelevement extends CommonObject public function set_infocredit($user, $date) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $error = 0; @@ -436,12 +436,12 @@ class BonPrelevement extends CommonObject if ($this->db->begin()) { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons "; - $sql.= " SET fk_user_credit = ".$user->id; - $sql.= ", statut = 2"; - $sql.= ", date_credit = '".$this->db->idate($date)."'"; - $sql.= " WHERE rowid=".$this->id; - $sql.= " AND entity = ".$conf->entity; - $sql.= " AND statut = 1"; + $sql .= " SET fk_user_credit = ".$user->id; + $sql .= ", statut = 2"; + $sql .= ", date_credit = '".$this->db->idate($date)."'"; + $sql .= " WHERE rowid=".$this->id; + $sql .= " AND entity = ".$conf->entity; + $sql .= " AND statut = 1"; if ($this->db->query($sql)) { @@ -458,7 +458,7 @@ class BonPrelevement extends CommonObject $facs = $this->getListInvoices(1); // Loop on each invoice. $facs=array(0=>id, 1=>amount requested) - $num=count($facs); + $num = count($facs); for ($i = 0; $i < $num; $i++) { $fac = new Facture($this->db); @@ -466,7 +466,7 @@ class BonPrelevement extends CommonObject $amounts[$fac->id] = $facs[$i][1]; $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; - $totalpaye = $fac->getSommePaiement(); + $totalpaye = $fac->getSommePaiement(); $totalcreditnotes = $fac->getSumCreditNotesUsed(); $totaldeposits = $fac->getSumDepositsUsed(); $alreadypayed = $totalpaye + $totalcreditnotes + $totaldeposits; @@ -481,9 +481,9 @@ class BonPrelevement extends CommonObject { $paiement = new Paiement($this->db); $paiement->datepaye = $date; - $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice - $paiement->paiementid = 3; // - $paiement->num_paiement = $this->ref; // Set ref of direct debit note + $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice + $paiement->paiementid = 3; // + $paiement->num_paiement = $this->ref; // Set ref of direct debit note $paiement->id_prelevement = $this->id; $paiement_id = $paiement->create($user); @@ -494,7 +494,7 @@ class BonPrelevement extends CommonObject } else { - $result=$paiement->addPaymentToBank($user, 'payment', '(WithdrawalPayment)', $bankaccount, '', ''); + $result = $paiement->addPaymentToBank($user, 'payment', '(WithdrawalPayment)', $bankaccount, '', ''); if ($result < 0) { dol_syslog(get_class($this)."::set_infocredit AddPaymentToBank Error"); @@ -509,10 +509,10 @@ class BonPrelevement extends CommonObject // Update withdrawal line // TODO: Translate to ligneprelevement.class.php $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; - $sql.= " SET statut = 2"; - $sql.= " WHERE fk_prelevement_bons = ".$this->id; + $sql .= " SET statut = 2"; + $sql .= " WHERE fk_prelevement_bons = ".$this->id; - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { dol_syslog(get_class($this)."::set_infocredit Update lines Error"); $error++; @@ -572,7 +572,7 @@ class BonPrelevement extends CommonObject public function set_infotrans($user, $date, $method) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $error = 0; @@ -580,13 +580,13 @@ class BonPrelevement extends CommonObject if ($this->db->begin()) { $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons "; - $sql.= " SET fk_user_trans = ".$user->id; - $sql.= " , date_trans = '".$this->db->idate($date)."'"; - $sql.= " , method_trans = ".$method; - $sql.= " , statut = 1"; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND entity = ".$conf->entity; - $sql.= " AND statut = 0"; + $sql .= " SET fk_user_trans = ".$user->id; + $sql .= " , date_trans = '".$this->db->idate($date)."'"; + $sql .= " , method_trans = ".$method; + $sql .= " , statut = 1"; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; + $sql .= " AND statut = 0"; if ($this->db->query($sql)) { @@ -594,7 +594,7 @@ class BonPrelevement extends CommonObject $langs->load('withdrawals'); $subject = $langs->trans("InfoTransSubject", $this->ref); $message = $langs->trans("InfoTransMessage", $this->ref, dolGetFirstLastname($user->firstname, $user->lastname)); - $message .=$langs->trans("InfoTransData", price($this->amount), $this->methodes_trans[$this->method_trans], dol_print_date($date, 'day')); + $message .= $langs->trans("InfoTransData", price($this->amount), $this->methodes_trans[$this->method_trans], dol_print_date($date, 'day')); // TODO Call trigger to create a notification using notification module } @@ -644,16 +644,16 @@ class BonPrelevement extends CommonObject */ $sql = "SELECT fk_facture"; if ($amounts) $sql .= ", SUM(pl.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; - $sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; - $sql.= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; - $sql.= " WHERE pf.fk_prelevement_lignes = pl.rowid"; - $sql.= " AND pl.fk_prelevement_bons = p.rowid"; - $sql.= " AND p.rowid = ".$this->id; - $sql.= " AND p.entity = ".$conf->entity; - if ($amounts) $sql.= " GROUP BY fk_facture"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; + $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; + $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid"; + $sql .= " AND pl.fk_prelevement_bons = p.rowid"; + $sql .= " AND p.rowid = ".$this->id; + $sql .= " AND p.entity = ".$conf->entity; + if ($amounts) $sql .= " GROUP BY fk_facture"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -697,18 +697,18 @@ class BonPrelevement extends CommonObject global $conf; $sql = "SELECT sum(pfd.amount) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f,"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; //$sql.= " ,".MAIN_DB_PREFIX."c_paiement as cp"; - $sql.= " WHERE f.fk_statut = 1"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.rowid = pfd.fk_facture"; - $sql.= " AND f.paye = 0"; - $sql.= " AND pfd.traite = 0"; - $sql.= " AND f.total_ttc > 0"; + $sql .= " WHERE f.fk_statut = 1"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.rowid = pfd.fk_facture"; + $sql .= " AND f.paye = 0"; + $sql .= " AND pfd.traite = 0"; + $sql .= " AND f.total_ttc > 0"; $resql = $this->db->query($sql); - if ( $resql ) + if ($resql) { $obj = $this->db->fetch_object($resql); @@ -739,21 +739,21 @@ class BonPrelevement extends CommonObject global $conf; $sql = "SELECT count(f.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " WHERE f.entity IN (".getEntity('invoice').")"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { - $sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; + $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; } - $sql.= " AND f.rowid = pfd.fk_facture"; - $sql.= " AND pfd.traite = 0"; - $sql.= " AND f.total_ttc > 0"; + $sql .= " AND f.rowid = pfd.fk_facture"; + $sql .= " AND pfd.traite = 0"; + $sql .= " AND f.total_ttc > 0"; dol_syslog(get_class($this)."::NbFactureAPrelever"); $resql = $this->db->query($sql); - if ( $resql ) + if ($resql) { $obj = $this->db->fetch_object($resql); @@ -763,7 +763,7 @@ class BonPrelevement extends CommonObject } else { - $this->error=get_class($this)."::NbFactureAPrelever Erreur -1 sql=".$this->db->error(); + $this->error = get_class($this)."::NbFactureAPrelever Erreur -1 sql=".$this->db->error(); return -1; } } @@ -798,7 +798,7 @@ class BonPrelevement extends CommonObject $datetimeprev = time(); //Choice the date of the execution direct debit - if(!empty($executiondate)) $datetimeprev = $executiondate; + if (!empty($executiondate)) $datetimeprev = $executiondate; $month = strftime("%m", $datetimeprev); $year = strftime("%Y", $datetimeprev); @@ -810,26 +810,26 @@ class BonPrelevement extends CommonObject $factures = array(); $factures_prev = array(); $factures_result = array(); - $factures_prev_id=array(); - $factures_errors=array(); + $factures_prev_id = array(); + $factures_errors = array(); - if (! $error) + if (!$error) { $sql = "SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc"; - $sql.= ", pfd.code_banque, pfd.code_guichet, pfd.number, pfd.cle_rib"; - $sql.= ", pfd.amount"; - $sql.= ", s.nom as name"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql.= " WHERE f.rowid = pfd.fk_facture"; - $sql.= " AND f.entity IN (".getEntity('invoice').')'; - $sql.= " AND s.rowid = f.fk_soc"; + $sql .= ", pfd.code_banque, pfd.code_guichet, pfd.number, pfd.cle_rib"; + $sql .= ", pfd.amount"; + $sql .= ", s.nom as name"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " WHERE f.rowid = pfd.fk_facture"; + $sql .= " AND f.entity IN (".getEntity('invoice').')'; + $sql .= " AND s.rowid = f.fk_soc"; //if ($banque || $agence) $sql.= " AND s.rowid = sr.fk_soc"; - $sql.= " AND f.fk_statut = 1"; - $sql.= " AND f.paye = 0"; - $sql.= " AND pfd.traite = 0"; - $sql.= " AND f.total_ttc > 0"; + $sql .= " AND f.fk_statut = 1"; + $sql .= " AND f.paye = 0"; + $sql .= " AND pfd.traite = 0"; + $sql .= " AND f.total_ttc > 0"; //if ($banque) $sql.= " AND sr.code_banque = '".$conf->global->PRELEVEMENT_CODE_BANQUE."'"; //if ($agence) $sql.= " AND sr.code_guichet = '".$conf->global->PRELEVEMENT_CODE_GUICHET."'"; @@ -844,7 +844,7 @@ class BonPrelevement extends CommonObject while ($i < $num) { $row = $this->db->fetch_row($resql); - $factures[$i] = $row; // All fields + $factures[$i] = $row; // All fields $i++; } $this->db->free($resql); @@ -857,9 +857,9 @@ class BonPrelevement extends CommonObject } } - if (! $error) + if (!$error) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $soc = new Societe($this->db); // Check RIB @@ -899,8 +899,8 @@ class BonPrelevement extends CommonObject else { dol_syslog(__METHOD__."::Check RIB Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_WARNING); - $this->invoice_in_error[$fac[0]]="Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); - $this->thirdparty_in_error[$soc->id]="Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); + $this->thirdparty_in_error[$soc->id] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); } } else @@ -920,10 +920,10 @@ class BonPrelevement extends CommonObject } } - $ok=0; + $ok = 0; // Withdraw invoices in factures_prev array - $out=count($factures_prev)." invoices will be withdrawn."; + $out = count($factures_prev)." invoices will be withdrawn."; //print $out."\n"; dol_syslog($out); @@ -938,9 +938,9 @@ class BonPrelevement extends CommonObject if (count($factures_prev) > 0) { - if ($mode=='real') + if ($mode == 'real') { - $ok=1; + $ok = 1; } else { @@ -957,7 +957,7 @@ class BonPrelevement extends CommonObject */ $this->db->begin(); - $now=dol_now(); + $now = dol_now(); /* * Traitements @@ -967,10 +967,10 @@ class BonPrelevement extends CommonObject $ref = substr($year, -2).$month; $sql = "SELECT substring(ref from char_length(ref) - 1)"; - $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; - $sql.= " WHERE ref LIKE '%".$this->db->escape($ref)."%'"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " ORDER BY ref DESC LIMIT 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; + $sql .= " WHERE ref LIKE '%".$this->db->escape($ref)."%'"; + $sql .= " AND entity = ".$conf->entity; + $sql .= " ORDER BY ref DESC LIMIT 1"; dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -978,21 +978,21 @@ class BonPrelevement extends CommonObject if ($resql) { $row = $this->db->fetch_row($resql); - $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1, 0, 2), 2, "0", STR_PAD_LEFT); + $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0]) + 1, 0, 2), 2, "0", STR_PAD_LEFT); - $dir=$conf->prelevement->dir_output.'/receipts'; - if (! is_dir($dir)) dol_mkdir($dir); + $dir = $conf->prelevement->dir_output.'/receipts'; + if (!is_dir($dir)) dol_mkdir($dir); $this->filename = $dir.'/'.$ref.'.xml'; // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; - $sql.= " ref, entity, datec"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($ref)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ")"; + $sql .= " ref, entity, datec"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($ref)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ")"; $resql = $this->db->query($sql); if ($resql) @@ -1046,15 +1046,15 @@ class BonPrelevement extends CommonObject // Update invoice requests as done $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande"; - $sql.= " SET traite = 1"; - $sql.= ", date_traite = '".$this->db->idate($now)."'"; - $sql.= ", fk_prelevement_bons = ".$this->id; - $sql.= " WHERE rowid = ".$fac[1]; + $sql .= " SET traite = 1"; + $sql .= ", date_traite = '".$this->db->idate($now)."'"; + $sql .= ", fk_prelevement_bons = ".$this->id; + $sql .= " WHERE rowid = ".$fac[1]; dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; dol_syslog(__METHOD__."::Update Orders::Error=".$this->db->error(), LOG_ERR); @@ -1077,18 +1077,18 @@ class BonPrelevement extends CommonObject $this->date_echeance = $datetimeprev; $this->reference_remise = $ref; - $id=$conf->global->PRELEVEMENT_ID_BANKACCOUNT; + $id = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; $account = new Account($this->db); - if ($account->fetch($id)>0) + if ($account->fetch($id) > 0) { - $this->emetteur_code_banque = $account->code_banque; + $this->emetteur_code_banque = $account->code_banque; $this->emetteur_code_guichet = $account->code_guichet; $this->emetteur_numero_compte = $account->number; - $this->emetteur_number_key = $account->cle_rib; + $this->emetteur_number_key = $account->cle_rib; $this->emetteur_iban = $account->iban; $this->emetteur_bic = $account->bic; - $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; + $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; $this->raison_sociale = $account->proprio; } @@ -1107,21 +1107,21 @@ class BonPrelevement extends CommonObject * Update total */ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; - $sql.= " SET amount = ".price2num($this->total); - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND entity = ".$conf->entity; + $sql .= " SET amount = ".price2num($this->total); + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR); } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user); + $result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -1158,43 +1158,43 @@ class BonPrelevement extends CommonObject $error = 0; $resql1 = $resql2 = $resql3 = $resql4 = 0; - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user); + $result = $this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_facture WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".$this->id.")"; - $resql1=$this->db->query($sql); - if (! $resql1) dol_print_error($this->db); + $resql1 = $this->db->query($sql); + if (!$resql1) dol_print_error($this->db); } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = ".$this->id; - $resql2=$this->db->query($sql); - if (! $resql2) dol_print_error($this->db); + $resql2 = $this->db->query($sql); + if (!$resql2) dol_print_error($this->db); } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_bons WHERE rowid = ".$this->id; - $resql3=$this->db->query($sql); - if (! $resql3) dol_print_error($this->db); + $resql3 = $this->db->query($sql); + if (!$resql3) dol_print_error($this->db); } - if (! $error) + if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = ".$this->id; - $resql4=$this->db->query($sql); - if (! $resql4) dol_print_error($this->db); + $resql4 = $this->db->query($sql); + if (!$resql4) dol_print_error($this->db); } - if ($resql1 && $resql2 && $resql3 && $resql4 && ! $error) + if ($resql1 && $resql2 && $resql3 && $resql4 && !$error) { $this->db->commit(); return 1; @@ -1221,34 +1221,34 @@ class BonPrelevement extends CommonObject { global $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; - $label = '' . $langs->trans("ShowWithdraw") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("ShowWithdraw").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('myobjectdao')); @@ -1257,22 +1257,22 @@ class BonPrelevement extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; + global $action, $hookmanager; $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -1293,7 +1293,7 @@ class BonPrelevement extends CommonObject $result = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; - $sql.= " WHERE rowid = '".$rowid."'"; + $sql .= " WHERE rowid = '".$rowid."'"; if ($this->db->query($sql)) { @@ -1347,7 +1347,7 @@ class BonPrelevement extends CommonObject if ($this->DeleteNotification($user, $action) == 0) { - $now=dol_now(); + $now = dol_now(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_user, fk_soc, fk_contact, fk_action)"; $sql .= " VALUES (".$db->idate($now).",".$user.", 'NULL', 'NULL', '".$action."')"; @@ -1381,7 +1381,7 @@ class BonPrelevement extends CommonObject */ public function generate($format = 'ALL', $executiondate = '') { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; //TODO: Optimize code to read lines in a single function @@ -1392,11 +1392,11 @@ class BonPrelevement extends CommonObject $this->file = fopen($this->filename, "w"); if (empty($this->file)) { - $this->error=$langs->trans('ErrorFailedToOpenFile', $this->filename); + $this->error = $langs->trans('ErrorFailedToOpenFile', $this->filename); return -1; } - $found=0; + $found = 0; // Build file for European countries if ($mysoc->isInEEC()) @@ -1414,9 +1414,9 @@ class BonPrelevement extends CommonObject $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); $date_actu = $now; - if (!empty($executiondate)) $date_actu=$executiondate; + if (!empty($executiondate)) $date_actu = $executiondate; - $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); + $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); $fileDebiteurSection = ''; $fileEmetteurSection = ''; @@ -1428,27 +1428,27 @@ class BonPrelevement extends CommonObject */ $sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,"; - $sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; - $sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum"; - $sql.= " FROM"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; - $sql.= " ".MAIN_DB_PREFIX."facture as f,"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_facture as pf,"; - $sql.= " ".MAIN_DB_PREFIX."societe as soc,"; - $sql.= " ".MAIN_DB_PREFIX."c_country as c,"; - $sql.= " ".MAIN_DB_PREFIX."societe_rib as rib"; - $sql.= " WHERE pl.fk_prelevement_bons = ".$this->id; - $sql.= " AND pl.rowid = pf.fk_prelevement_lignes"; - $sql.= " AND pf.fk_facture = f.rowid"; - $sql.= " AND soc.fk_pays = c.rowid"; - $sql.= " AND soc.rowid = f.fk_soc"; - $sql.= " AND rib.fk_soc = f.fk_soc"; - $sql.= " AND rib.default_rib = 1"; - $sql.= " AND rib.type = 'ban'"; + $sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,"; + $sql .= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum"; + $sql .= " FROM"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; + $sql .= " ".MAIN_DB_PREFIX."facture as f,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,"; + $sql .= " ".MAIN_DB_PREFIX."societe as soc,"; + $sql .= " ".MAIN_DB_PREFIX."c_country as c,"; + $sql .= " ".MAIN_DB_PREFIX."societe_rib as rib"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id; + $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; + $sql .= " AND pf.fk_facture = f.rowid"; + $sql .= " AND soc.fk_pays = c.rowid"; + $sql .= " AND soc.rowid = f.fk_soc"; + $sql .= " AND rib.fk_soc = f.fk_soc"; + $sql .= " AND rib.default_rib = 1"; + $sql .= " AND rib.type = 'ban'"; //print $sql; // Define $fileDebiteurSection. One section DrctDbtTxInf per invoice. - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -1464,7 +1464,7 @@ class BonPrelevement extends CommonObject } else { - fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers + fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers $result = -2; } @@ -1475,7 +1475,7 @@ class BonPrelevement extends CommonObject } else { - fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company + fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company } /** @@ -1504,10 +1504,10 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$CrLf); // SEPA File Emetteur if ($result != -2) - { fputs($this-> file, $fileEmetteurSection);} + { fputs($this-> file, $fileEmetteurSection); } // SEPA File Debiteurs if ($result != -2) - { fputs($this-> file, $fileDebiteurSection);} + { fputs($this-> file, $fileDebiteurSection); } // SEPA FILE FOOTER fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1515,21 +1515,21 @@ class BonPrelevement extends CommonObject } // Build file for Other Countries with unknow format - if (! $found) + if (!$found) { $this->total = 0; $sql = "SELECT pl.amount"; - $sql.= " FROM"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; - $sql.= " ".MAIN_DB_PREFIX."facture as f,"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_facture as pf"; - $sql.= " WHERE pl.fk_prelevement_bons = ".$this->id; - $sql.= " AND pl.rowid = pf.fk_prelevement_lignes"; - $sql.= " AND pf.fk_facture = f.rowid"; + $sql .= " FROM"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; + $sql .= " ".MAIN_DB_PREFIX."facture as f,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf"; + $sql .= " WHERE pl.fk_prelevement_bons = ".$this->id; + $sql .= " AND pl.rowid = pf.fk_prelevement_lignes"; + $sql .= " AND pf.fk_facture = f.rowid"; //Lines $i = 0; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -1553,7 +1553,7 @@ class BonPrelevement extends CommonObject } fclose($this->file); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($this->file, octdec($conf->global->MAIN_UMASK)); return $result; } @@ -1643,7 +1643,7 @@ class BonPrelevement extends CommonObject public static function buildRumNumber($row_code_client, $row_datec, $row_drum) { global $langs; - $pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation) + $pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation) return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } @@ -1687,46 +1687,46 @@ class BonPrelevement extends CommonObject // Define date of RUM signature $DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d'); - $XML_DEBITOR =''; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; + $XML_DEBITOR = ''; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters - $XML_DEBITOR .=' '.(($conf->global->PRELEVEMENT_END_TO_END != "" ) ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.round($row_somme, 2).''.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$Rum.''.$CrLf; - $XML_DEBITOR .=' '.$DtOfSgntr.''.$CrLf; - $XML_DEBITOR .=' false'.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$row_bic.''.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$row_country_code.''.$CrLf; + $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.round($row_somme, 2).''.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$Rum.''.$CrLf; + $XML_DEBITOR .= ' '.$DtOfSgntr.''.$CrLf; + $XML_DEBITOR .= ' false'.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$row_bic.''.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = dol_string_unaccent(strtr($row_zip.(($row_zip && $row_town)?' ':''.$row_town), array(CHR(13) => ", ", CHR(10) => ""))); - if (trim($addressline1)) $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf; - if (trim($addressline2)) $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', true)).''.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.preg_replace('/\s/', '', $row_iban).''.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; + $addressline2 = dol_string_unaccent(strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => ""))); + if (trim($addressline1)) $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf; + if (trim($addressline2)) $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline2, 70, 'right', 'UTF-8', true)).''.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.preg_replace('/\s/', '', $row_iban).''.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max - $XML_DEBITOR .=' '.(($conf->global->PRELEVEMENT_USTRD != "" ) ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135) ).''.$CrLf; // 140 max - $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.$CrLf; + $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max + $XML_DEBITOR .= ' '.$CrLf; + $XML_DEBITOR .= ' '.$CrLf; return $XML_DEBITOR; } @@ -1755,11 +1755,11 @@ class BonPrelevement extends CommonObject // Raison Sociale C2 - fputs($this->file, substr($this->raison_sociale. " ", 0, 24)); + fputs($this->file, substr($this->raison_sociale." ", 0, 24)); // Reference de la remise creancier D1 sur 7 caracteres - fputs($this->file, substr($this->reference_remise. " ", 0, 7)); + fputs($this->file, substr($this->reference_remise." ", 0, 7)); // Zone Reservee D1-2 @@ -1822,29 +1822,29 @@ class BonPrelevement extends CommonObject $dateTime_YMDHMS = dol_print_date($ladate, '%Y-%m-%dT%H:%M:%S'); // Get data of bank account - $id=$configuration->global->PRELEVEMENT_ID_BANKACCOUNT; + $id = $configuration->global->PRELEVEMENT_ID_BANKACCOUNT; $account = new Account($this->db); - if ($account->fetch($id)>0) + if ($account->fetch($id) > 0) { - $this->emetteur_code_banque = $account->code_banque; + $this->emetteur_code_banque = $account->code_banque; $this->emetteur_code_guichet = $account->code_guichet; $this->emetteur_numero_compte = $account->number; - $this->emetteur_number_key = $account->cle_rib; + $this->emetteur_number_key = $account->cle_rib; $this->emetteur_iban = $account->iban; $this->emetteur_bic = $account->bic; - $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; + $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; $this->raison_sociale = $account->proprio; } // Récupération info demandeur $sql = "SELECT rowid, ref"; - $sql.= " FROM"; - $sql.= " ".MAIN_DB_PREFIX."prelevement_bons as pb"; - $sql.= " WHERE pb.rowid = ".$this->id; + $sql .= " FROM"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_bons as pb"; + $sql .= " WHERE pb.rowid = ".$this->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -1876,7 +1876,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN)?' ':'').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => ""))); + $addressline2 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => ""))); if ($addressline1) $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf; if ($addressline2) $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index aa56428db30..35170e0d830 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -829,7 +829,7 @@ else print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print "
"; @@ -1162,12 +1162,12 @@ else } // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols'=>3); + $parameters = array('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; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } $object->load_ref_elements(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 724a19bdbb8..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,39 +1239,39 @@ 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 if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit', $parameters); } print "\n"; @@ -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/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 45fe792c81a..a24274b81af 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2019 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,15 +49,24 @@ if ($action == 'add' && ! empty($permissiontoadd)) { foreach ($object->fields as $key => $val) { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields + if ($object->fields[$key]['type'] == 'duration') { + if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') continue; // The field was not submited to be edited + } + else { + if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited + } + // Ignore special fields + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Set value to insert if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key, 'none'); - } elseif ($object->fields[$key]['type']=='date') { + } elseif ($object->fields[$key]['type'] == 'date') { $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); - } elseif ($object->fields[$key]['type']=='datetime') { + } elseif ($object->fields[$key]['type'] == 'datetime') { $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); + } elseif ($object->fields[$key]['type'] == 'duration') { + $value = 60*60*GETPOST($key.'hour', 'int') + 60*GETPOST($key.'min', 'int'); } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup } else { @@ -108,8 +117,16 @@ if ($action == 'update' && !empty($permissiontoadd)) { foreach ($object->fields as $key => $val) { - if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields + // Check if field was submited to be edited + if ($object->fields[$key]['type'] == 'duration') { + if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) continue; // The field was not submited to be edited + } + else { + if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited + } + // Ignore special fields + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; + // Set value to update if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key, 'none'); @@ -117,6 +134,12 @@ if ($action == 'update' && !empty($permissiontoadd)) $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type'] == 'datetime') { $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } elseif ($object->fields[$key]['type'] == 'duration') { + if (GETPOST($key.'hour', 'int') != '' || GETPOST($key.'min', 'int') != '') { + $value = 60*60*GETPOST($key.'hour', 'int') + 60*GETPOST($key.'min', 'int'); + } else { + $value = ''; + } } elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) { $value = price2num(GETPOST($key)); } else { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8aa24819efd..1ce1eca120f 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; @@ -5626,14 +5626,12 @@ abstract class CommonObject $objectid = $this->id; - if ($computed) { if (!preg_match('/^search_/', $keyprefix)) return ''.$langs->trans("AutomaticallyCalculated").''; else return ''; } - // Set value of $morecss. For this, we use in priority showsize from parameters, then $val['css'] then autodefine if (empty($morecss) && !empty($val['css'])) { @@ -5689,6 +5687,10 @@ abstract class CommonObject // TODO Must also support $moreparam $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } + elseif (in_array($type, array('duration'))) + { + $out=$form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1); + } elseif (in_array($type, array('int', 'integer'))) { $tmp = explode(',', $size); @@ -6088,77 +6090,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).'