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.= '| '.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).' | '; + print ''.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).' | '; print ''; if ($user->socid == 0) { if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') { - $tmpaction='activateline'; - $tmpactionpicto='play'; - $tmpactiontext=$langs->trans("Activate"); + $tmpaction = 'activateline'; + $tmpactionpicto = 'play'; + $tmpactiontext = $langs->trans("Activate"); if ($objp->statut == 4) { - $tmpaction='unactivateline'; - $tmpactionpicto='playstop'; - $tmpactiontext=$langs->trans("Disable"); + $tmpaction = 'unactivateline'; + $tmpactionpicto = 'playstop'; + $tmpactiontext = $langs->trans("Disable"); } - if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) + if (($tmpaction == 'activateline' && $user->rights->contrat->activer) || ($tmpaction == 'unactivateline' && $user->rights->contrat->desactiver)) { - print 'id . '&ligne=' . $object->lines[$cursorline - 1]->id . '&action=' . $tmpaction . '">'; + print 'id.'&ligne='.$object->lines[$cursorline - 1]->id.'&action='.$tmpaction.'">'; print img_picto($tmpactiontext, $tmpactionpicto); print ''; } @@ -2060,24 +2060,24 @@ else // Form to add new line if ($user->rights->contrat->creer && ($object->statut == 0)) { - $dateSelector=1; + $dateSelector = 1; print "\n"; - print ' |