Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Daniel Seichter 2019-11-25 23:14:19 +01:00
commit 7a4beb824f
164 changed files with 4887 additions and 3533 deletions

View File

@ -29,6 +29,7 @@ Following changes may create regressions for some external modules, but were nec
* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'. * All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'.
* All properties 'type_libelle' were renamed into 'type_label'. * All properties 'type_libelle' were renamed into 'type_label'.
* Renamed property of thirdparty "statut_commercial" into "status_prospect_label" * Renamed property of thirdparty "statut_commercial" into "status_prospect_label"
* The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core.
***** ChangeLog for 10.0.3 compared to 10.0.2 ***** ***** ChangeLog for 10.0.3 compared to 10.0.2 *****
IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card.

View File

@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("accountancy")); $langs->loadLangs(array("accountancy"));
$page = GETPOST("page"); $page = GETPOST("page", 'int');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');

View File

@ -575,8 +575,8 @@ if ($action == 'delmouv') {
} }
if ($action == 'delbookkeepingyear') { if ($action == 'delbookkeepingyear') {
$form_question = array(); $form_question = array();
$delyear = GETPOST('delyear'); $delyear = GETPOST('delyear', 'int');
$deljournal = GETPOST('deljournal'); $deljournal = GETPOST('deljournal', 'alpha');
if (empty($delyear)) { if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y'); $delyear = dol_print_date(dol_now(), '%Y');

View File

@ -36,7 +36,7 @@ class AccountancySystem
/** /**
* @var string Error code (or message) * @var string Error code (or message)
*/ */
public $error=''; public $error = '';
/** /**
* @var int ID * @var int ID
@ -48,7 +48,14 @@ class AccountancySystem
*/ */
public $fk_pcg_version; public $fk_pcg_version;
/**
* @var string pcg type
*/
public $pcg_type; public $pcg_type;
/**
* @var string pcg subtype
*/
public $pcg_subtype; public $pcg_subtype;
/** /**
@ -61,7 +68,14 @@ class AccountancySystem
*/ */
public $label; public $label;
/**
* @var string account number
*/
public $account_number; public $account_number;
/**
* @var string account parent
*/
public $account_parent; public $account_parent;
/** /**

View File

@ -42,8 +42,7 @@ class AccountingJournal extends CommonObject
public $fk_element = ''; public $fk_element = '';
/** /**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/ */
public $ismultientitymanaged = 0; public $ismultientitymanaged = 0;
@ -57,6 +56,9 @@ class AccountingJournal extends CommonObject
*/ */
public $rowid; public $rowid;
/**
* @var string Accounting journal code
*/
public $code; public $code;
/** /**
@ -64,9 +66,19 @@ class AccountingJournal extends CommonObject
*/ */
public $label; 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; public $active;
/**
* @var array array of lines
*/
public $lines; public $lines;
/** /**

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2014-2017 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2014-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015-2017 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015-2017 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -32,16 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/ */
class BookKeeping extends CommonObject class BookKeeping extends CommonObject
{ {
/**
* @var string Error code (or message)
*/
public $error;
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
/** /**
* @var string Id to identify managed objects * @var string Id to identify managed objects
*/ */
@ -67,7 +57,14 @@ class BookKeeping extends CommonObject
*/ */
public $id; public $id;
/**
* @var string Date of source document, in db date NOT NULL
*/
public $doc_date; public $doc_date;
/**
* @var int Deadline for payment
*/
public $date_lim_reglement; public $date_lim_reglement;
/** /**
@ -119,9 +116,25 @@ class BookKeeping extends CommonObject
* @var string label operation * @var string label operation
*/ */
public $label_operation; public $label_operation;
/**
* @var float FEC:Debit
*/
public $debit; public $debit;
/**
* @var float FEC:Credit
*/
public $credit; public $credit;
/**
* @var float FEC:Amount (Not necessary)
*/
public $montant; public $montant;
/**
* @var string FEC:Sens (Not necessary)
*/
public $sens; public $sens;
/** /**
@ -129,9 +142,24 @@ class BookKeeping extends CommonObject
*/ */
public $fk_user_author; public $fk_user_author;
/**
* @var string key for import
*/
public $import_key; public $import_key;
/**
* @var string code journal
*/
public $code_journal; public $code_journal;
/**
* @var string label journal
*/
public $journal_label; public $journal_label;
/**
* @var int accounting transaction id
*/
public $piece_num; public $piece_num;
/** /**
@ -140,7 +168,6 @@ class BookKeeping extends CommonObject
public $picto = 'generic'; public $picto = 'generic';
/** /**
* Constructor * Constructor
* *
@ -198,13 +225,13 @@ class BookKeeping extends CommonObject
$this->label_operation = trim($this->label_operation); $this->label_operation = trim($this->label_operation);
} }
if (isset($this->debit)) { if (isset($this->debit)) {
$this->debit = trim($this->debit); $this->debit = (float) $this->debit;
} }
if (isset($this->credit)) { if (isset($this->credit)) {
$this->credit = trim($this->credit); $this->credit = (float) $this->credit;
} }
if (isset($this->montant)) { if (isset($this->montant)) {
$this->montant = trim($this->montant); $this->montant = (float) $this->montant;
} }
if (isset($this->sens)) { if (isset($this->sens)) {
$this->sens = trim($this->sens); $this->sens = trim($this->sens);
@ -221,8 +248,8 @@ class BookKeeping extends CommonObject
if (isset($this->piece_num)) { if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
} }
if (empty($this->debit)) $this->debit = 0; if (empty($this->debit)) $this->debit = 0.0;
if (empty($this->credit)) $this->credit = 0; if (empty($this->credit)) $this->credit = 0.0;
// Check parameters // Check parameters
if (($this->numero_compte == "") || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') if (($this->numero_compte == "") || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined')

View File

@ -629,7 +629,9 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $objmid->labelc;
$accountingaccount->fetch(null, $k, true);
$bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_vat') { } elseif ($tabtype[$key] == 'payment_vat') {
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';

View File

@ -1077,7 +1077,7 @@ else
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '<tbody>'; print '<tbody>';

View File

@ -99,9 +99,9 @@ class AdherentType extends CommonObject
public $mail_valid; public $mail_valid;
/** @var array Array of members */ /** @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(); $current_lang = $langs->getDefaultLang();
$sql = "SELECT lang, label, description, email"; $sql = "SELECT lang, label, description, email";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id; $sql .= " WHERE fk_type=".$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { 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. 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->label = $obj->label;
$this->description = $obj->description; $this->description = $obj->description;
$this->email = $obj->email; $this->email = $obj->email;
} }
$this->multilangs["$obj->lang"]["label"] = $obj->label; $this->multilangs["$obj->lang"]["label"] = $obj->label;
@ -149,7 +149,7 @@ class AdherentType extends CommonObject
} }
else else
{ {
$this->error="Error: ".$this->db->lasterror()." - ".$sql; $this->error = "Error: ".$this->db->lasterror()." - ".$sql;
return -1; return -1;
} }
} }
@ -171,75 +171,75 @@ class AdherentType extends CommonObject
{ {
if ($key == $current_lang) { if ($key == $current_lang) {
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id; $sql .= " WHERE fk_type=".$this->id;
$sql.= " AND lang='".$key."'"; $sql .= " AND lang='".$key."'";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($this->db->num_rows($result)) // if there is already a description line for this language 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 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
$sql2.= " SET "; $sql2 .= " SET ";
$sql2.= " label='".$this->db->escape($this->label)."',"; $sql2 .= " label='".$this->db->escape($this->label)."',";
$sql2.= " description='".$this->db->escape($this->description)."'"; $sql2 .= " description='".$this->db->escape($this->description)."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", email='".$this->db->escape($this->other)."'"; 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 else
{ {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; $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 .= ")";
$sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->label)."',"; $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
$sql2.= " '".$this->db->escape($this->description)."'"; $sql2 .= " '".$this->db->escape($this->description)."'";
if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2.= ", '".$this->db->escape($this->other)."'"; 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); dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
if (! $this->db->query($sql2)) { if (!$this->db->query($sql2)) {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
elseif (isset($this->multilangs[$key])) { elseif (isset($this->multilangs[$key])) {
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type_lang"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
$sql.= " WHERE fk_type=".$this->id; $sql .= " WHERE fk_type=".$this->id;
$sql.= " AND lang='".$key."'"; $sql .= " AND lang='".$key."'";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($this->db->num_rows($result)) // if there is already a description line for this language 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 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
$sql2.= " SET "; $sql2 .= " SET ";
$sql2.= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; $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"])."'"; 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 else
{ {
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description"; $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 .= ")";
$sql2.= " VALUES(".$this->id.",'".$this->db->escape($key)."','". $this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2.= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; $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"])."'"; 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 // We do not save if main fields are empty
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) { if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
if (! $this->db->query($sql2)) { if (!$this->db->query($sql2)) {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
@ -272,7 +272,7 @@ class AdherentType extends CommonObject
public function delMultiLangs($langtodelete, $user) public function delMultiLangs($langtodelete, $user)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang"; $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); dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -289,7 +289,7 @@ class AdherentType extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
return -1; return -1;
} }
@ -306,22 +306,22 @@ class AdherentType extends CommonObject
{ {
global $langs, $conf; global $langs, $conf;
$error=0; $error = 0;
$this->statut=(int) $this->statut; $this->statut = (int) $this->statut;
$this->label=trim($this->label); $this->label = trim($this->label);
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
$sql.= " morphy"; $sql .= " morphy";
$sql.= ", libelle"; $sql .= ", libelle";
$sql.= ", entity"; $sql .= ", entity";
$sql.= ") VALUES ("; $sql .= ") VALUES (";
$sql.= "'".$this->db->escape($this->morphy)."'"; $sql .= "'".$this->db->escape($this->morphy)."'";
$sql.= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->escape($this->label)."'";
$sql.= ", ".$conf->entity; $sql .= ", ".$conf->entity;
$sql.= ")"; $sql .= ")";
dol_syslog("Adherent_type::create", LOG_DEBUG); dol_syslog("Adherent_type::create", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -336,15 +336,15 @@ class AdherentType extends CommonObject
return -3; return -3;
} }
if (! $notrigger) if (!$notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('MEMBER_TYPE_CREATE', $user); $result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
} }
if (! $error) if (!$error)
{ {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
@ -358,7 +358,7 @@ class AdherentType extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -375,23 +375,23 @@ class AdherentType extends CommonObject
{ {
global $langs, $conf, $hookmanager; global $langs, $conf, $hookmanager;
$error=0; $error = 0;
$this->label=trim($this->label); $this->label = trim($this->label);
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
$sql.= "SET "; $sql .= "SET ";
$sql.= "statut = ".$this->statut.","; $sql .= "statut = ".$this->statut.",";
$sql.= "libelle = '".$this->db->escape($this->label) ."',"; $sql .= "libelle = '".$this->db->escape($this->label)."',";
$sql.= "morphy = '".$this->db->escape($this->morphy) ."',"; $sql .= "morphy = '".$this->db->escape($this->morphy)."',";
$sql.= "subscription = '".$this->db->escape($this->subscription)."',"; $sql .= "subscription = '".$this->db->escape($this->subscription)."',";
$sql.= "duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."',"; $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
$sql.= "note = '".$this->db->escape($this->note)."',"; $sql .= "note = '".$this->db->escape($this->note)."',";
$sql.= "vote = ".(integer) $this->db->escape($this->vote).","; $sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
$sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; $sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
$sql.= " WHERE rowid =".$this->id; $sql .= " WHERE rowid =".$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
@ -399,34 +399,34 @@ class AdherentType extends CommonObject
$this->description = $this->db->escape($this->note); $this->description = $this->db->escape($this->note);
// Multilangs // Multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) { if (!empty($conf->global->MAIN_MULTILANGS)) {
if ($this->setMultiLangs($user) < 0) { 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; return -2;
} }
} }
$action='update'; $action = 'update';
// Actions on extra fields // 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) if ($result < 0)
{ {
$error++; $error++;
} }
} }
if (! $error && ! $notrigger) if (!$error && !$notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('MEMBER_TYPE_MODIFY', $user); $result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
} }
if (! $error) if (!$error)
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
@ -440,7 +440,7 @@ class AdherentType extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -458,13 +458,13 @@ class AdherentType extends CommonObject
$error = 0; $error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type"; $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) if ($resql)
{ {
// Call trigger // 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; } if ($result < 0) { $error++; $this->db->rollback(); return -2; }
// End call triggers // End call triggers
@ -474,7 +474,7 @@ class AdherentType extends CommonObject
else else
{ {
$this->db->rollback(); $this->db->rollback();
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
@ -495,7 +495,7 @@ class AdherentType extends CommonObject
dol_syslog("Adherent_type::fetch", LOG_DEBUG); dol_syslog("Adherent_type::fetch", LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($this->db->num_rows($resql)) if ($this->db->num_rows($resql))
@ -506,10 +506,10 @@ class AdherentType extends CommonObject
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->label = $obj->label; $this->label = $obj->label;
$this->morphy = $obj->morphy; $this->morphy = $obj->morphy;
$this->statut = $obj->status; // deprecated $this->statut = $obj->status; // deprecated
$this->status = $obj->status; $this->status = $obj->status;
$this->duration = $obj->duration; $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->duration_unit = substr($obj->duration, -1);
$this->subscription = $obj->subscription; $this->subscription = $obj->subscription;
$this->mail_valid = $obj->mail_valid; $this->mail_valid = $obj->mail_valid;
@ -517,7 +517,7 @@ class AdherentType extends CommonObject
$this->vote = $obj->vote; $this->vote = $obj->vote;
// multilangs // multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$this->getMultiLangs(); $this->getMultiLangs();
} }
} }
@ -526,7 +526,7 @@ class AdherentType extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
@ -540,15 +540,15 @@ class AdherentType extends CommonObject
public function liste_array() public function liste_array()
{ {
// phpcs:enable // phpcs:enable
global $conf,$langs; global $conf, $langs;
$adherenttypes = array(); $adherenttypes = array();
$sql = "SELECT rowid, libelle as label"; $sql = "SELECT rowid, libelle as label";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql.= " WHERE entity IN (".getEntity('member_type').")"; $sql .= " WHERE entity IN (".getEntity('member_type').")";
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$nump = $this->db->num_rows($resql); $nump = $this->db->num_rows($resql);
@ -585,13 +585,13 @@ class AdherentType extends CommonObject
{ {
global $conf, $user; global $conf, $user;
$ret=array(); $ret = array();
$sql = "SELECT a.rowid"; $sql = "SELECT a.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql.= " WHERE a.entity IN (".getEntity('member').")"; $sql .= " WHERE a.entity IN (".getEntity('member').")";
$sql.= " AND a.fk_adherent_type = ".$this->id; $sql .= " AND a.fk_adherent_type = ".$this->id;
if (! empty($excludefilter)) $sql.=' AND ('.$excludefilter.')'; if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')';
dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG); dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -599,31 +599,31 @@ class AdherentType extends CommonObject
{ {
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
if (! array_key_exists($obj->rowid, $ret)) if (!array_key_exists($obj->rowid, $ret))
{ {
if ($mode < 2) if ($mode < 2)
{ {
$memberstatic=new Adherent($this->db); $memberstatic = new Adherent($this->db);
if ($mode == 1) { if ($mode == 1) {
$memberstatic->fetch($obj->rowid, '', '', '', false, false); $memberstatic->fetch($obj->rowid, '', '', '', false, false);
} else { } else {
$memberstatic->fetch($obj->rowid); $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->db->free($resql);
$this->members=$ret; $this->members = $ret;
return $ret; return $ret;
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
@ -655,15 +655,15 @@ class AdherentType extends CommonObject
{ {
global $langs; global $langs;
$result=''; $result = '';
$label=$langs->trans("ShowTypeCard", $this->label); $label = $langs->trans("ShowTypeCard", $this->label);
$linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>'; $linkend = '</a>';
$result .= $linkstart; $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) $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 != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
$result .= $linkend; $result .= $linkend;
return $result; return $result;
@ -723,10 +723,10 @@ class AdherentType extends CommonObject
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
$dn=''; $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 == 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 == 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]; if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
return $dn; return $dn;
} }
@ -741,27 +741,27 @@ class AdherentType extends CommonObject
public function _load_ldap_info() public function _load_ldap_info()
{ {
// phpcs:enable // phpcs:enable
global $conf,$langs; global $conf, $langs;
$info=array(); $info = array();
// Object classes // Object classes
$info["objectclass"]=explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS); $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
// Champs // Champs
if ($this->label && ! empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label; 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 ($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 (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS))
{ {
$valueofldapfield=array(); $valueofldapfield = array();
foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database. 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); $member->fetch($val->id, '', '', '', false, false);
$info2 = $member->_load_ldap_info(); $info2 = $member->_load_ldap_info();
$valueofldapfield[] = $member->_load_ldap_dn($info2); $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; return $info;
} }
@ -780,18 +780,18 @@ class AdherentType extends CommonObject
// Initialise parametres // Initialise parametres
$this->id = 0; $this->id = 0;
$this->ref = 'MTSPEC'; $this->ref = 'MTSPEC';
$this->specimen=1; $this->specimen = 1;
$this->label='MEMBERS TYPE SPECIMEN'; $this->label = 'MEMBERS TYPE SPECIMEN';
$this->note='This is a note'; $this->note = 'This is a note';
$this->mail_valid='This is welcome email'; $this->mail_valid = 'This is welcome email';
$this->subscription=1; $this->subscription = 1;
$this->vote=0; $this->vote = 0;
$this->statut=1; $this->statut = 1;
// Members of this member type is just me // Members of this member type is just me
$this->members=array( $this->members = array(
$user->id => $user $user->id => $user
); );
} }
@ -805,7 +805,7 @@ class AdherentType extends CommonObject
{ {
global $conf; 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; return $this->mail_valid;
} }
@ -823,7 +823,7 @@ class AdherentType extends CommonObject
global $conf; global $conf;
// mail_subscription not defined so never used // 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; return $this->mail_subscription;
} }
@ -841,7 +841,7 @@ class AdherentType extends CommonObject
global $conf; global $conf;
// NOTE mail_resiliate not defined so never used // 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; return $this->mail_resiliate;
} }

View File

@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink)
} }
echo '</td>'; echo '</td>';
echo '<td class="right"></td>'; echo '<td class="right"></td>';
echo '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>'; echo '<td class="right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
echo '</tr>'; echo '</tr>';
} }

View File

@ -373,11 +373,11 @@ if ($action == 'create')
// Other attributes // Other attributes
$parameters = array(); $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; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '<tbody>'; print '<tbody>';
print "</table>\n"; print "</table>\n";
@ -823,7 +823,7 @@ if ($rowid > 0)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';

View File

@ -75,7 +75,7 @@ if (empty($action) && empty($id) && empty($ref)) $action = 'view';
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid; //if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
@ -418,10 +418,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (function_exists('imap_open')) if (function_exists('imap_open'))
{ {
$connectstringserver = $object->getConnectStringIMAP(); $connectstringserver = $object->getConnectStringIMAP();
$connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir);
$connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir);
$connection = imap_open($connectstringsource, $object->login, $object->password); try {
if ($sourcedir) {
//$connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir);
$connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir);
}
if ($targetdir) {
//$connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir);
$connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir);
}
$connection = imap_open($connectstringsource, $object->login, $object->password);
}
catch(Exception $e)
{
print $e->getMessage();
}
$morehtml .= $form->textwithpicto('', 'connect string '.$connectstringserver);
} }
else else
{ {
@ -509,11 +524,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
else { jQuery("#rulevalue").prop("disabled", false); } else { jQuery("#rulevalue").prop("disabled", false); }
jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder"))); jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder")));
'; ';
$noparam = array(); /*$noparam = array();
foreach ($arrayoftypes as $key => $value) foreach ($arrayoftypes as $key => $value)
{ {
if ($value['noparam']) $noparam[] = $key; if ($value['noparam']) $noparam[] = $key;
} }*/
print '})'; print '})';
print '</script>'."\n"; print '</script>'."\n";

View File

@ -321,13 +321,15 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
$newcardbutton = ''; $newcardbutton = '';
//if ($user->rights->emailcollector->creer) //if ($user->rights->emailcollector->creer)
//{ //{
$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'])); $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) // Add code for pre mass action (confirmation or email presend form)
/*$topicmail=""; /*$topicmail="";

View File

@ -43,7 +43,7 @@ $type='contract';
if (empty($conf->global->HOLIDAY_ADDON)) if (empty($conf->global->HOLIDAY_ADDON))
{ {
$conf->global->HOLIDAY_ADDON='mod_holiday_madona'; $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
} }

View File

@ -315,7 +315,7 @@ if ($action == 'edit')
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity))
{ {
print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" size="18" value="' . $mainserver . '">'; print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" size="18" value="' . $mainserver . '" autocomplete="off">';
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="' . $mainserver . '">'; print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="' . $mainserver . '">';
print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>'; print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
} }
@ -384,11 +384,13 @@ if ($action == 'edit')
if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
{ {
$mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:''); $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:'');
print '<tr class="drag drop oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'; print '<tr class="drag drop oddeven"><td>';
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword"));
print '</td><td>';
// SuperAdministrator access only // SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
{ {
print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . $mainsmtppw . '">'; print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . $mainsmtppw . '" autocomplete="off">';
} }
else else
{ {

View File

@ -135,6 +135,10 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
// Actions cancel, add, update, delete or clone
$backurlforlist = $_SERVER["PHP_SELF"].'?action=list';
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
@ -344,7 +348,7 @@ print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'"
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="'.($action == 'create' ? 'add' : 'list').'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
@ -354,7 +358,7 @@ $newcardbutton = '';
if ($action != 'create') { if ($action != 'create') {
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER['PHP_SELF'].'?action=create', '', $permissiontoadd); $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER['PHP_SELF'].'?action=create', '', $permissiontoadd);
} else { } else {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; /*print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
@ -362,13 +366,18 @@ if ($action != 'create') {
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
*/
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="label" value="'.GETPOST('label', 'alphanohtml').'"></td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="label" value="'.GETPOST('label', 'alphanohtml').'"></td></tr>';
print '<tr><td>'.$langs->trans("Email").'</td><td><input type="text" name="email" value="'.GETPOST('email', 'alphanohtml').'"></td></tr>'; print '<tr><td>'.$langs->trans("Email").'</td><td><input type="text" name="email" value="'.GETPOST('email', 'alphanohtml').'"></td></tr>';
print '<tr><td>'.$langs->trans("Signature").'</td><td><textarea name="signature">'.GETPOST('signature', 'none').'</textarea></td></tr>'; print '<tr><td>'.$langs->trans("Signature").'</td><td>';
print '<tr><td>'.$langs->trans("Position").'</td><td><input type="text" name="label" class="maxwidth50" value="'.GETPOST('position', 'int').'"></td></tr>'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%');
print $doleditor->Create(1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Position").'</td><td><input type="text" name="position" class="maxwidth50" value="'.GETPOST('position', 'int').'"></td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>'; print '<tr><td>'.$langs->trans("Status").'</td><td>';
print '<input type="text" name="status" value="'.GETPOST('status', 'int').'">'; print $form->selectyesno('active', GETPOST('active', 'int'), 1);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@ -377,7 +386,7 @@ if ($action != 'create') {
print ' &nbsp; '; print ' &nbsp; ';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; //print '</form>';
} }
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit);

View File

@ -79,7 +79,7 @@ class Documents extends DolibarrApi
} }
//--- Finds and returns the document //--- Finds and returns the document
$entity=$conf->entity; $entity = $conf->entity;
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
$accessallowed = $check_access['accessallowed']; $accessallowed = $check_access['accessallowed'];
@ -94,16 +94,16 @@ class Documents extends DolibarrApi
} }
$filename = basename($original_file); $filename = basename($original_file);
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
if (! file_exists($original_file_osencoded)) if (!file_exists($original_file_osencoded))
{ {
dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING);
throw new RestException(404, 'File not found'); throw new RestException(404, 'File not found');
} }
$file_content=file_get_contents($original_file_osencoded); $file_content = file_get_contents($original_file_osencoded);
return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64' ); return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64');
} }
@ -141,12 +141,12 @@ class Documents extends DolibarrApi
$outputlangs = $langs; $outputlangs = $langs;
if ($langcode && $langs->defaultlang != $langcode) if ($langcode && $langs->defaultlang != $langcode)
{ {
$outputlangs=new Translate('', $conf); $outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($langcode); $outputlangs->setDefaultLang($langcode);
} }
//--- Finds and returns the document //--- Finds and returns the document
$entity=$conf->entity; $entity = $conf->entity;
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write');
$accessallowed = $check_access['accessallowed']; $accessallowed = $check_access['accessallowed'];
@ -165,20 +165,20 @@ class Documents extends DolibarrApi
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1; $hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1; $hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
$templateused=''; $templateused = '';
if ($modulepart == 'facture' || $modulepart == 'invoice') if ($modulepart == 'facture' || $modulepart == 'invoice')
{ {
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$this->invoice = new Facture($this->db); $this->invoice = new Facture($this->db);
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); $result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) { if (!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
$templateused = $doctemplate?$doctemplate:$this->invoice->modelpdf; $templateused = $doctemplate ? $doctemplate : $this->invoice->modelpdf;
$result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); $result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) { if ($result <= 0) {
throw new RestException(500, 'Error generating document'); throw new RestException(500, 'Error generating document');
} }
} }
@ -187,12 +187,12 @@ class Documents extends DolibarrApi
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$this->order = new Commande($this->db); $this->order = new Commande($this->db);
$result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); $result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) { if (!$result) {
throw new RestException(404, 'Order not found'); throw new RestException(404, 'Order not found');
} }
$templateused = $doctemplate?$doctemplate:$this->order->modelpdf; $templateused = $doctemplate ? $doctemplate : $this->order->modelpdf;
$result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); $result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) { if ($result <= 0) {
throw new RestException(500, 'Error generating document'); throw new RestException(500, 'Error generating document');
} }
} }
@ -201,12 +201,12 @@ class Documents extends DolibarrApi
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$this->propal = new Propal($this->db); $this->propal = new Propal($this->db);
$result = $this->propal->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); $result = $this->propal->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) { if (!$result) {
throw new RestException(404, 'Proposal not found'); throw new RestException(404, 'Proposal not found');
} }
$templateused = $doctemplate?$doctemplate:$this->propal->modelpdf; $templateused = $doctemplate ? $doctemplate : $this->propal->modelpdf;
$result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); $result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) { if ($result <= 0) {
throw new RestException(500, 'Error generating document'); throw new RestException(500, 'Error generating document');
} }
} }
@ -216,15 +216,15 @@ class Documents extends DolibarrApi
} }
$filename = basename($original_file); $filename = basename($original_file);
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
if (! file_exists($original_file_osencoded)) if (!file_exists($original_file_osencoded))
{ {
throw new RestException(404, 'File not found'); throw new RestException(404, 'File not found');
} }
$file_content=file_get_contents($original_file_osencoded); $file_content = file_get_contents($original_file_osencoded);
return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64' ); return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64');
} }
/** /**
@ -257,7 +257,7 @@ class Documents extends DolibarrApi
throw new RestException(400, 'bad value for parameter id or ref'); throw new RestException(400, 'bad value for parameter id or ref');
} }
$id = (empty($id)?0:$id); $id = (empty($id) ? 0 : $id);
if ($modulepart == 'societe' || $modulepart == 'thirdparty') if ($modulepart == 'societe' || $modulepart == 'thirdparty')
{ {
@ -268,12 +268,12 @@ class Documents extends DolibarrApi
} }
$object = new Societe($this->db); $object = new Societe($this->db);
$result=$object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Thirdparty not found'); throw new RestException(404, 'Thirdparty not found');
} }
$upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
} }
elseif ($modulepart == 'adherent' || $modulepart == 'member') elseif ($modulepart == 'adherent' || $modulepart == 'member')
{ {
@ -284,12 +284,12 @@ class Documents extends DolibarrApi
} }
$object = new Adherent($this->db); $object = new Adherent($this->db);
$result=$object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Member not found'); throw new RestException(404, 'Member not found');
} }
$upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); $upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
} }
elseif ($modulepart == 'propal' || $modulepart == 'proposal') elseif ($modulepart == 'propal' || $modulepart == 'proposal')
{ {
@ -300,12 +300,12 @@ class Documents extends DolibarrApi
} }
$object = new Propal($this->db); $object = new Propal($this->db);
$result=$object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Proposal not found'); throw new RestException(404, 'Proposal not found');
} }
$upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); $upload_dir = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
} }
elseif ($modulepart == 'commande' || $modulepart == 'order') elseif ($modulepart == 'commande' || $modulepart == 'order')
{ {
@ -316,12 +316,12 @@ class Documents extends DolibarrApi
} }
$object = new Commande($this->db); $object = new Commande($this->db);
$result=$object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Order not found'); throw new RestException(404, 'Order not found');
} }
$upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande'); $upload_dir = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande');
} }
elseif ($modulepart == 'shipment' || $modulepart == 'expedition') elseif ($modulepart == 'shipment' || $modulepart == 'expedition')
{ {
@ -332,12 +332,12 @@ class Documents extends DolibarrApi
} }
$object = new Expedition($this->db); $object = new Expedition($this->db);
$result=$object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Shipment not found'); throw new RestException(404, 'Shipment not found');
} }
$upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment'); $upload_dir = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
} }
elseif ($modulepart == 'facture' || $modulepart == 'invoice') elseif ($modulepart == 'facture' || $modulepart == 'invoice')
{ {
@ -348,12 +348,12 @@ class Documents extends DolibarrApi
} }
$object = new Facture($this->db); $object = new Facture($this->db);
$result=$object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Invoice not found'); throw new RestException(404, 'Invoice not found');
} }
$upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); $upload_dir = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice');
} }
elseif ($modulepart == 'produit' || $modulepart == 'product') elseif ($modulepart == 'produit' || $modulepart == 'product')
{ {
@ -364,8 +364,8 @@ class Documents extends DolibarrApi
} }
$object = new Product($this->db); $object = new Product($this->db);
$result=$object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Product not found'); throw new RestException(404, 'Product not found');
} }
@ -380,8 +380,8 @@ class Documents extends DolibarrApi
} }
$object = new ActionComm($this->db); $object = new ActionComm($this->db);
$result=$object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'Event not found'); throw new RestException(404, 'Event not found');
} }
@ -392,9 +392,9 @@ class Documents extends DolibarrApi
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
} }
$filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
if (empty($filearray)) { if (empty($filearray)) {
throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.'); throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->Ref) ? ' or Ref '.$object->ref : '').' does not return any document.');
} }
return $filearray; return $filearray;
@ -447,7 +447,7 @@ class Documents extends DolibarrApi
var_dump($filecontent); var_dump($filecontent);
exit;*/ exit;*/
if(empty($modulepart)) if (empty($modulepart))
{ {
throw new RestException(400, 'Modulepart not provided.'); throw new RestException(400, 'Modulepart not provided.');
} }
@ -467,11 +467,11 @@ class Documents extends DolibarrApi
$entity = DolibarrApiAccess::$user->entity; $entity = DolibarrApiAccess::$user->entity;
if ($ref) if ($ref)
{ {
$tmpreldir=''; $tmpreldir = '';
if ($modulepart == 'facture' || $modulepart == 'invoice') if ($modulepart == 'facture' || $modulepart == 'invoice')
{ {
$modulepart='facture'; $modulepart = 'facture';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($this->db); $object = new Facture($this->db);
@ -491,11 +491,11 @@ class Documents extends DolibarrApi
$task_result = $object->fetch('', $ref); $task_result = $object->fetch('', $ref);
// Fetching the tasks project is required because its out_dir might be a sub-directory of the project // Fetching the tasks project is required because its out_dir might be a sub-directory of the project
if($task_result > 0) if ($task_result > 0)
{ {
$project_result = $object->fetch_projet(); $project_result = $object->fetch_projet();
if($project_result >= 0) if ($project_result >= 0)
{ {
$tmpreldir = dol_sanitizeFileName($object->project->ref).'/'; $tmpreldir = dol_sanitizeFileName($object->project->ref).'/';
} }
@ -516,11 +516,11 @@ class Documents extends DolibarrApi
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
} }
if(is_object($object)) if (is_object($object))
{ {
$result = $object->fetch('', $ref); $result = $object->fetch('', $ref);
if($result == 0) if ($result == 0)
{ {
throw new RestException(404, "Object with ref '".$ref."' was not found."); throw new RestException(404, "Object with ref '".$ref."' was not found.");
} }
@ -530,7 +530,7 @@ class Documents extends DolibarrApi
} }
} }
if (! ($object->id > 0)) if (!($object->id > 0))
{ {
throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found."); throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found.");
} }
@ -538,7 +538,7 @@ class Documents extends DolibarrApi
$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref);
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write'); $tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write');
$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir $upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
if (empty($upload_dir) || $upload_dir == '/') if (empty($upload_dir) || $upload_dir == '/')
{ {
@ -547,12 +547,12 @@ class Documents extends DolibarrApi
} }
else else
{ {
if ($modulepart == 'invoice') $modulepart ='facture'; if ($modulepart == 'invoice') $modulepart = 'facture';
$relativefile = $subdir; $relativefile = $subdir;
$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write'); $tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write');
$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir $upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
if (empty($upload_dir) || $upload_dir == '/') if (empty($upload_dir) || $upload_dir == '/')
{ {
@ -568,8 +568,8 @@ class Documents extends DolibarrApi
throw new RestException(500, 'Error while trying to create directory.'); throw new RestException(500, 'Error while trying to create directory.');
} }
$destfile = $upload_dir . '/' . $original_file; $destfile = $upload_dir.'/'.$original_file;
$destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file; $destfiletmp = DOL_DATA_ROOT.'/admin/temp/'.$original_file;
dol_delete_file($destfiletmp); dol_delete_file($destfiletmp);
//var_dump($original_file);exit; //var_dump($original_file);exit;
@ -577,7 +577,7 @@ class Documents extends DolibarrApi
throw new RestException(401, 'Directory not exists : '.dirname($destfile)); throw new RestException(401, 'Directory not exists : '.dirname($destfile));
} }
if (! $overwriteifexists && dol_is_file($destfile)) if (!$overwriteifexists && dol_is_file($destfile))
{ {
throw new RestException(500, "File with name '".$original_file."' already exists."); throw new RestException(500, "File with name '".$original_file."' already exists.");
} }
@ -595,7 +595,7 @@ class Documents extends DolibarrApi
} }
$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1);
if (! $result) if (!$result)
{ {
throw new RestException(500, "Failed to move file into '".$destfile."'"); throw new RestException(500, "Failed to move file into '".$destfile."'");
} }
@ -629,7 +629,7 @@ class Documents extends DolibarrApi
} }
//--- Finds and returns the document //--- Finds and returns the document
$entity=$conf->entity; $entity = $conf->entity;
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
$accessallowed = $check_access['accessallowed']; $accessallowed = $check_access['accessallowed'];
@ -644,9 +644,9 @@ class Documents extends DolibarrApi
} }
$filename = basename($original_file); $filename = basename($original_file);
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
if (! file_exists($original_file_osencoded)) if (!file_exists($original_file_osencoded))
{ {
dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING);
throw new RestException(404, 'File not found'); throw new RestException(404, 'File not found');

View File

@ -60,7 +60,7 @@ foreach ($object->fields as $key => $val)
if (empty($action) && empty($id) && empty($ref)) $action = 'view'; if (empty($action) && empty($id) && empty($ref)) $action = 'view';
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid; //if ($user->socid > 0) $socid = $user->socid;
//$result = restrictedArea($user, 'asset', $id); //$result = restrictedArea($user, 'asset', $id);

View File

@ -40,7 +40,7 @@ $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'))
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid; //if ($user->socid > 0) $socid = $user->socid;
//$result = restrictedArea($user, 'asset', $id); //$result = restrictedArea($user, 'asset', $id);

View File

@ -46,7 +46,7 @@ $hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules co
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid; //if ($user->socid > 0) $socid = $user->socid;
//$result = restrictedArea($user, 'asset', $id); //$result = restrictedArea($user, 'asset', $id);

View File

@ -391,11 +391,11 @@ if ($action == 'create')
// Other attributes // Other attributes
$parameters = array(); $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; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '<tbody>'; print '<tbody>';
print "</table>\n"; print "</table>\n";
@ -606,7 +606,7 @@ if ($rowid > 0)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';

View File

@ -53,7 +53,7 @@ else
$search_agenda_label=GETPOST('search_agenda_label'); $search_agenda_label=GETPOST('search_agenda_label');
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid; //if ($user->socid > 0) $socid = $user->socid;
//$result = restrictedArea($user, 'bom', $id); //$result = restrictedArea($user, 'bom', $id);

View File

@ -70,16 +70,16 @@ if (empty($action) && empty($id) && empty($ref)) $action = 'view';
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid; //if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); //$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote=$user->rights->bom->write; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php $permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php
$permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$upload_dir = $conf->bom->multidir_output[isset($object->entity)?$object->entity:1]; $upload_dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1];
/* /*
@ -521,29 +521,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
* Lines * Lines
*/ */
if (! empty($object->table_element_line)) if (!empty($object->table_element_line))
{ {
// Show object lines // Show object lines
$result = $object->getLinesArray(); $result = $object->getLinesArray();
print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '#addline' : '#line_' . GETPOST('lineid', 'int')) . '" method="POST"> print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '"> <input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '"> <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id . '"> <input type="hidden" name="id" value="' . $object->id.'">
'; ';
if (! empty($conf->use_javascript_ajax) && $object->status == 0) { if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
} }
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{ {
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
} }
if (! empty($object->lines)) if (!empty($object->lines))
{ {
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
} }
@ -561,7 +561,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
} }
if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{ {
print '</table>'; print '</table>';
} }
@ -613,11 +613,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
{ {
if (is_array($object->lines) && count($object->lines) > 0) if (is_array($object->lines) && count($object->lines) > 0)
{ {
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=validate">' . $langs->trans("Validate") . '</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
} }
else else
{ {
print '<a class="butActionRefused" href="" title="'.$langs->trans("AddAtLeastOneLineFirst").'">' . $langs->trans("Validate") . '</a>'; print '<a class="butActionRefused" href="" title="'.$langs->trans("AddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
} }
} }
} }

View File

@ -41,7 +41,7 @@ $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'))
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid; //if ($user->socid > 0) $socid = $user->socid;
//$result = restrictedArea($user, 'bom', $id); //$result = restrictedArea($user, 'bom', $id);

View File

@ -47,7 +47,7 @@ $hookmanager->initHooks(array('bomnote', 'globalcard')); // Note that conf->hook
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) accessforbidden();
//if ($user->socid > 0) $socid = $user->socid; //if ($user->socid > 0) $socid = $user->socid;
//$result = restrictedArea($user, 'bom', $id); //$result = restrictedArea($user, 'bom', $id);

View File

@ -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'), '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'), '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'), '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), '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_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,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-2, 'position'=>162, 'notnull'=>-1,),

View File

@ -278,7 +278,7 @@ if ($user->rights->categorie->creer)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';

View File

@ -78,16 +78,16 @@ class Categories extends DolibarrApi
*/ */
public function get($id, $include_childs = false) public function get($id, $include_childs = false)
{ {
if (! DolibarrApiAccess::$user->rights->categorie->lire) { if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->category->fetch($id); $result = $this->category->fetch($id);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'category not found'); 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); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@ -126,50 +126,50 @@ class Categories extends DolibarrApi
$obj_ret = array(); $obj_ret = array();
if(! DolibarrApiAccess::$user->rights->categorie->lire) { if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as t"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie as t";
$sql.= ' WHERE t.entity IN ('.getEntity('category').')'; $sql .= ' WHERE t.entity IN ('.getEntity('category').')';
if (!empty($type)) if (!empty($type))
{ {
$sql.= ' AND t.type='.array_search($type, Categories::$TYPES); $sql .= ' AND t.type='.array_search($type, Categories::$TYPES);
} }
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
if (! DolibarrApi::_checkFilters($sqlfilters)) if (!DolibarrApi::_checkFilters($sqlfilters))
{ {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql.= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) if ($page < 0)
{ {
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
} }
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$i=0; $i = 0;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min) while ($i < $min)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$category_static = new Categorie($db); $category_static = new Categorie($db);
if($category_static->fetch($obj->rowid)) { if ($category_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($category_static); $obj_ret[] = $this->_cleanObjectDatas($category_static);
} }
$i++; $i++;
@ -178,7 +178,7 @@ class Categories extends DolibarrApi
else { else {
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror()); 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'); throw new RestException(404, 'No category found');
} }
return $obj_ret; return $obj_ret;
@ -192,14 +192,14 @@ class Categories extends DolibarrApi
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if(! DolibarrApiAccess::$user->rights->categorie->creer) { if (!DolibarrApiAccess::$user->rights->categorie->creer) {
throw new RestException(401); throw new RestException(401);
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
foreach($request_data as $field => $value) { foreach ($request_data as $field => $value) {
$this->category->$field = $value; $this->category->$field = $value;
} }
if ($this->category->create(DolibarrApiAccess::$user) < 0) { if ($this->category->create(DolibarrApiAccess::$user) < 0) {
@ -217,20 +217,20 @@ class Categories extends DolibarrApi
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if(! DolibarrApiAccess::$user->rights->categorie->creer) { if (!DolibarrApiAccess::$user->rights->categorie->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->category->fetch($id); $result = $this->category->fetch($id);
if( ! $result ) { if (!$result) {
throw new RestException(404, 'category not found'); 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); 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; if ($field == 'id') continue;
$this->category->$field = $value; $this->category->$field = $value;
} }
@ -253,19 +253,19 @@ class Categories extends DolibarrApi
*/ */
public function delete($id) public function delete($id)
{ {
if(! DolibarrApiAccess::$user->rights->categorie->supprimer) { if (!DolibarrApiAccess::$user->rights->categorie->supprimer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->category->fetch($id); $result = $this->category->fetch($id);
if( ! $result ) { if (!$result) {
throw new RestException(404, 'category not found'); 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); 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'); throw new RestException(401, 'error when delete category');
} }
@ -306,21 +306,21 @@ class Categories extends DolibarrApi
throw new RestException(401); 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); 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); 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); 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); 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); throw new RestException(401);
} }
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
if( ! is_array($categories)) { if (!is_array($categories)) {
if ($categories == 0) { if ($categories == 0) {
throw new RestException(404, 'No category found for this object'); throw new RestException(404, 'No category found for this object');
} }
@ -347,37 +347,37 @@ class Categories extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
if(! DolibarrApiAccess::$user->rights->categorie->lire) { if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->category->fetch($id); $result = $this->category->fetch($id);
if( ! $result ) { if (!$result) {
throw new RestException(404, 'category not found'); throw new RestException(404, 'category not found');
} }
if ($type === Categorie::TYPE_PRODUCT) { 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); throw new RestException(401);
} }
$object = new Product($this->db); $object = new Product($this->db);
} elseif ($type === Categorie::TYPE_CUSTOMER) { } elseif ($type === Categorie::TYPE_CUSTOMER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) { if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Societe($this->db); $object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_SUPPLIER) { } elseif ($type === Categorie::TYPE_SUPPLIER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) { if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Societe($this->db); $object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) { } elseif ($type === Categorie::TYPE_CONTACT) {
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Contact($this->db); $object = new Contact($this->db);
} elseif ($type === Categorie::TYPE_MEMBER) { } elseif ($type === Categorie::TYPE_MEMBER) {
if(! DolibarrApiAccess::$user->rights->adherent->creer) { if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Adherent($this->db); $object = new Adherent($this->db);
@ -388,7 +388,7 @@ class Categories extends DolibarrApi
if (!empty($object)) { if (!empty($object)) {
$result = $object->fetch($object_id); $result = $object->fetch($object_id);
if ($result > 0) { if ($result > 0) {
$result=$this->category->add_type($object, $type); $result = $this->category->add_type($object, $type);
if ($result < 0) { if ($result < 0) {
if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { 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)); throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
@ -427,37 +427,37 @@ class Categories extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
if(! DolibarrApiAccess::$user->rights->categorie->lire) { if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->category->fetch($id); $result = $this->category->fetch($id);
if( ! $result ) { if (!$result) {
throw new RestException(404, 'category not found'); throw new RestException(404, 'category not found');
} }
if ($type === Categorie::TYPE_PRODUCT) { 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); throw new RestException(401);
} }
$object = new Product($this->db); $object = new Product($this->db);
} elseif ($type === Categorie::TYPE_CUSTOMER) { } elseif ($type === Categorie::TYPE_CUSTOMER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) { if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Societe($this->db); $object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_SUPPLIER) { } elseif ($type === Categorie::TYPE_SUPPLIER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) { if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Societe($this->db); $object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) { } elseif ($type === Categorie::TYPE_CONTACT) {
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Contact($this->db); $object = new Contact($this->db);
} elseif ($type === Categorie::TYPE_MEMBER) { } elseif ($type === Categorie::TYPE_MEMBER) {
if(! DolibarrApiAccess::$user->rights->adherent->creer) { if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Adherent($this->db); $object = new Adherent($this->db);
@ -468,7 +468,7 @@ class Categories extends DolibarrApi
if (!empty($object)) { if (!empty($object)) {
$result = $object->fetch('', $object_ref); $result = $object->fetch('', $object_ref);
if ($result > 0) { if ($result > 0) {
$result=$this->category->add_type($object, $type); $result = $this->category->add_type($object, $type);
if ($result < 0) { if ($result < 0) {
if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') { 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)); throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
@ -507,37 +507,37 @@ class Categories extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
if(! DolibarrApiAccess::$user->rights->categorie->lire) { if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->category->fetch($id); $result = $this->category->fetch($id);
if( ! $result ) { if (!$result) {
throw new RestException(404, 'category not found'); throw new RestException(404, 'category not found');
} }
if ($type === Categorie::TYPE_PRODUCT) { 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); throw new RestException(401);
} }
$object = new Product($this->db); $object = new Product($this->db);
} elseif ($type === Categorie::TYPE_CUSTOMER) { } elseif ($type === Categorie::TYPE_CUSTOMER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) { if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Societe($this->db); $object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_SUPPLIER) { } elseif ($type === Categorie::TYPE_SUPPLIER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) { if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Societe($this->db); $object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) { } elseif ($type === Categorie::TYPE_CONTACT) {
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Contact($this->db); $object = new Contact($this->db);
} elseif ($type === Categorie::TYPE_MEMBER) { } elseif ($type === Categorie::TYPE_MEMBER) {
if(! DolibarrApiAccess::$user->rights->adherent->creer) { if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Adherent($this->db); $object = new Adherent($this->db);
@ -548,7 +548,7 @@ class Categories extends DolibarrApi
if (!empty($object)) { if (!empty($object)) {
$result = $object->fetch((int) $object_id); $result = $object->fetch((int) $object_id);
if ($result > 0) { if ($result > 0) {
$result=$this->category->del_type($object, $type); $result = $this->category->del_type($object, $type);
if ($result < 0) { if ($result < 0) {
throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
} }
@ -585,37 +585,37 @@ class Categories extends DolibarrApi
throw new RestException(401); throw new RestException(401);
} }
if(! DolibarrApiAccess::$user->rights->categorie->lire) { if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->category->fetch($id); $result = $this->category->fetch($id);
if( ! $result ) { if (!$result) {
throw new RestException(404, 'category not found'); throw new RestException(404, 'category not found');
} }
if ($type === Categorie::TYPE_PRODUCT) { 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); throw new RestException(401);
} }
$object = new Product($this->db); $object = new Product($this->db);
} elseif ($type === Categorie::TYPE_CUSTOMER) { } elseif ($type === Categorie::TYPE_CUSTOMER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) { if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Societe($this->db); $object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_SUPPLIER) { } elseif ($type === Categorie::TYPE_SUPPLIER) {
if(! DolibarrApiAccess::$user->rights->societe->creer) { if (!DolibarrApiAccess::$user->rights->societe->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Societe($this->db); $object = new Societe($this->db);
} elseif ($type === Categorie::TYPE_CONTACT) { } elseif ($type === Categorie::TYPE_CONTACT) {
if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Contact($this->db); $object = new Contact($this->db);
} elseif ($type === Categorie::TYPE_MEMBER) { } elseif ($type === Categorie::TYPE_MEMBER) {
if(! DolibarrApiAccess::$user->rights->adherent->creer) { if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401); throw new RestException(401);
} }
$object = new Adherent($this->db); $object = new Adherent($this->db);
@ -626,7 +626,7 @@ class Categories extends DolibarrApi
if (!empty($object)) { if (!empty($object)) {
$result = $object->fetch('', (string) $object_ref); $result = $object->fetch('', (string) $object_ref);
if ($result > 0) { if ($result > 0) {
$result=$this->category->del_type($object, $type); $result = $this->category->del_type($object, $type);
if ($result < 0) { if ($result < 0) {
throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors)); throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
} }
@ -736,7 +736,7 @@ class Categories extends DolibarrApi
{ {
dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG); dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG);
if (! DolibarrApiAccess::$user->rights->categorie->lire) { if (!DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401); throw new RestException(401);
} }
@ -746,11 +746,11 @@ class Categories extends DolibarrApi
} }
$result = $this->category->fetch($id); $result = $this->category->fetch($id);
if (! $result) { if (!$result) {
throw new RestException(404, 'category not found'); 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); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }

View File

@ -781,18 +781,19 @@ class Categorie extends CommonObject
$objs = array(); $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 = "SELECT c.fk_".$this->MAP_CAT_FK[$type];
$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c"; $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 .= ", ".MAIN_DB_PREFIX.$this->MAP_OBJ_TABLE[$type]." as o";
$sql .= " WHERE o.entity IN (" . getEntity($obj->element).")"; $sql .= " WHERE o.entity IN (".getEntity($obj->element).")";
$sql .= " AND c.fk_categorie = ".$this->id; $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 // Protection for external users
if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) 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); if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset);
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
@ -929,7 +930,7 @@ class Categorie extends CommonObject
$categories[$i]['description'] = $category_static->description; $categories[$i]['description'] = $category_static->description;
$categories[$i]['color'] = $category_static->color; $categories[$i]['color'] = $category_static->color;
$categories[$i]['socid'] = $category_static->socid; $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]['visible'] = $category_static->visible;
$categories[$i]['type'] = $category_static->type; $categories[$i]['type'] = $category_static->type;
$categories[$i]['entity'] = $category_static->entity; $categories[$i]['entity'] = $category_static->entity;
@ -1569,7 +1570,7 @@ class Categorie extends CommonObject
$sql .= " AND rowid = '".$id."'"; $sql .= " AND rowid = '".$id."'";
} }
$res = $this->db->query($sql); $res = $this->db->query($sql);
if ($res) if ($res)
{ {
while ($rec = $this->db->fetch_array($res)) while ($rec = $this->db->fetch_array($res))

View File

@ -180,7 +180,7 @@ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object,
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';

View File

@ -1115,7 +1115,7 @@ if ($action == 'create')
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';
@ -1437,7 +1437,7 @@ if ($id > 0)
// related contact // related contact
print '<tr><td>'.$langs->trans("ActionOnContact").'</td><td>'; print '<tr><td>'.$langs->trans("ActionOnContact").'</td><td>';
print '<div class="maxwidth200onsmartphone">'; print '<div class="maxwidth200onsmartphone">';
print $form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 0, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); print $form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid');
print '</div>'; print '</div>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -1519,7 +1519,7 @@ if ($id > 0)
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';

View File

@ -1242,7 +1242,7 @@ else
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';

View File

@ -294,7 +294,6 @@ class FormAdvTargetEmailing extends Form
$options_array = array(); $options_array = array();
$sql = "SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX."c_civility"; $sql = "SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX."c_civility";
$sql .= " WHERE active = 1"; $sql .= " WHERE active = 1";
@ -312,7 +311,6 @@ class FormAdvTargetEmailing extends Form
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : '')); $label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : ''));
$options_array[$obj->code] = $label; $options_array[$obj->code] = $label;
$i++; $i++;

View File

@ -271,6 +271,12 @@ if ($result)
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
if (empty($num)) {
$colspan = 6;
if (!$filteremail) $colspan++;
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '</form>'; print '</form>';

View File

@ -68,7 +68,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
} }
print '</td>'; print '</td>';
print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>'; print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
print '<td class="linkedcol-action right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>'; print '<td class="linkedcol-action right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
print "</tr>\n"; print "</tr>\n";
} }
if (count($linkedObjectBlock) > 1) if (count($linkedObjectBlock) > 1)

View File

@ -736,35 +736,34 @@ if ($socid > 0)
// Discount linked to invoice lines // Discount linked to invoice lines
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
$sql .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
$sql .= " rc.fk_facture_source,"; $sql .= " rc.fk_facture_source,";
$sql .= " u.login, u.rowid as user_id,"; $sql .= " u.login, u.rowid as user_id,";
$sql .= " f.rowid, f.ref,"; $sql .= " f.rowid as invoiceid, f.ref,";
$sql .= " fa.ref as ref, fa.type as type"; $sql .= " fa.ref as invoice_source_ref, fa.type as type";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " , ".MAIN_DB_PREFIX."facturedet as fc"; $sql .= " , ".MAIN_DB_PREFIX."facturedet as fc";
$sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
$sql .= " WHERE rc.fk_soc =".$object->id; $sql .= " WHERE rc.fk_soc =". $object->id;
$sql .= " AND rc.fk_facture_line = fc.rowid"; $sql .= " AND rc.fk_facture_line = fc.rowid";
$sql .= " AND fc.fk_facture = f.rowid"; $sql .= " AND fc.fk_facture = f.rowid";
$sql .= " AND rc.fk_user = u.rowid"; $sql .= " AND rc.fk_user = u.rowid";
$sql .= " AND rc.discount_type = 0"; // Eliminate supplier discounts $sql .= " AND rc.discount_type = 0"; // Eliminate supplier discounts
$sql .= " ORDER BY dc DESC"; $sql .= " ORDER BY dc DESC";
//$sql.= " UNION "; //$sql.= " UNION ";
// Remises liees a factures // Discount linked to invoices
$sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
$sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; $sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
$sql2 .= " rc.fk_facture_source,"; $sql2 .= " rc.fk_facture_source,";
$sql2 .= " u.login, u.rowid as user_id,"; $sql2 .= " u.login, u.rowid as user_id,";
$sql2 .= " f.rowid, f.ref,"; $sql2 .= " f.rowid as invoiceid, f.ref,";
$sql2 .= " fa.ref as ref, fa.type as type"; $sql2 .= " fa.ref as invoice_source_ref, fa.type as type";
$sql2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql2 .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql2 .= " , ".MAIN_DB_PREFIX."user as u"; $sql2 .= " , ".MAIN_DB_PREFIX."user as u";
$sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
$sql2 .= " WHERE rc.fk_soc =".$object->id; $sql2 .= " WHERE rc.fk_soc =". $object->id;
$sql2 .= " AND rc.fk_facture = f.rowid"; $sql2 .= " AND rc.fk_facture = f.rowid";
$sql2 .= " AND rc.fk_user = u.rowid"; $sql2 .= " AND rc.fk_user = u.rowid";
$sql2 .= " AND rc.discount_type = 0"; // Eliminate supplier discounts $sql2 .= " AND rc.discount_type = 0"; // Eliminate supplier discounts
@ -833,7 +832,7 @@ if ($socid > 0)
{ {
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref; $facturestatic->ref = $obj->invoice_source_ref;
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>'; print '</td>';
@ -842,7 +841,7 @@ if ($socid > 0)
{ {
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref; $facturestatic->ref = $obj->invoice_source_ref;
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>'; print '</td>';
@ -851,7 +850,7 @@ if ($socid > 0)
{ {
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturestatic->id = $obj->fk_facture_source; $facturestatic->id = $obj->fk_facture_source;
$facturestatic->ref = $obj->ref; $facturestatic->ref = $obj->invoice_source_ref;
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1);
print '</td>'; print '</td>';
@ -862,7 +861,12 @@ if ($socid > 0)
print $obj->description; print $obj->description;
print '</td>'; print '</td>';
} }
print '<td class="left nowrap"><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.'</a></td>'; print '<td class="left nowrap">';
if ($obj->invoiceid)
{
print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->invoiceid.'">'.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.'</a>';
}
print '</td>';
print '<td class="right">'.price($obj->amount_ht).'</td>'; print '<td class="right">'.price($obj->amount_ht).'</td>';
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
@ -909,32 +913,32 @@ if ($socid > 0)
$sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,";
$sql .= " rc.fk_invoice_supplier_source,"; $sql .= " rc.fk_invoice_supplier_source,";
$sql .= " u.login, u.rowid as user_id,"; $sql .= " u.login, u.rowid as user_id,";
$sql .= " f.rowid, f.ref as ref,"; $sql .= " f.rowid as invoiceid, f.ref as ref,";
$sql .= " fa.ref, fa.type as type"; $sql .= " fa.ref as invoice_source_ref, fa.type as type";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc"; $sql .= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc";
$sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
$sql .= " WHERE rc.fk_soc =".$object->id; $sql .= " WHERE rc.fk_soc =". $object->id;
$sql .= " AND rc.fk_invoice_supplier_line = fc.rowid"; $sql .= " AND rc.fk_invoice_supplier_line = fc.rowid";
$sql .= " AND fc.fk_facture_fourn = f.rowid"; $sql .= " AND fc.fk_facture_fourn = f.rowid";
$sql .= " AND rc.fk_user = u.rowid"; $sql .= " AND rc.fk_user = u.rowid";
$sql .= " AND rc.discount_type = 1"; // Eliminate customer discounts $sql .= " AND rc.discount_type = 1"; // Eliminate customer discounts
$sql .= " ORDER BY dc DESC"; $sql .= " ORDER BY dc DESC";
//$sql.= " UNION "; //$sql.= " UNION ";
// Remises liees a factures // Discount linked to invoices
$sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
$sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,";
$sql2 .= " rc.fk_invoice_supplier_source,"; $sql2 .= " rc.fk_invoice_supplier_source,";
$sql2 .= " u.login, u.rowid as user_id,"; $sql2 .= " u.login, u.rowid as user_id,";
$sql2 .= " f.rowid, f.ref as ref,"; $sql2 .= " f.rowid as invoiceid, f.ref as ref,";
$sql2 .= " fa.ref, fa.type as type"; $sql2 .= " fa.ref as invoice_source_ref, fa.type as type";
$sql2 .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql2 .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql2 .= " , ".MAIN_DB_PREFIX."user as u"; $sql2 .= " , ".MAIN_DB_PREFIX."user as u";
$sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
$sql2 .= " WHERE rc.fk_soc =".$object->id; $sql2 .= " WHERE rc.fk_soc =". $object->id;
$sql2 .= " AND rc.fk_invoice_supplier = f.rowid"; $sql2 .= " AND rc.fk_invoice_supplier = f.rowid";
$sql2 .= " AND rc.fk_user = u.rowid"; $sql2 .= " AND rc.fk_user = u.rowid";
$sql2 .= " AND rc.discount_type = 1"; // Eliminate customer discounts $sql2 .= " AND rc.discount_type = 1"; // Eliminate customer discounts
@ -1003,7 +1007,7 @@ if ($socid > 0)
{ {
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref; $facturefournstatic->ref = $obj->invoice_source_ref;
$facturefournstatic->type = $obj->type; $facturefournstatic->type = $obj->type;
print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>'; print '</td>';
@ -1012,7 +1016,7 @@ if ($socid > 0)
{ {
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref; $facturefournstatic->ref = $obj->invoice_source_ref;
$facturefournstatic->type = $obj->type; $facturefournstatic->type = $obj->type;
print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>'; print '</td>';
@ -1021,7 +1025,7 @@ if ($socid > 0)
{ {
print '<td class="minwidth100">'; print '<td class="minwidth100">';
$facturefournstatic->id = $obj->fk_invoice_supplier_source; $facturefournstatic->id = $obj->fk_invoice_supplier_source;
$facturefournstatic->ref = $obj->ref; $facturefournstatic->ref = $obj->invoice_source_ref;
$facturefournstatic->type = $obj->type; $facturefournstatic->type = $obj->type;
print preg_replace('/\(EXCESS PAID\)/', $langs->trans("Invoice"), $obj->description).' '.$facturefournstatic->getNomURl(1); print preg_replace('/\(EXCESS PAID\)/', $langs->trans("Invoice"), $obj->description).' '.$facturefournstatic->getNomURl(1);
print '</td>'; print '</td>';
@ -1032,7 +1036,11 @@ if ($socid > 0)
print $obj->description; print $obj->description;
print '</td>'; print '</td>';
} }
print '<td class="left nowrap"><a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.'</a></td>'; print '<td class="left nowrap">';
if ($obj->invoiceid) {
print '<a href="'.DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$obj->invoiceid.'">'.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.'</a>';
}
print '</td>';
print '<td class="right">'.price($obj->amount_ht).'</td>'; print '<td class="right">'.price($obj->amount_ht).'</td>';
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {

View File

@ -1771,7 +1771,7 @@ if ($action == 'create' && $usercancreate)
} }
}; };
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
// Template to use by default // Template to use by default

View File

@ -76,7 +76,7 @@ class Orders extends DolibarrApi
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET byRef/{ref} * @url GET ref/{ref}
* *
* @throws RestException * @throws RestException
*/ */
@ -94,7 +94,7 @@ class Orders extends DolibarrApi
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET byRefExt/{ref_ext} * @url GET ref_ext/{ref_ext}
* *
* @throws RestException * @throws RestException
*/ */

View File

@ -977,35 +977,22 @@ class Commande extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id; $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
if ($this->id) $this->ref = $initialref;
if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
{ {
$this->ref = $initialref; $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
}
if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects // Add object linked
if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects))
{
foreach ($this->linked_objects as $origin => $tmp_origin_id)
{ {
$this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
}
// Add object linked
if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects))
{
foreach ($this->linked_objects as $origin => $tmp_origin_id)
{ {
if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) foreach ($tmp_origin_id as $origin_id)
{ {
foreach ($tmp_origin_id as $origin_id)
{
$ret = $this->add_object_linked($origin, $origin_id);
if (!$ret)
{
$this->error = $this->db->lasterror();
$error++;
}
}
}
else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
{
$origin_id = $tmp_origin_id;
$ret = $this->add_object_linked($origin, $origin_id); $ret = $this->add_object_linked($origin, $origin_id);
if (!$ret) if (!$ret)
{ {
@ -1014,44 +1001,54 @@ class Commande extends CommonOrder
} }
} }
} }
else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
{
$origin_id = $tmp_origin_id;
$ret = $this->add_object_linked($origin, $origin_id);
if (!$ret)
{
$this->error = $this->db->lasterror();
$error++;
}
}
} }
}
if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object
{
$originforcontact = $this->origin;
$originidforcontact = $this->origin_id;
if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
{ {
$originforcontact = $this->origin; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
$originidforcontact = $this->origin_id; $exp = new Expedition($this->db);
if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order $exp->fetch($this->origin_id);
$exp->fetchObjectLinked();
if (count($exp->linkedObjectsIds['commande']) > 0)
{ {
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
$exp = new Expedition($this->db);
$exp->fetch($this->origin_id);
$exp->fetchObjectLinked();
if (count($exp->linkedObjectsIds['commande']) > 0)
{ {
foreach ($exp->linkedObjectsIds['commande'] as $key => $value) $originforcontact = 'commande';
{ if (is_object($value)) $originidforcontact = $value->id;
$originforcontact = 'commande'; else $originidforcontact = $value;
if (is_object($value)) $originidforcontact = $value->id; break; // We take first one
else $originidforcontact = $value;
break; // We take first one
}
} }
} }
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
$resqlcontact = $this->db->query($sqlcontact);
if ($resqlcontact)
{
while ($objcontact = $this->db->fetch_object($resqlcontact))
{
//print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n";
$this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object
}
}
else dol_print_error($resqlcontact);
} }
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
$resqlcontact = $this->db->query($sqlcontact);
if ($resqlcontact)
{
while ($objcontact = $this->db->fetch_object($resqlcontact))
{
//print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n";
$this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object
}
}
else dol_print_error($resqlcontact);
} }
if (!$error) if (!$error)

View File

@ -80,7 +80,7 @@ $search_total_ttc = GETPOST('search_total_ttc', 'alpha');
$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $search_categ_cus = trim(GETPOST("search_categ_cus", 'int'));
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
$billed = GETPOST('billed', 'int'); $billed = GETPOST('billed', 'int');
$viewstatut = GETPOST('viewstatut'); $viewstatut = GETPOST('viewstatut', 'int');
$search_btn = GETPOST('button_search', 'alpha'); $search_btn = GETPOST('button_search', 'alpha');
$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha');
$search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_project_ref = GETPOST('search_project_ref', 'alpha');

View File

@ -18,7 +18,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf)) { if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -36,14 +36,14 @@ $langs->load("orders");
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
$total=0; $total = 0;
$ilink=0; $ilink = 0;
foreach($linkedObjectBlock as $key => $objectlink) foreach ($linkedObjectBlock as $key => $objectlink)
{ {
$ilink++; $ilink++;
$trclass='oddeven'; $trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
echo '<tr class="'.$trclass.'" >'; echo '<tr class="'.$trclass.'" >';
echo '<td class="linkedcol-element" >'.$langs->trans("CustomerOrder"); echo '<td class="linkedcol-element" >'.$langs->trans("CustomerOrder");
if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
@ -62,14 +62,14 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>'; echo '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
echo '<td class="linkedcol-action right">'; echo '<td class="linkedcol-action right">';
// For now, shipments must stay linked to order, so link is not deletable // For now, shipments must stay linked to order, so link is not deletable
if($object->element != 'shipping') { if ($object->element != 'shipping') {
echo '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a>'; echo '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a>';
} }
echo '</td>'; echo '</td>';
echo "</tr>\n"; echo "</tr>\n";
} }
if (count($linkedObjectBlock) > 1) { if (count($linkedObjectBlock) > 1) {
echo '<tr class="liste_total '.(empty($noMoreLinkedObjectBlockAfter)?'liste_sub_total':'').'">'; echo '<tr class="liste_total '.(empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : '').'">';
echo '<td>'.$langs->trans("Total").'</td>'; echo '<td>'.$langs->trans("Total").'</td>';
echo '<td></td>'; echo '<td></td>';
echo '<td class="center"></td>'; echo '<td class="center"></td>';

View File

@ -698,10 +698,7 @@ if ($resql)
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Numero").'</td>'; print '<td>'.$langs->trans("Numero").'</td>';
//if (! $search_account > 0) print '<td class=right>'.$langs->trans("BankAccount").'</td>';
//{
print '<td class=right>'.$langs->trans("BankAccount").'</td>';
//}
print '<td class=right>'.$langs->trans("Debit").'</td>'; print '<td class=right>'.$langs->trans("Debit").'</td>';
print '<td class=right>'.$langs->trans("Credit").'</td>'; print '<td class=right>'.$langs->trans("Credit").'</td>';
/*if (! empty($conf->accounting->enabled)) /*if (! empty($conf->accounting->enabled))
@ -824,19 +821,21 @@ if ($resql)
$moreforfilter = ''; $moreforfilter = '';
$moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('DateOperationShort').' : '; $moreforfilter .= $langs->trans('DateOperationShort').' :';
$moreforfilter .= '<div class="nowrap'.($conf->browser->layout == 'phone' ? ' centpercent' : '').' inline-block">'.$langs->trans('From').' '; $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
$moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('From').' ';
$moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0).'</div>'; $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0).'</div>';
//$moreforfilter .= ' - '; //$moreforfilter .= ' - ';
$moreforfilter .= '<div class="nowrap'.($conf->browser->layout == 'phone' ? ' centpercent' : '').' inline-block">'.$langs->trans('to').' '.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'</div>'; $moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('to').' '.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'</div>';
$moreforfilter .= '</div>'; $moreforfilter .= '</div>';
$moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('DateValueShort').' : '; $moreforfilter .= $langs->trans('DateValueShort').' : ';
$moreforfilter .= '<div class="nowrap'.($conf->browser->layout == 'phone' ? ' centpercent' : '').' inline-block">'.$langs->trans('From').' '; $moreforfilter .= ($conf->browser->layout == 'phone' ? '<br>' : ' ');
$moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('From').' ';
$moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0).'</div>'; $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0).'</div>';
//$moreforfilter .= ' - '; //$moreforfilter .= ' - ';
$moreforfilter .= '<div class="nowrap'.($conf->browser->layout == 'phone' ? ' centpercent' : '').' inline-block">'.$langs->trans('to').' '.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'</div>'; $moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('to').' '.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'</div>';
$moreforfilter .= '</div>'; $moreforfilter .= '</div>';
if (!empty($conf->categorie->enabled)) if (!empty($conf->categorie->enabled))

View File

@ -443,7 +443,7 @@ if ($action == 'create')
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';
@ -945,7 +945,7 @@ else
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</table>'; print '</table>';

View File

@ -283,7 +283,7 @@ if ($action == 'create')
// Label // Label
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>'; print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>';
print '<input name="label" id="label" class="minwidth300" value="'.($label ? $label : $langs->trans("VariousPayment")).'">'; print '<input name="label" id="label" class="minwidth300 maxwidth150onsmartphone" value="'.($label ? $label : $langs->trans("VariousPayment")).'">';
print '</td></tr>'; print '</td></tr>';
// Sens // Sens
@ -296,7 +296,7 @@ if ($action == 'create')
// Amount // Amount
print '<tr><td>'; print '<tr><td>';
print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>'; print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
print '<input name="amount" id="amount" class="minwidth100" value="'.$amount.'">'; print '<input name="amount" id="amount" class="minwidth100 maxwidth150onsmartphone" value="'.$amount.'">';
print '</td></tr>'; print '</td></tr>';
// Bank // Bank
@ -321,7 +321,7 @@ if ($action == 'create')
print '<tr><td><label for="num_payment">'.$langs->trans('Numero'); print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</label></td>'; print '</label></td>';
print '<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n"; print '<td><input name="num_payment" class="maxwidth150onsmartphone" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
} }
// Project // Project
@ -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 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
print '</td></tr>';
// Category // Category
if (is_array($options) && count($options) && $conf->categorie->enabled) if (is_array($options) && count($options) && $conf->categorie->enabled)
{ {
@ -360,13 +358,13 @@ if ($action == 'create')
// TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("AccountAccounting").'</td>'; print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("AccountAccounting").'</td>';
print '<td>'; print '<td>';
print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1);
print '</td></tr>'; print '</td></tr>';
} }
else // For external software else // For external software
{ {
print '<tr><td class="titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code" value="'.$accountancy_code.'">'; print '<td><input class="minwidth100 maxwidthonsmartphone" name="accountancy_code" value="'.$accountancy_code.'">';
print '</td></tr>'; print '</td></tr>';
} }
@ -381,14 +379,14 @@ if ($action == 'create')
} }
else else
{ {
print '<input type="text" class="maxwidth200" name="subledger_account" value="'.$subledger_account.'">'; print '<input type="text" class="maxwidth200 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
} }
print '</td></tr>'; print '</td></tr>';
} }
else // For external software else // For external software
{ {
print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>'; print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="subledger_account" value="'.$subledger_account.'">'; print '<td><input class="minwidth100 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -986,7 +986,7 @@ if (empty($reshook))
$object->entity = $originentity; $object->entity = $originentity;
} }
$object->socid = GETPOST('socid', 'int'); $object->socid = GETPOST('socid', 'int');
$object->number = $_POST['ref']; $object->ref = $_POST['ref'];
$object->date = $dateinvoice; $object->date = $dateinvoice;
$object->date_pointoftax = $date_pointoftax; $object->date_pointoftax = $date_pointoftax;
$object->note_public = trim(GETPOST('note_public', 'none')); $object->note_public = trim(GETPOST('note_public', 'none'));
@ -1166,7 +1166,7 @@ if (empty($reshook))
{ {
$object->socid = GETPOST('socid', 'int'); $object->socid = GETPOST('socid', 'int');
$object->type = $_POST['type']; $object->type = $_POST['type'];
$object->number = $_POST['ref']; $object->ref = $_POST['ref'];
$object->date = $dateinvoice; $object->date = $dateinvoice;
$object->date_pointoftax = $date_pointoftax; $object->date_pointoftax = $date_pointoftax;
$object->note_public = trim(GETPOST('note_public', 'none')); $object->note_public = trim(GETPOST('note_public', 'none'));
@ -1216,7 +1216,7 @@ if (empty($reshook))
// Si facture standard // Si facture standard
$object->socid = GETPOST('socid', 'int'); $object->socid = GETPOST('socid', 'int');
$object->type = GETPOST('type'); $object->type = GETPOST('type');
$object->number = $_POST['ref']; $object->ref = $_POST['ref'];
$object->date = $dateinvoice; $object->date = $dateinvoice;
$object->date_pointoftax = $date_pointoftax; $object->date_pointoftax = $date_pointoftax;
$object->note_public = trim(GETPOST('note_public', 'none')); $object->note_public = trim(GETPOST('note_public', 'none'));
@ -3282,11 +3282,11 @@ if ($action == 'create')
} }
// Other attributes // 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 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) { if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
// Template to use by default // Template to use by default

View File

@ -980,7 +980,7 @@ class Facture extends CommonInvoice
} }
elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION))
{ {
$this->fetchObjectLinked('', '', $facture->id, 'facture'); $this->fetchObjectLinked('', '', $this->id, 'facture');
foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object)
{ {

View File

@ -86,7 +86,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
} }
print '</td>'; print '</td>';
print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>'; print '<td class="linkedcol-statut right">'.$objectlink->getLibStatut(3).'</td>';
print '<td class="linkedcol-action right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>'; print '<td class="linkedcol-action right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
print "</tr>\n"; print "</tr>\n";
} }
if (count($linkedObjectBlock) > 1) if (count($linkedObjectBlock) > 1)

View File

@ -57,7 +57,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
} }
?></td> ?></td>
<td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td> <td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="linkedcol-action right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> <td class="linkedcol-action right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr> </tr>
<?php <?php
} }

File diff suppressed because it is too large Load Diff

View File

@ -622,9 +622,14 @@ else
// Name // Name
print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</label></td>'; print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</label></td>';
print '<td><input name="lastname" id="lastname" type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(GETPOST("lastname", 'alpha') ?GETPOST("lastname", 'alpha') : $object->lastname).'" autofocus="autofocus"></td>'; print '<td colspan="3"><input name="lastname" id="lastname" type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(GETPOST("lastname", 'alpha') ?GETPOST("lastname", 'alpha') : $object->lastname).'" autofocus="autofocus"></td>';
print '<td><label for="firstname">'.$langs->trans("Firstname").'</label></td>'; print '</tr>';
print '<td><input name="firstname" id="firstname"type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(GETPOST("firstname", 'alpha') ?GETPOST("firstname", 'alpha') : $object->firstname).'"></td></tr>';
print '<tr>';
print '<td><label for="firstname">';
print $form->textwithpicto($langs->trans("Firstname"), $langs->trans("KeepEmptyIfGenericAddress")).'</label></td>';
print '<td colspan="3"><input name="firstname" id="firstname"type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(GETPOST("firstname", 'alpha') ?GETPOST("firstname", 'alpha') : $object->firstname).'"></td>';
print '</tr>';
// Company // Company
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
@ -715,19 +720,24 @@ else
// Phone / Fax // Phone / Fax
print '<tr><td>'.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).'</td>'; print '<tr><td>'.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).'</td>';
print '<td><input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" value="'.(GETPOSTISSET('phone_pro') ?GETPOST('phone_pro', 'alpha') : $object->phone_pro).'"></td>'; print '<td><input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" value="'.(GETPOSTISSET('phone_pro') ?GETPOST('phone_pro', 'alpha') : $object->phone_pro).'"></td>';
if ($conf->browser->layout == 'phone') print '</tr><tr>';
print '<td>'.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).'</td>'; print '<td>'.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).'</td>';
print '<td><input type="text" name="phone_perso" id="phone_perso" class="maxwidth200" value="'.(GETPOSTISSET('phone_perso') ?GETPOST('phone_perso', 'alpha') : $object->phone_perso).'"></td></tr>'; print '<td><input type="text" name="phone_perso" id="phone_perso" class="maxwidth200" value="'.(GETPOSTISSET('phone_perso') ?GETPOST('phone_perso', 'alpha') : $object->phone_perso).'"></td></tr>';
print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).'</td>'; print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).'</td>';
print '<td><input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" value="'.(GETPOSTISSET('phone_mobile') ?GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td>'; print '<td><input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" value="'.(GETPOSTISSET('phone_mobile') ?GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td>';
if ($conf->browser->layout == 'phone') print '</tr><tr>';
print '<td>'.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td>'; print '<td>'.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td>';
print '<td><input type="text" name="fax" id="fax" class="maxwidth200" value="'.(GETPOSTISSET('fax') ?GETPOST('fax', 'alpha') : $object->fax).'"></td></tr>'; print '<td><input type="text" name="fax" id="fax" class="maxwidth200" value="'.(GETPOSTISSET('fax') ?GETPOST('fax', 'alpha') : $object->fax).'"></td>';
print '</tr>';
if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party
// Email // Email
print '<tr><td>'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').'</td>'; print '<tr><td>'.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').'</td>';
print '<td><input type="text" name="email" id="email" value="'.(GETPOSTISSET('email') ?GETPOST('email', 'alpha') : $object->email).'"></td>'; print '<td><input type="text" name="email" id="email" value="'.(GETPOSTISSET('email') ?GETPOST('email', 'alpha') : $object->email).'"></td>';
print '</tr>';
if (!empty($conf->mailing->enabled)) if (!empty($conf->mailing->enabled))
{ {
$noemail = ''; $noemail = '';
@ -743,12 +753,10 @@ else
} }
} }
print '<tr>';
print '<td><label for="no_email">'.$langs->trans("No_Email").'</label></td>'; print '<td><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
print '<td>'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'</td>'; print '<td>'.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).'</td>';
} print '</tr>';
else
{
print '<td colspan="2">&nbsp;</td>';
} }
print '</tr>'; print '</tr>';
@ -829,7 +837,7 @@ else
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print "</table><br>"; print "</table><br>";
@ -842,7 +850,7 @@ else
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Date To Birth // Date To Birth
print '<tr><td width="20%"><label for="birthday">'.$langs->trans("DateToBirth").'</label></td><td width="30%">'; print '<tr><td><label for="birthday">'.$langs->trans("DateToBirth").'</label></td><td>';
$form = new Form($db); $form = new Form($db);
if ($object->birthday) if ($object->birthday)
{ {
@ -854,15 +862,16 @@ else
} }
print '</td>'; print '</td>';
print '<td colspan="2"><label for="birthday_alert">'.$langs->trans("Alert").'</label>: '; print '<td><label for="birthday_alert">'.$langs->trans("Alert").'</label>: ';
if ($object->birthday_alert) if ($object->birthday_alert)
{ {
print '<input type="checkbox" name="birthday_alert" id="birthday_alert" checked></td>'; print '<input type="checkbox" name="birthday_alert" id="birthday_alert" checked>';
} }
else else
{ {
print '<input type="checkbox" name="birthday_alert" id="birthday_alert"></td>'; print '<input type="checkbox" name="birthday_alert" id="birthday_alert">';
} }
print '</td>';
print '</tr>'; print '</tr>';
print "</table>"; print "</table>";
@ -971,7 +980,7 @@ else
// Civility // Civility
print '<tr><td><label for="civility_code">'.$langs->trans("UserTitle").'</label></td><td colspan="3">'; print '<tr><td><label for="civility_code">'.$langs->trans("UserTitle").'</label></td><td colspan="3">';
print $formcompany->select_civility(GETPOSTISSET("civility_code") ?GETPOST("civility", "aZ09") : $object->civility_code, 'civility_code'); print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", "aZ09") : $object->civility_code, 'civility_code');
print '</td></tr>'; print '</td></tr>';
print '<tr><td><label for="title">'.$langs->trans("PostOrFunction").'</label></td>'; print '<tr><td><label for="title">'.$langs->trans("PostOrFunction").'</label></td>';
@ -1162,12 +1171,12 @@ else
} }
// Other attributes // 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 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
$object->load_ref_elements(); $object->load_ref_elements();

View File

@ -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/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.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->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->projet->enabled)) { if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; 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/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 // 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'); $action = GETPOST('action', 'alpha');
$confirm=GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref=GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$origin=GETPOST('origin', 'alpha'); $origin = GETPOST('origin', 'alpha');
$originid=GETPOST('originid', 'int'); $originid = GETPOST('originid', 'int');
$datecontrat=''; $datecontrat = '';
$usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); $usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0);
// Security check // Security check
if ($user->socid) $socid=$user->socid; if ($user->socid) $socid = $user->socid;
$result=restrictedArea($user, 'contrat', $id); $result = restrictedArea($user, 'contrat', $id);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // 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); $object = new Contrat($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// Load object // Load object
if ($id > 0 || ! empty($ref) && $action!='add') { if ($id > 0 || !empty($ref) && $action != 'add') {
$ret = $object->fetch($id, $ref); $ret = $object->fetch($id, $ref);
if ($ret > 0) if ($ret > 0)
$ret = $object->fetch_thirdparty(); $ret = $object->fetch_thirdparty();
@ -444,8 +444,8 @@ if (empty($reshook))
$error++; $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_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_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) if (!empty($date_start) && !empty($date_end) && $date_start > $date_end)
{ {
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
@ -528,46 +528,46 @@ if (empty($reshook))
{ {
if ($price_base_type != 'HT') if ($price_base_type != 'HT')
{ {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat/100)), 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} }
else else
{ {
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
} }
} }
$desc=$prod->description; $desc = $prod->description;
$desc=dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
$fk_unit = $prod->fk_unit; $fk_unit = $prod->fk_unit;
} }
else else
{ {
$pu_ht=GETPOST('price_ht'); $pu_ht = GETPOST('price_ht');
$price_base_type = '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_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; $tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0;
$desc=$product_desc; $desc = $product_desc;
$fk_unit= GETPOST('units', 'alpha'); $fk_unit = GETPOST('units', 'alpha');
} }
$localtax1_tx=get_localtax($tva_tx, 1, $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); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
// ajout prix achat // ajout prix achat
$fk_fournprice = $_POST['fournprice']; $fk_fournprice = $_POST['fournprice'];
if ( ! empty($_POST['buying_price']) ) if (!empty($_POST['buying_price']))
$pa_ht = $_POST['buying_price']; $pa_ht = $_POST['buying_price'];
else else
$pa_ht = null; $pa_ht = null;
$info_bits=0; $info_bits = 0;
if ($tva_npr) $info_bits |= 0x01; if ($tva_npr) $info_bits |= 0x01;
if (((! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) 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)))) || 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)); $object->error = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
$result = -1 ; $result = -1;
} }
else else
{ {
@ -1239,39 +1239,39 @@ if ($action == 'create')
print "</td></tr>"; print "</td></tr>";
// Project // Project
if (! empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
$langs->load('projects'); $langs->load('projects');
$formproject=new FormProjets($db); $formproject = new FormProjets($db);
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';
$formproject->select_projects(($soc->id>0?$soc->id:-1), $projectid, "projectid", 0, 0, 1, 1); $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, "projectid", 0, 0, 1, 1);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">' . $langs->trans("AddProject") . '</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
print "</td></tr>"; print "</td></tr>";
} }
print '<tr><td>'.$langs->trans("NotePublic").'</td><td class="tdtop">'; print '<tr><td>'.$langs->trans("NotePublic").'</td><td class="tdtop">';
$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 $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
if (empty($user->socid)) if (empty($user->socid))
{ {
print '<tr><td>'.$langs->trans("NotePrivate").'</td><td class="tdtop">'; print '<tr><td>'.$langs->trans("NotePrivate").'</td><td class="tdtop">';
$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 $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
} }
// Other attributes // Other attributes
$parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols'=>3); $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 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Other attributes // Other attributes
if (empty($reshook)) { if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print "</table>\n"; print "</table>\n";
@ -1389,62 +1389,62 @@ else
// Contract card // Contract card
$linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref=''; $morehtmlref = '';
if (! empty($modCodeContract->code_auto)) { if (!empty($modCodeContract->code_auto)) {
$morehtmlref.=$object->ref; $morehtmlref .= $object->ref;
} else { } else {
$morehtmlref.=$form->editfieldkey("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 3); $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->editfieldval("", 'ref', $object->ref, $object, $user->rights->contrat->creer, 'string', '', 0, 2);
} }
$morehtmlref.='<div class="refidno">'; $morehtmlref .= '<div class="refidno">';
// Ref customer // Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1); $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->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
// Ref supplier // Ref supplier
$morehtmlref.='<br>'; $morehtmlref .= '<br>';
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', 0, 1); $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 .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->contrat->creer, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
// Thirdparty // Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->thirdparty->id.'&search_name='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherContracts").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/contrat/list.php?socid='.$object->thirdparty->id.'&search_name='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherContracts").'</a>)';
// Project // Project
if (! empty($conf->projet->enabled)) if (!empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->contrat->creer) if ($user->rights->contrat->creer)
{ {
if ($action != 'classify') { if ($action != 'classify') {
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
} }
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>'; $morehtmlref .= '</form>';
} else { } 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 { } else {
if (! empty($object->fk_project)) { if (!empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
$morehtmlref.=$proj->ref; $morehtmlref .= $proj->ref;
$morehtmlref.='</a>'; $morehtmlref .= '</a>';
} else { } else {
$morehtmlref.=''; $morehtmlref .= '';
} }
} }
} }
$morehtmlref.='</div>'; $morehtmlref .= '</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
@ -1619,7 +1619,7 @@ else
// Quantity // Quantity
print '<td class="center">'.$objp->qty.'</td>'; print '<td class="center">'.$objp->qty.'</td>';
// Unit // Unit
if($conf->global->PRODUCT_USE_UNITS) print '<td class="left">'.$langs->trans($object->lines[$cursorline-1]->getLabelOfUnit()).'</td>'; if ($conf->global->PRODUCT_USE_UNITS) print '<td class="left">'.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).'</td>';
// Discount // Discount
if ($objp->remise_percent > 0) if ($objp->remise_percent > 0)
{ {
@ -1717,32 +1717,32 @@ else
print '<td>'; print '<td>';
if ($objp->fk_product) if ($objp->fk_product)
{ {
$productstatic->id=$objp->fk_product; $productstatic->id = $objp->fk_product;
$productstatic->type=$objp->ptype; $productstatic->type = $objp->ptype;
$productstatic->ref=$objp->pref; $productstatic->ref = $objp->pref;
$productstatic->entity=$objp->pentity; $productstatic->entity = $objp->pentity;
print $productstatic->getNomUrl(1, '', 32); print $productstatic->getNomUrl(1, '', 32);
print $objp->label?' - '.dol_trunc($objp->label, 32):''; print $objp->label ? ' - '.dol_trunc($objp->label, 32) : '';
print '<br>'; print '<br>';
} }
else else
{ {
print $objp->label?$objp->label.'<br>':''; print $objp->label ? $objp->label.'<br>' : '';
} }
// editeur wysiwyg // editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$nbrows=ROWS_2; $nbrows = ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; 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); $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 = new DolEditor('product_desc', $objp->description, '', 92, 'dolibarr_details', '', false, true, $enable, $nbrows, '90%');
$doleditor->Create(); $doleditor->Create();
print '</td>'; print '</td>';
// VAT // VAT
print '<td class="right">'; print '<td class="right">';
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 '</td>'; print '</td>';
// Price // Price
@ -1767,7 +1767,7 @@ else
// Discount // Discount
print '<td class="nowrap right"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>'; print '<td class="nowrap right"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
if (! empty($usemargins)) if (!empty($usemargins))
{ {
print '<td class="right">'; print '<td class="right">';
if ($objp->fk_product) print '<select id="fournprice" name="fournprice"></select>'; if ($objp->fk_product) print '<select id="fournprice" name="fournprice"></select>';
@ -1885,27 +1885,27 @@ else
// Area with status and activation info of line // Area with status and activation info of line
if ($object->statut > 0) if ($object->statut > 0)
{ {
print '<table class="notopnoleftnoright tableforservicepart2'.($cursorline < $nbofservices ?' boxtablenobottom':'').'" width="100%">'; print '<table class="notopnoleftnoright tableforservicepart2'.($cursorline < $nbofservices ? ' boxtablenobottom' : '').'" width="100%">';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).'</td>'; print '<td>'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).'</td>';
print '<td width="30" class="right">'; print '<td width="30" class="right">';
if ($user->socid == 0) if ($user->socid == 0)
{ {
if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline')
{ {
$tmpaction='activateline'; $tmpaction = 'activateline';
$tmpactionpicto='play'; $tmpactionpicto = 'play';
$tmpactiontext=$langs->trans("Activate"); $tmpactiontext = $langs->trans("Activate");
if ($objp->statut == 4) if ($objp->statut == 4)
{ {
$tmpaction='unactivateline'; $tmpaction = 'unactivateline';
$tmpactionpicto='playstop'; $tmpactionpicto = 'playstop';
$tmpactiontext=$langs->trans("Disable"); $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 '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;ligne=' . $object->lines[$cursorline - 1]->id . '&amp;action=' . $tmpaction . '">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;ligne='.$object->lines[$cursorline - 1]->id.'&amp;action='.$tmpaction.'">';
print img_picto($tmpactiontext, $tmpactionpicto); print img_picto($tmpactiontext, $tmpactionpicto);
print '</a>'; print '</a>';
} }
@ -2060,24 +2060,24 @@ else
// Form to add new line // Form to add new line
if ($user->rights->contrat->creer && ($object->statut == 0)) if ($user->rights->contrat->creer && ($object->statut == 0))
{ {
$dateSelector=1; $dateSelector = 1;
print "\n"; print "\n";
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline')?'#add':'#line_'.GETPOST('lineid')).'" method="POST"> print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid')).'" method="POST">
<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'"> <input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">
<input type="hidden" name="action" value="'.(($action != 'editline')?'addline':'updateline').'"> <input type="hidden" name="action" value="'.(($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="'.$object->id.'"> <input type="hidden" name="id" value="'.$object->id.'">
'; ';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Array with (n*2)+1 lines print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Array with (n*2)+1 lines
// Form to add new line // Form to add new line
if ($action != 'editline') if ($action != 'editline')
{ {
$forcetoshowtitlelines=1; $forcetoshowtitlelines = 1;
if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts if (empty($object->multicurrency_code)) $object->multicurrency_code = $conf->currency; // TODO Remove this when multicurrency supported on contracts
// Add free products/services // Add free products/services
$object->formAddObjectLine(1, $mysoc, $soc); $object->formAddObjectLine(1, $mysoc, $soc);

View File

@ -63,7 +63,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($totalcontrat); echo price($totalcontrat);
} ?></td> } ?></td>
<td class="right"><?php echo $objectlink->getLibStatut(7); ?></td> <td class="right"><?php echo $objectlink->getLibStatut(7); ?></td>
<td class="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr> </tr>
<?php <?php
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2017-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -30,44 +30,54 @@
// $backtopage may be defined // $backtopage may be defined
// $triggermodname may be defined // $triggermodname may be defined
if (! empty($permissionedit) && empty($permissiontoadd)) $permissiontoadd = $permissionedit; // For backward compatibility if (!empty($permissionedit) && empty($permissiontoadd)) $permissiontoadd = $permissionedit; // For backward compatibility
if ($cancel) if ($cancel)
{ {
/*var_dump($cancel); /*var_dump($cancel);
var_dump($backtopage);exit;*/ var_dump($backtopage);exit;*/
if (! empty($backtopage)) if (!empty($backtopage))
{ {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
$action=''; $action = '';
} }
// Action to add record // Action to add record
if ($action == 'add' && ! empty($permissiontoadd)) if ($action == 'add' && !empty($permissiontoadd))
{ {
foreach ($object->fields as $key => $val) 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 // Set value to insert
if (in_array($object->fields[$key]['type'], array('text', 'html'))) { if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
$value = GETPOST($key, 'none'); $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')); $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')); $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'])) { } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
} else { } else {
$value = GETPOST($key, 'alpha'); $value = GETPOST($key, 'alpha');
} }
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field
if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field
$object->$key=$value; //var_dump($key.' '.$value.' '.$object->fields[$key]['type']);
if ($val['notnull'] > 0 && $object->$key == '' && ! is_null($val['default']) && $val['default'] == '(PROV)') $object->$key = $value;
if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)')
{ {
$object->$key = '(PROV)'; $object->$key = '(PROV)';
} }
@ -108,8 +118,16 @@ if ($action == 'update' && !empty($permissiontoadd))
{ {
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited // Check if field was 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 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 // Set value to update
if (in_array($object->fields[$key]['type'], array('text', 'html'))) { if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
$value = GETPOST($key, 'none'); $value = GETPOST($key, 'none');
@ -117,6 +135,12 @@ if ($action == 'update' && !empty($permissiontoadd))
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
} elseif ($object->fields[$key]['type'] == 'datetime') { } 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')); $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'))) { } elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) {
$value = price2num(GETPOST($key)); $value = price2num(GETPOST($key));
} else { } else {

View File

@ -0,0 +1,190 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/boxes/box_shipments.php
* \ingroup shipment
* \brief Module for generating the display of the shipment box
*/
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
/**
* Class to manage the box to show last shipments
*/
class box_shipments extends ModeleBoxes
{
public $boxcode="lastcustomershipments";
public $boximg="sending";
public $boxlabel="BoxLastCustomerShipments";
public $depends = array("expedition");
/**
* @var DoliDB Database handler.
*/
public $db;
public $param;
public $info_box_head = array();
public $info_box_contents = array();
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
public function __construct($db, $param)
{
global $user;
$this->db=$db;
$this->hidden=! ($user->rights->expedition->lire);
}
/**
* Load data for box to show them later
*
* @param int $max Maximum number of records to load
* @return void
*/
public function loadBox($max = 5)
{
global $user, $langs, $conf;
$langs->loadLangs(array('orders', 'sendings'));
$this->max = $max;
include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$shipmentstatic = new Expedition($this->db);
$orderstatic = new Commande($this->db);
$societestatic = new Societe($this->db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max));
if ($user->rights->expedition->lire)
{
$sql = "SELECT s.nom as name";
$sql.= ", s.rowid as socid";
$sql.= ", s.code_client";
$sql.= ", s.logo, s.email";
$sql.= ", e.ref, e.tms";
$sql.= ", e.rowid";
$sql.= ", e.ref_customer";
$sql.= ", e.fk_statut";
$sql.= ", e.fk_user_valid";
$sql.= ", c.ref as commande_ref";
$sql.= ", c.rowid as commande_id";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql.= " WHERE e.entity = ".$conf->entity;
if (! empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql.=" AND e.fk_statut = 1";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND sc.fk_user = " .$user->id;
else $sql.= " ORDER BY e.date_delivery, e.ref DESC ";
$sql.= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$shipmentstatic->id = $objp->rowid;
$shipmentstatic->ref = $objp->ref;
$shipmentstatic->ref_customer = $objp->ref_customer;
$orderstatic->id= $objp->commande_id;
$orderstatic->ref=$objp->commande_ref;
$societestatic->id = $objp->socid;
$societestatic->name = $objp->name;
$societestatic->email = $objp->email;
$societestatic->code_client = $objp->code_client;
$societestatic->logo = $objp->logo;
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => $shipmentstatic->getNomUrl(1),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $societestatic->getNomUrl(1),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => $orderstatic->getNomUrl(1),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right" width="18"',
'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3),
);
$line++;
}
if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedShipments"));
$this->db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => '',
'maxlength'=>500,
'text' => ($this->db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'class="nohover opacitymedium left"',
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
* @return string
*/
public function showBox($head = null, $contents = null, $nooutput = 0)
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
}

View File

@ -626,6 +626,7 @@ class CMailFile
} }
// Force parameters // Force parameters
//dol_syslog("CMailFile::sendfile conf->global->".$keyforsmtpserver."=".$conf->global->$keyforsmtpserver." cpnf->global->".$keyforsmtpport."=".$conf->global->$keyforsmtpport, LOG_DEBUG);
if (!empty($conf->global->$keyforsmtpserver)) ini_set('SMTP', $conf->global->$keyforsmtpserver); if (!empty($conf->global->$keyforsmtpserver)) ini_set('SMTP', $conf->global->$keyforsmtpserver);
if (!empty($conf->global->$keyforsmtpport)) ini_set('smtp_port', $conf->global->$keyforsmtpport); if (!empty($conf->global->$keyforsmtpport)) ini_set('smtp_port', $conf->global->$keyforsmtpport);
@ -776,7 +777,7 @@ class CMailFile
else else
{ {
if (empty($this->error)) $this->error = $result; if (empty($this->error)) $this->error = $result;
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."<br>".$this->error, LOG_ERR);
$res = false; $res = false;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -178,7 +178,7 @@ class Conf
if ($value && preg_match('/^MAIN_MODULE_/', $key)) if ($value && preg_match('/^MAIN_MODULE_/', $key))
{ {
$reg=array(); $reg = array();
// If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs']. // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key))
{ {
@ -224,11 +224,11 @@ class Conf
} }
// Include other local consts.php files and fetch their values to the corresponding database constants. // Include other local consts.php files and fetch their values to the corresponding database constants.
if (! empty($this->global->LOCAL_CONSTS_FILES)) { if (!empty($this->global->LOCAL_CONSTS_FILES)) {
$filesList = explode(":", $this->global->LOCAL_CONSTS_FILES); $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
foreach ($filesList as $file) { foreach ($filesList as $file) {
$file=dol_sanitizeFileName($file); $file = dol_sanitizeFileName($file);
include_once DOL_DOCUMENT_ROOT . "/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars. include_once DOL_DOCUMENT_ROOT."/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars.
} }
} }
@ -326,33 +326,33 @@ class Conf
} }
// For mycompany storage // For mycompany storage
$this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany"); $this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany");
$this->mycompany->multidir_temp = array($this->entity => $rootfordata."/mycompany/temp"); $this->mycompany->multidir_temp = array($this->entity => $rootfordata."/mycompany/temp");
// For backward compatibility // For backward compatibility
$this->mycompany->dir_output=$rootfordata."/mycompany"; $this->mycompany->dir_output = $rootfordata."/mycompany";
$this->mycompany->dir_temp=$rootfordata."/mycompany/temp"; $this->mycompany->dir_temp = $rootfordata."/mycompany/temp";
// For admin storage // For admin storage
$this->admin->dir_output=$rootfordata.'/admin'; $this->admin->dir_output = $rootfordata.'/admin';
$this->admin->dir_temp=$rootfordata.'/admin/temp'; $this->admin->dir_temp = $rootfordata.'/admin/temp';
// For user storage // For user storage
$this->user->multidir_output = array($this->entity => $rootfordata."/users"); $this->user->multidir_output = array($this->entity => $rootfordata."/users");
$this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp"); $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp");
// For backward compatibility // For backward compatibility
$this->user->dir_output=$rootforuser."/users"; $this->user->dir_output = $rootforuser."/users";
$this->user->dir_temp=$rootforuser."/users/temp"; $this->user->dir_temp = $rootforuser."/users/temp";
// For usergroup storage // For usergroup storage
$this->usergroup->dir_output=$rootforuser."/usergroups"; $this->usergroup->dir_output = $rootforuser."/usergroups";
$this->usergroup->dir_temp=$rootforuser."/usergroups/temp"; $this->usergroup->dir_temp = $rootforuser."/usergroups/temp";
// For proposal storage // For proposal storage
$this->propal->multidir_output = array($this->entity => $rootfordata."/propale"); $this->propal->multidir_output = array($this->entity => $rootfordata."/propale");
$this->propal->multidir_temp = array($this->entity => $rootfordata."/propale/temp"); $this->propal->multidir_temp = array($this->entity => $rootfordata."/propale/temp");
// For backward compatibility // For backward compatibility
$this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_output = $rootfordata."/propale";
$this->propal->dir_temp=$rootfordata."/propale/temp"; $this->propal->dir_temp = $rootfordata."/propale/temp";
// For bank storage // For bank storage
$this->bank->multidir_output = array($this->entity => $rootfordata."/bank"); $this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
@ -361,107 +361,107 @@ class Conf
$this->bank->dir_temp = $rootfordata."/bank/temp"; $this->bank->dir_temp = $rootfordata."/bank/temp";
// For medias storage // For medias storage
$this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); $this->medias->multidir_output = array($this->entity => $rootfordata."/medias");
$this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp"); $this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp");
// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
// Sous module bons d'expedition // Sous module bons d'expedition
$this->expedition_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_EXPEDITION)?$this->global->MAIN_SUBMODULE_EXPEDITION:0); $this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0);
// Sous module bons de livraison // Sous module bons de livraison
$this->livraison_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_LIVRAISON)?$this->global->MAIN_SUBMODULE_LIVRAISON:0); $this->livraison_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_LIVRAISON) ? $this->global->MAIN_SUBMODULE_LIVRAISON : 0);
// Module fournisseur // Module fournisseur
// TODO To split into module supplier_invoice and supplier_order // TODO To split into module supplier_invoice and supplier_order
if (! empty($this->fournisseur)) if (!empty($this->fournisseur))
{ {
$this->fournisseur->commande=new stdClass(); $this->fournisseur->commande = new stdClass();
$this->fournisseur->commande->multidir_output=array($this->entity => $rootfordata."/fournisseur/commande"); $this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
$this->fournisseur->commande->multidir_temp =array($this->entity => $rootfordata."/fournisseur/commande/temp"); $this->fournisseur->commande->multidir_temp = array($this->entity => $rootfordata."/fournisseur/commande/temp");
$this->fournisseur->commande->dir_output=$rootfordata."/fournisseur/commande"; // For backward compatibility $this->fournisseur->commande->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
$this->fournisseur->commande->dir_temp =$rootfordata."/fournisseur/commande/temp"; // For backward compatibility $this->fournisseur->commande->dir_temp = $rootfordata."/fournisseur/commande/temp"; // For backward compatibility
$this->fournisseur->facture=new stdClass(); $this->fournisseur->facture = new stdClass();
$this->fournisseur->facture->multidir_output=array($this->entity => $rootfordata."/fournisseur/facture"); $this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
$this->fournisseur->facture->multidir_temp =array($this->entity => $rootfordata."/fournisseur/facture/temp"); $this->fournisseur->facture->multidir_temp = array($this->entity => $rootfordata."/fournisseur/facture/temp");
$this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture"; // For backward compatibility $this->fournisseur->facture->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
$this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp"; // For backward compatibility $this->fournisseur->facture->dir_temp = $rootfordata."/fournisseur/facture/temp"; // For backward compatibility
$this->fournisseur->payment=new stdClass(); $this->fournisseur->payment = new stdClass();
$this->fournisseur->payment->multidir_output=array($this->entity => $rootfordata."/fournisseur/payment"); $this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata."/fournisseur/payment");
$this->fournisseur->payment->multidir_temp =array($this->entity => $rootfordata."/fournisseur/payment/temp"); $this->fournisseur->payment->multidir_temp = array($this->entity => $rootfordata."/fournisseur/payment/temp");
$this->fournisseur->payment->dir_output =$rootfordata."/fournisseur/payment"; // For backward compatibility $this->fournisseur->payment->dir_output = $rootfordata."/fournisseur/payment"; // For backward compatibility
$this->fournisseur->payment->dir_temp =$rootfordata."/fournisseur/payment/temp"; // For backward compatibility $this->fournisseur->payment->dir_temp = $rootfordata."/fournisseur/payment/temp"; // For backward compatibility
// To prepare split of module vendor(fournisseur) into vendor + supplier_order + supplier_invoice + supplierproposal // To prepare split of module vendor(fournisseur) into vendor + supplier_order + supplier_invoice + supplierproposal
if (! empty($this->fournisseur->enabled)) // By default, if module supplier is on, we set new properties if (!empty($this->fournisseur->enabled)) // By default, if module supplier is on, we set new properties
{ {
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists
{ {
$this->supplier_order=new stdClass(); $this->supplier_order = new stdClass();
$this->supplier_order->enabled=1; $this->supplier_order->enabled = 1;
$this->supplier_order->multidir_output=array($this->entity => $rootfordata."/fournisseur/commande"); $this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
$this->supplier_order->multidir_temp =array($this->entity => $rootfordata."/fournisseur/commande/temp"); $this->supplier_order->multidir_temp = array($this->entity => $rootfordata."/fournisseur/commande/temp");
$this->supplier_order->dir_output=$rootfordata."/fournisseur/commande"; // For backward compatibility $this->supplier_order->dir_output = $rootfordata."/fournisseur/commande"; // For backward compatibility
$this->supplier_order->dir_temp=$rootfordata."/fournisseur/commande/temp"; // For backward compatibility $this->supplier_order->dir_temp = $rootfordata."/fournisseur/commande/temp"; // For backward compatibility
} }
if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) // This can be set to 1 once modules purchase order and supplier invoice exists
{ {
$this->supplier_invoice=new stdClass(); $this->supplier_invoice = new stdClass();
$this->supplier_invoice->enabled=1; $this->supplier_invoice->enabled = 1;
$this->supplier_invoice->multidir_output=array($this->entity => $rootfordata."/fournisseur/facture"); $this->supplier_invoice->multidir_output = array($this->entity => $rootfordata."/fournisseur/facture");
$this->supplier_invoice->multidir_temp =array($this->entity => $rootfordata."/fournisseur/facture/temp"); $this->supplier_invoice->multidir_temp = array($this->entity => $rootfordata."/fournisseur/facture/temp");
$this->supplier_invoice->dir_output=$rootfordata."/fournisseur/facture"; // For backward compatibility $this->supplier_invoice->dir_output = $rootfordata."/fournisseur/facture"; // For backward compatibility
$this->supplier_invoice->dir_temp=$rootfordata."/fournisseur/facture/temp"; // For backward compatibility $this->supplier_invoice->dir_temp = $rootfordata."/fournisseur/facture/temp"; // For backward compatibility
} }
} }
} }
// Module product/service // Module product/service
$this->product->multidir_output=array($this->entity => $rootfordata."/produit"); $this->product->multidir_output = array($this->entity => $rootfordata."/produit");
$this->product->multidir_temp =array($this->entity => $rootfordata."/produit/temp"); $this->product->multidir_temp = array($this->entity => $rootfordata."/produit/temp");
$this->service->multidir_output=array($this->entity => $rootfordata."/produit"); $this->service->multidir_output = array($this->entity => $rootfordata."/produit");
$this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp"); $this->service->multidir_temp = array($this->entity => $rootfordata."/produit/temp");
// For backward compatibility // For backward compatibility
$this->product->dir_output=$rootfordata."/produit"; $this->product->dir_output = $rootfordata."/produit";
$this->product->dir_temp =$rootfordata."/produit/temp"; $this->product->dir_temp = $rootfordata."/produit/temp";
$this->service->dir_output=$rootfordata."/produit"; $this->service->dir_output = $rootfordata."/produit";
$this->service->dir_temp =$rootfordata."/produit/temp"; $this->service->dir_temp = $rootfordata."/produit/temp";
// Module productbatch // Module productbatch
$this->productbatch->multidir_output=array($this->entity => $rootfordata."/produitlot"); $this->productbatch->multidir_output = array($this->entity => $rootfordata."/produitlot");
$this->productbatch->multidir_temp =array($this->entity => $rootfordata."/produitlot/temp"); $this->productbatch->multidir_temp = array($this->entity => $rootfordata."/produitlot/temp");
// Module contrat // Module contrat
$this->contrat->multidir_output = array($this->entity => $rootfordata."/contract"); $this->contrat->multidir_output = array($this->entity => $rootfordata."/contract");
$this->contrat->multidir_temp = array($this->entity => $rootfordata."/contract/temp"); $this->contrat->multidir_temp = array($this->entity => $rootfordata."/contract/temp");
// For backward compatibility // For backward compatibility
$this->contrat->dir_output=$rootfordata."/contract"; $this->contrat->dir_output = $rootfordata."/contract";
$this->contrat->dir_temp =$rootfordata."/contract/temp"; $this->contrat->dir_temp = $rootfordata."/contract/temp";
// Module bank // Module bank
$this->bank->dir_output=$rootfordata."/bank"; $this->bank->dir_output = $rootfordata."/bank";
$this->bank->dir_temp =$rootfordata."/bank/temp"; $this->bank->dir_temp = $rootfordata."/bank/temp";
// Set some default values // Set some default values
//$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month
$this->global->MAIN_MAIL_USE_MULTI_PART=1; $this->global->MAIN_MAIL_USE_MULTI_PART = 1;
// societe // societe
if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard"; if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum"; if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint'; if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
if (empty($conf->global->TICKET_ADDON)) $this->global->TICKET_ADDON='mod_ticket_simple'; if (empty($conf->global->TICKET_ADDON)) $this->global->TICKET_ADDON = 'mod_ticket_simple';
// Security // Security
if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK='0664'; // Default mask if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask
// conf->use_javascript_ajax // conf->use_javascript_ajax
$this->use_javascript_ajax=1; $this->use_javascript_ajax = 1;
if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax=! $this->global->MAIN_DISABLE_JAVASCRIPT; if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
// If no javascript_ajax, Ajax features are disabled. // If no javascript_ajax, Ajax features are disabled.
if (empty($this->use_javascript_ajax)) if (empty($this->use_javascript_ajax))
{ {
@ -471,231 +471,231 @@ class Conf
unset($this->global->PROJECT_USE_SEARCH_TO_SELECT); unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
} }
if (! empty($this->productbatch->enabled)) if (!empty($this->productbatch->enabled))
{ {
$this->global->STOCK_CALCULATE_ON_BILL=0; $this->global->STOCK_CALCULATE_ON_BILL = 0;
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER=0; $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
$this->global->STOCK_CALCULATE_ON_SHIPMENT=1; $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE=0; $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL=0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER=0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
if(empty($this->reception->enabled))$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER=1; if (empty($this->reception->enabled))$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
else { else {
$this->global->STOCK_CALCULATE_ON_RECEPTION=1; $this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE=0; $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
} }
} }
// conf->currency // conf->currency
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR'; if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE = 'EUR';
$this->currency=$this->global->MAIN_MONNAIE; $this->currency = $this->global->MAIN_MONNAIE;
if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
// conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
// By default, suppliers objects can be linked to all projects // By default, suppliers objects can be linked to all projects
if (! isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
// By default we enable feature to bill time spent // By default we enable feature to bill time spent
if (! isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1; if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1;
// MAIN_HTML_TITLE // MAIN_HTML_TITLE
if (! isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE='noapp,thirdpartynameonly,contactnameonly,projectnameonly'; if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
// conf->liste_limit = constante de taille maximale des listes // conf->liste_limit = constante de taille maximale des listes
if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25; if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT = 25;
$this->liste_limit=$this->global->MAIN_SIZE_LISTE_LIMIT; $this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
// conf->product->limit_size = constante de taille maximale des select de produit // conf->product->limit_size = constante de taille maximale des select de produit
if (! isset($this->global->PRODUIT_LIMIT_SIZE)) $this->global->PRODUIT_LIMIT_SIZE=1000; if (!isset($this->global->PRODUIT_LIMIT_SIZE)) $this->global->PRODUIT_LIMIT_SIZE = 1000;
$this->product->limit_size=$this->global->PRODUIT_LIMIT_SIZE; $this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
// conf->theme et $this->css // conf->theme et $this->css
if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME="eldy"; if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy";
if (! empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME=$this->global->MAIN_FORCETHEME; if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
$this->theme=$this->global->MAIN_THEME; $this->theme = $this->global->MAIN_THEME;
$this->css = "/theme/".$this->theme."/style.css.php"; $this->css = "/theme/".$this->theme."/style.css.php";
// conf->email_from = email pour envoi par dolibarr des mails automatiques // conf->email_from = email pour envoi par dolibarr des mails automatiques
$this->email_from = "robot@example.com"; $this->email_from = "robot@example.com";
if (! empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM; if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
// conf->notification->email_from = email pour envoi par Dolibarr des notifications // conf->notification->email_from = email pour envoi par Dolibarr des notifications
$this->notification->email_from=$this->email_from; $this->notification->email_from = $this->email_from;
if (! empty($this->global->NOTIFICATION_EMAIL_FROM)) $this->notification->email_from=$this->global->NOTIFICATION_EMAIL_FROM; if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
// conf->mailing->email_from = email pour envoi par Dolibarr des mailings // conf->mailing->email_from = email pour envoi par Dolibarr des mailings
$this->mailing->email_from=$this->email_from; $this->mailing->email_from = $this->email_from;
if (! empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from=$this->global->MAILING_EMAIL_FROM; if (!empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
if (! isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID=1; if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1;
// Format for date (used by default when not found or not searched in lang) // Format for date (used by default when not found or not searched in lang)
$this->format_date_short="%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
$this->format_date_short_java="dd/MM/yyyy"; // Format of day with Java tags $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags
$this->format_hour_short="%H:%M"; $this->format_hour_short = "%H:%M";
$this->format_hour_short_duration="%H:%M"; $this->format_hour_short_duration = "%H:%M";
$this->format_date_text_short="%d %b %Y"; $this->format_date_text_short = "%d %b %Y";
$this->format_date_text="%d %B %Y"; $this->format_date_text = "%d %B %Y";
$this->format_date_hour_short="%d/%m/%Y %H:%M"; $this->format_date_hour_short = "%d/%m/%Y %H:%M";
$this->format_date_hour_sec_short="%d/%m/%Y %H:%M:%S"; $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S";
$this->format_date_hour_text_short="%d %b %Y %H:%M"; $this->format_date_hour_text_short = "%d %b %Y %H:%M";
$this->format_date_hour_text="%d %B %Y %H:%M"; $this->format_date_hour_text = "%d %B %Y %H:%M";
// Duration of workday // Duration of workday
if (! isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY=86400; if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400;
// Limites decimales si non definie (peuvent etre egale a 0) // Limites decimales si non definie (peuvent etre egale a 0)
if (! isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT=5; if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT = 5;
if (! isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT=2; if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT = 2;
if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN=8; if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
// Default pdf option // Default pdf option
if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
// Default max file size for upload // Default max file size for upload
$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
// By default, we propagate contacts // By default, we propagate contacts
if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
// By default, we do not use the zip town table but the table of third parties // By default, we do not use the zip town table but the table of third parties
if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=0; if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
// By default, we open card if one found // By default, we open card if one found
if (! isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE=1; if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
// By default, we show state code in combo list // By default, we show state code in combo list
if (! isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE=1; if (!isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE = 1;
// Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined) // Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
if (! isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION=1; if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
// Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later. if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
if (! empty($this->modules_parts['moduleforexternal'])) // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list if (!empty($this->modules_parts['moduleforexternal'])) // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
{ {
foreach($this->modules_parts['moduleforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL.=",".$key; foreach ($this->modules_parts['moduleforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
} }
// Enable select2 // Enable select2
if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT='select2'; if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
// Timeouts // Timeouts
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10; if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT=30; if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
// Set default variable to calculate VAT as if option tax_mode was 0 (standard) // Set default variable to calculate VAT as if option tax_mode was 0 (standard)
if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT='invoice'; if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT='invoice'; if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE='payment'; if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment';
if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE='payment'; if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment';
// Delay before warnings // Delay before warnings
// Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
if (isset($this->agenda)) { if (isset($this->agenda)) {
$this->adherent->subscription = new stdClass(); $this->adherent->subscription = new stdClass();
$this->adherent->subscription->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60; $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 24 * 60 * 60;
} }
if (isset($this->agenda)) { if (isset($this->agenda)) {
$this->agenda->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60; $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 24 * 60 * 60;
} }
if (isset($this->projet)) if (isset($this->projet))
{ {
$this->projet->warning_delay=(isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE)?$this->global->MAIN_DELAY_PROJECT_TO_CLOSE:7)*24*60*60; $this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 24 * 60 * 60;
$this->projet->task = new StdClass(); $this->projet->task = new StdClass();
$this->projet->task->warning_delay=(isset($this->global->MAIN_DELAY_TASKS_TODO)?$this->global->MAIN_DELAY_TASKS_TODO:7)*24*60*60; $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 24 * 60 * 60;
} }
if (isset($this->commande)) { if (isset($this->commande)) {
$this->commande->client = new stdClass(); $this->commande->client = new stdClass();
$this->commande->fournisseur = new stdClass(); $this->commande->fournisseur = new stdClass();
$this->commande->client->warning_delay=(isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_ORDERS_TO_PROCESS:2)*24*60*60; $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 24 * 60 * 60;
$this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60; $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 24 * 60 * 60;
} }
if (isset($this->propal)) { if (isset($this->propal)) {
$this->propal->cloture = new stdClass(); $this->propal->cloture = new stdClass();
$this->propal->facturation = new stdClass(); $this->propal->facturation = new stdClass();
$this->propal->cloture->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE)?$this->global->MAIN_DELAY_PROPALS_TO_CLOSE:0)*24*60*60; $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 24 * 60 * 60;
$this->propal->facturation->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_BILL)?$this->global->MAIN_DELAY_PROPALS_TO_BILL:0)*24*60*60; $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 24 * 60 * 60;
} }
if (isset($this->facture)) { if (isset($this->facture)) {
$this->facture->client = new stdClass(); $this->facture->client = new stdClass();
$this->facture->fournisseur = new stdClass(); $this->facture->fournisseur = new stdClass();
$this->facture->client->warning_delay=(isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED)?$this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED:0)*24*60*60; $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 24 * 60 * 60;
$this->facture->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY)?$this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY:0)*24*60*60; $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 24 * 60 * 60;
} }
if (isset($this->contrat)) { if (isset($this->contrat)) {
$this->contrat->services = new stdClass(); $this->contrat->services = new stdClass();
$this->contrat->services->inactifs = new stdClass(); $this->contrat->services->inactifs = new stdClass();
$this->contrat->services->expires = new stdClass(); $this->contrat->services->expires = new stdClass();
$this->contrat->services->inactifs->warning_delay=(isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES)?$this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES:0)*24*60*60; $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 24 * 60 * 60;
$this->contrat->services->expires->warning_delay=(isset($this->global->MAIN_DELAY_RUNNING_SERVICES)?$this->global->MAIN_DELAY_RUNNING_SERVICES:0)*24*60*60; $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 24 * 60 * 60;
} }
if (isset($this->commande)) { if (isset($this->commande)) {
$this->bank->rappro = new stdClass(); $this->bank->rappro = new stdClass();
$this->bank->cheque = new stdClass(); $this->bank->cheque = new stdClass();
$this->bank->rappro->warning_delay=(isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE)?$this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE:0)*24*60*60; $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 24 * 60 * 60;
$this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60; $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 24 * 60 * 60;
} }
if (isset($this->expensereport)) { if (isset($this->expensereport)) {
$this->expensereport->approve = new stdClass(); $this->expensereport->approve = new stdClass();
$this->expensereport->approve->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS)?$this->global->MAIN_DELAY_EXPENSEREPORTS:0)*24*60*60; $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 24 * 60 * 60;
$this->expensereport->payment = new stdClass(); $this->expensereport->payment = new stdClass();
$this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60; $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 24 * 60 * 60;
} }
if (isset($this->holiday)) { if (isset($this->holiday)) {
$this->holiday->approve = new stdClass(); $this->holiday->approve = new stdClass();
$this->holiday->approve->warning_delay=(isset($this->global->MAIN_DELAY_HOLIDAYS)?$this->global->MAIN_DELAY_HOLIDAYS:0)*24*60*60; $this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 24 * 60 * 60;
} }
if (! empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT))
{ {
$this->global->PRODUIT_MULTIPRICES_LIMIT = 5; $this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
} }
// For modules that want to disable top or left menu // For modules that want to disable top or left menu
if (! empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu=$this->global->MAIN_HIDE_TOP_MENU; if (!empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
if (! empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu=$this->global->MAIN_HIDE_LEFT_MENU; if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT=3; if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
if (! isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT=0; if (!isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT = 0;
// Save inconsistent option // Save inconsistent option
if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (! isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
{ {
$this->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. $this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
} }
if (! isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1; if (!isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1;
if (! isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0; if (!isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0;
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
// If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined. // If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined.
if (! isset($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $conf->global->MAIN_FEATURES_LEVEL >= 2) $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; if (!isset($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $conf->global->MAIN_FEATURES_LEVEL >= 2) $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
// For backward compatibility // For backward compatibility
if (isset($this->product)) $this->produit=$this->product; if (isset($this->product)) $this->produit = $this->product;
if (isset($this->facture)) $this->invoice=$this->facture; if (isset($this->facture)) $this->invoice = $this->facture;
if (isset($this->commande)) $this->order=$this->commande; if (isset($this->commande)) $this->order = $this->commande;
if (isset($this->contrat)) $this->contract=$this->contrat; if (isset($this->contrat)) $this->contract = $this->contrat;
if (isset($this->categorie)) $this->category=$this->categorie; if (isset($this->categorie)) $this->category = $this->categorie;
if (isset($this->project)) $this->project=$this->projet; if (isset($this->project)) $this->project = $this->projet;
// Object $mc // Object $mc
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled))
{ {
if (is_object($mc)) $mc->setValues($this); if (is_object($mc)) $mc->setValues($this);
} }
// We init log handlers // We init log handlers
if (! empty($this->global->SYSLOG_HANDLERS)) { if (!empty($this->global->SYSLOG_HANDLERS)) {
$handlers = json_decode($this->global->SYSLOG_HANDLERS); $handlers = json_decode($this->global->SYSLOG_HANDLERS);
} else { } else {
$handlers = array(); $handlers = array();

View File

@ -56,19 +56,28 @@ class EmailSenderProfile extends CommonObject
public $picto = 'emailsenderprofile@monmodule'; public $picto = 'emailsenderprofile@monmodule';
const STATUS_DISABLED = 0;
const STATUS_ENABLED = 1;
/** /**
* 'type' if the field format. * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float')
* 'label' the translation key. * 'label' the translation key.
* 'enabled' is a condition when the filed must be managed. * 'enabled' is a condition when the field must be managed.
* 'visible' says if field is visible in list (-1 means not shown by default but can be added into list to be viewed). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing)
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'noteditable' says if field is not editable (1 or 0)
* 'index' if we want an index in database. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). * 'default' is a default value for creation (can still be replaced by the global setup of default values)
* 'position' is the sort order of field. * 'index' if we want an index in database.
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). * 'position' is the sort order of field.
* 'help' is a string visible as a tooltip on field * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
* 'comment' is not used. You can store here any text of your choice. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
* 'css' is the CSS style to use on field. For example: 'maxwidth200'
* 'help' is a string visible as a tooltip on field
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
* 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
*/ */
// BEGIN MODULEBUILDER PROPERTIES // BEGIN MODULEBUILDER PROPERTIES
@ -78,7 +87,7 @@ class EmailSenderProfile extends CommonObject
public $fields=array( public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1),
'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1), 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1),
//'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), //'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
//'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), //'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,),
@ -86,7 +95,7 @@ class EmailSenderProfile extends CommonObject
'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,), 'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1), 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'default'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1),
); );
/** /**

View File

@ -1957,13 +1957,14 @@ class ExtraFields
* *
* @param string $key Key of attribute * @param string $key Key of attribute
* @param string $object Object * @param string $object Object
* @param int $colspan Value of colspan to use (it must includes the first column with title)
* @return string HTML code with line for separator * @return string HTML code with line for separator
*/ */
public function showSeparator($key, $object) public function showSeparator($key, $object, $colspan = 2)
{ {
global $langs; global $langs;
$out = '<tr id="trextrafieldseparator'.$key.'" class="trextrafieldseparator trextrafieldseparator'.$key.'"><td colspan="2"><strong>'; $out = '<tr id="trextrafieldseparator'.$key.'" class="trextrafieldseparator trextrafieldseparator'.$key.'"><td colspan="'.$colspan.'"><strong>';
$out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]); $out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]);
$out .= '</strong></td></tr>'; $out .= '</strong></td></tr>';

View File

@ -5749,14 +5749,14 @@ class Form
/** /**
* Function to show a form to select a duration on a page * Function to show a form to select a duration on a page
* *
* @param string $prefix Prefix for input fields * @param string $prefix Prefix for input fields
* @param int $iSecond Default preselected duration (number of seconds or '') * @param int $iSecond Default preselected duration (number of seconds or '')
* @param int $disabled Disable the combo box * @param int $disabled Disable the combo box
* @param string $typehour If 'select' then input hour and input min is a combo, * @param string $typehour If 'select' then input hour and input min is a combo,
* if 'text' input hour is in text and input min is a text, * If 'text' input hour is in text and input min is a text,
* if 'textselect' input hour is in text and input min is a combo * If 'textselect' input hour is in text and input min is a combo
* @param integer $minunderhours If 1, show minutes selection under the hours * @param integer $minunderhours If 1, show minutes selection under the hours
* @param int $nooutput Do not output html string but return it * @param int $nooutput Do not output html string but return it
* @return string|void * @return string|void
*/ */
public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
@ -6521,6 +6521,7 @@ class Form
elseif ($addjscombo == 2) elseif ($addjscombo == 2)
{ {
// Add other js lib // Add other js lib
// TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
// ... // ...
$out .= '$(document).ready(function () { $out .= '$(document).ready(function () {
$(\'#'.$htmlname.'\').multiSelect({ $(\'#'.$htmlname.'\').multiSelect({

View File

@ -56,19 +56,19 @@ class FormWebsite
*/ */
public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0) public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0)
{ {
$out=''; $out = '';
$sql = "SELECT rowid, ref"; $sql = "SELECT rowid, ref";
$sql.= " FROM ".MAIN_DB_PREFIX."website"; $sql .= " FROM ".MAIN_DB_PREFIX."website";
$sql.= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
$sql.= " ORDER BY rowid"; $sql .= " ORDER BY rowid";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$out.='<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">'; $out .= '<select class="flat minwidth100" name="'.$htmlname.'" id="'.$htmlname.'">';
if ($useempty) if ($useempty)
{ {
$out.='<option value="-1">&nbsp;</option>'; $out .= '<option value="-1">&nbsp;</option>';
} }
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
@ -78,17 +78,17 @@ class FormWebsite
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($selected == $obj->rowid) if ($selected == $obj->rowid)
{ {
$out.='<option value="'.$obj->rowid.'" selected>'; $out .= '<option value="'.$obj->rowid.'" selected>';
} }
else else
{ {
$out.='<option value="'.$obj->rowid.'">'; $out .= '<option value="'.$obj->rowid.'">';
} }
$out.=$obj->ref; $out .= $obj->ref;
$out.='</option>'; $out .= '</option>';
$i++; $i++;
} }
$out.="</select>"; $out .= "</select>";
} }
else { else {
dol_print_error($this->db); dol_print_error($this->db);
@ -114,9 +114,9 @@ class FormWebsite
$langs->load("admin"); $langs->load("admin");
$sql = "SELECT rowid, code, label, entity"; $sql = "SELECT rowid, code, label, entity";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; $sql .= " FROM ".MAIN_DB_PREFIX.'c_type_container';
$sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; $sql .= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")";
$sql.= " ORDER BY label"; $sql .= " ORDER BY label";
dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -126,7 +126,7 @@ class FormWebsite
$i = 0; $i = 0;
if ($num) if ($num)
{ {
print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
if ($useempty == 1 || ($useempty == 2 && $num > 1)) if ($useempty == 1 || ($useempty == 2 && $num > 1))
{ {
print '<option value="-1">&nbsp;</option>'; print '<option value="-1">&nbsp;</option>';
@ -179,8 +179,8 @@ class FormWebsite
$listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$'); $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$');
$arrayofsamples = array(); $arrayofsamples = array();
$arrayofsamples['empty']='EmptyPage'; // Always this one first $arrayofsamples['empty'] = 'EmptyPage'; // Always this one first
foreach($listofsamples as $sample) foreach ($listofsamples as $sample)
{ {
$reg = array(); $reg = array();
if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg)) if (preg_match('/^page-sample-(.*)\.html$/', $sample['name'], $reg))
@ -193,14 +193,14 @@ class FormWebsite
} }
$out = ''; $out = '';
$out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>'; $out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
if ($useempty == 1 || $useempty == 2) if ($useempty == 1 || $useempty == 2)
{ {
$out .= '<option value="-1">&nbsp;</option>'; $out .= '<option value="-1">&nbsp;</option>';
} }
foreach($arrayofsamples as $key => $val) foreach ($arrayofsamples as $key => $val)
{ {
if ($selected == $key) if ($selected == $key)
{ {
@ -229,63 +229,66 @@ class FormWebsite
* @param int $showempty Show empty record * @param int $showempty Show empty record
* @param string $action Action on page that use this select list * @param string $action Action on page that use this select list
* @param string $morecss More CSS * @param string $morecss More CSS
* @param array $excludeids Exclude some ID in list
* @return string HTML select component with list of type of containers * @return string HTML select component with list of type of containers
*/ */
public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '', $morecss = 'minwidth200') public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '', $morecss = 'minwidth200', $excludeids = null)
{ {
global $langs; global $langs;
$atleastonepage = (is_array($website->lines) && count($website->lines) > 0); $atleastonepage = (is_array($website->lines) && count($website->lines) > 0);
$out=''; $out = '';
if ($atleastonepage && $action != 'editsource') if ($atleastonepage && $action != 'editsource')
{ {
$out.='<select name="'.$htmlname.'" id="'.$htmlname.'" class="maxwidth300'.($morecss ? ' '.$morecss : '').'">'; $out .= '<select name="'.$htmlname.'" id="'.$htmlname.'" class="maxwidth300'.($morecss ? ' '.$morecss : '').'">';
} }
else else
{ {
$out.='<select name="pageidbis" id="pageid" class="maxwidth300'.($morecss ? ' '.$morecss : '').'" disabled="disabled">'; $out .= '<select name="pageidbis" id="pageid" class="maxwidth300'.($morecss ? ' '.$morecss : '').'" disabled="disabled">';
} }
if ($showempty || ! $atleastonepage) $out.='<option value="-1">&nbsp;</option>'; if ($showempty || !$atleastonepage) $out .= '<option value="-1">&nbsp;</option>';
if ($atleastonepage) if ($atleastonepage)
{ {
if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one if (empty($pageid) && $action != 'createcontainer') // Page id is not defined, we try to take one
{ {
$firstpageid=0;$homepageid=0; $firstpageid = 0; $homepageid = 0;
foreach($website->lines as $key => $valpage) foreach ($website->lines as $key => $valpage)
{ {
if (empty($firstpageid)) $firstpageid=$valpage->id; if (empty($firstpageid)) $firstpageid = $valpage->id;
if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid=$valpage->id; if ($website->fk_default_home && $key == $website->fk_default_home) $homepageid = $valpage->id;
} }
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page $pageid = $homepageid ? $homepageid : $firstpageid; // We choose home page and if not defined yet, we take first page
} }
foreach($website->lines as $key => $valpage) foreach ($website->lines as $key => $valpage)
{ {
$valueforoption = '<span class="opacitymedium">['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).']</span> '; if (is_array($excludeids) && count($excludeids) && in_array($valpage->id, $excludeids)) continue;
$valueforoption.= $valpage->pageurl.' - '.$valpage->title;
if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption.=' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>';
$out.='<option value="'.$key.'"'; $valueforoption = '<span class="opacitymedium">['.$valpage->type_container.' '.sprintf("%03d", $valpage->id).']</span> ';
if ($pageid > 0 && $pageid == $key) $out.=' selected'; // To preselect a value $valueforoption .= $valpage->pageurl.' - '.$valpage->title;
$out.=' data-html="'.dol_escape_htmltag($valueforoption).'"'; if ($website->fk_default_home && $key == $website->fk_default_home) $valueforoption .= ' <span class="opacitymedium">('.$langs->trans("HomePage").')</span>';
$out.='>';
$out.=$valueforoption; $out .= '<option value="'.$key.'"';
$out.='</option>'; if ($pageid > 0 && $pageid == $key) $out .= ' selected'; // To preselect a value
$out .= ' data-html="'.dol_escape_htmltag($valueforoption).'"';
$out .= '>';
$out .= $valueforoption;
$out .= '</option>';
} }
} }
$out.='</select>'; $out .= '</select>';
if ($atleastonepage && $action != 'editsource') if ($atleastonepage && $action != 'editsource')
{ {
$out.=ajax_combobox($htmlname); $out .= ajax_combobox($htmlname);
} }
else else
{ {
$out.='<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">'; $out .= '<input type="hidden" name="'.$htmlname.'" value="'.$pageid.'">';
$out.=ajax_combobox($htmlname); $out .= ajax_combobox($htmlname);
} }
return $out; return $out;
} }

View File

@ -173,24 +173,24 @@ class Menubase
global $conf, $langs; global $conf, $langs;
// Clean parameters // Clean parameters
$this->menu_handler=trim($this->menu_handler); $this->menu_handler = trim($this->menu_handler);
$this->module=trim($this->module); $this->module = trim($this->module);
$this->type=trim($this->type); $this->type = trim($this->type);
$this->mainmenu=trim($this->mainmenu); $this->mainmenu = trim($this->mainmenu);
$this->leftmenu=trim($this->leftmenu); $this->leftmenu = trim($this->leftmenu);
$this->fk_menu = (int) $this->fk_menu; // If -1, fk_mainmenu and fk_leftmenu must be defined $this->fk_menu = (int) $this->fk_menu; // If -1, fk_mainmenu and fk_leftmenu must be defined
$this->fk_mainmenu=trim($this->fk_mainmenu); $this->fk_mainmenu = trim($this->fk_mainmenu);
$this->fk_leftmenu=trim($this->fk_leftmenu); $this->fk_leftmenu = trim($this->fk_leftmenu);
$this->position = (int) $this->position; $this->position = (int) $this->position;
$this->url=trim($this->url); $this->url = trim($this->url);
$this->target=trim($this->target); $this->target = trim($this->target);
$this->titre=trim($this->titre); $this->titre = trim($this->titre);
$this->langs=trim($this->langs); $this->langs = trim($this->langs);
$this->perms=trim($this->perms); $this->perms = trim($this->perms);
$this->enabled=trim($this->enabled); $this->enabled = trim($this->enabled);
$this->user = (int) $this->user; $this->user = (int) $this->user;
if (empty($this->position)) $this->position=0; if (empty($this->position)) $this->position = 0;
if (! $this->level) $this->level=0; if (!$this->level) $this->level = 0;
// Check parameters // Check parameters
if (empty($this->menu_handler)) return -1; if (empty($this->menu_handler)) return -1;
@ -201,32 +201,32 @@ class Menubase
if (in_array($this->db->type, array('pgsql'))) if (in_array($this->db->type, array('pgsql')))
{ {
$sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu"; $sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu";
$resqlrowid=$this->db->query($sql); $resqlrowid = $this->db->query($sql);
if ($resqlrowid) { if ($resqlrowid) {
$obj=$this->db->fetch_object($resqlrowid); $obj = $this->db->fetch_object($resqlrowid);
$maxrowid=$obj->maxrowid; $maxrowid = $obj->maxrowid;
// Max rowid can be empty if there is no record yet // Max rowid can be empty if there is no record yet
if(empty($maxrowid)) $maxrowid=1; if (empty($maxrowid)) $maxrowid = 1;
$sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")"; $sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")";
//print $sql; exit; //print $sql; exit;
$resqlrowidset=$this->db->query($sql); $resqlrowidset = $this->db->query($sql);
if (! $resqlrowidset) dol_print_error($this->db); if (!$resqlrowidset) dol_print_error($this->db);
} }
else dol_print_error($this->db); else dol_print_error($this->db);
} }
// Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql // Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql
$sql = "SELECT count(*)"; $sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."menu"; $sql .= " FROM ".MAIN_DB_PREFIX."menu";
$sql.= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'"; $sql .= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'";
$sql.= " AND fk_menu = ".((int) $this->fk_menu); $sql .= " AND fk_menu = ".((int) $this->fk_menu);
$sql.= " AND position = ".((int) $this->position); $sql .= " AND position = ".((int) $this->position);
$sql.= " AND url = '".$this->db->escape($this->url)."'"; $sql .= " AND url = '".$this->db->escape($this->url)."'";
$sql.= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$result=$this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$row = $this->db->fetch_row($result); $row = $this->db->fetch_row($result);
@ -235,45 +235,45 @@ class Menubase
{ {
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."menu("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu(";
$sql.= "menu_handler,"; $sql .= "menu_handler,";
$sql.= "entity,"; $sql .= "entity,";
$sql.= "module,"; $sql .= "module,";
$sql.= "type,"; $sql .= "type,";
$sql.= "mainmenu,"; $sql .= "mainmenu,";
$sql.= "leftmenu,"; $sql .= "leftmenu,";
$sql.= "fk_menu,"; $sql .= "fk_menu,";
$sql.= "fk_mainmenu,"; $sql .= "fk_mainmenu,";
$sql.= "fk_leftmenu,"; $sql .= "fk_leftmenu,";
$sql.= "position,"; $sql .= "position,";
$sql.= "url,"; $sql .= "url,";
$sql.= "target,"; $sql .= "target,";
$sql.= "titre,"; $sql .= "titre,";
$sql.= "langs,"; $sql .= "langs,";
$sql.= "perms,"; $sql .= "perms,";
$sql.= "enabled,"; $sql .= "enabled,";
$sql.= "usertype"; $sql .= "usertype";
$sql.= ") VALUES ("; $sql .= ") VALUES (";
$sql.= " '".$this->db->escape($this->menu_handler)."',"; $sql .= " '".$this->db->escape($this->menu_handler)."',";
$sql.= " '".$this->db->escape($conf->entity)."',"; $sql .= " '".$this->db->escape($conf->entity)."',";
$sql.= " '".$this->db->escape($this->module)."',"; $sql .= " '".$this->db->escape($this->module)."',";
$sql.= " '".$this->db->escape($this->type)."',"; $sql .= " '".$this->db->escape($this->type)."',";
$sql.= " ".($this->mainmenu?"'".$this->db->escape($this->mainmenu)."'":"''").","; // Can't be null $sql .= " ".($this->mainmenu ? "'".$this->db->escape($this->mainmenu)."'" : "''").","; // Can't be null
$sql.= " ".($this->leftmenu?"'".$this->db->escape($this->leftmenu)."'":"null").","; $sql .= " ".($this->leftmenu ? "'".$this->db->escape($this->leftmenu)."'" : "null").",";
$sql.= " ".((int) $this->fk_menu).","; $sql .= " ".((int) $this->fk_menu).",";
$sql.= " ".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").","; $sql .= " ".($this->fk_mainmenu ? "'".$this->db->escape($this->fk_mainmenu)."'" : "null").",";
$sql.= " ".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").","; $sql .= " ".($this->fk_leftmenu ? "'".$this->db->escape($this->fk_leftmenu)."'" : "null").",";
$sql.= " ".((int) $this->position).","; $sql .= " ".((int) $this->position).",";
$sql.= " '".$this->db->escape($this->url)."',"; $sql .= " '".$this->db->escape($this->url)."',";
$sql.= " '".$this->db->escape($this->target)."',"; $sql .= " '".$this->db->escape($this->target)."',";
$sql.= " '".$this->db->escape($this->titre)."',"; $sql .= " '".$this->db->escape($this->titre)."',";
$sql.= " '".$this->db->escape($this->langs)."',"; $sql .= " '".$this->db->escape($this->langs)."',";
$sql.= " '".$this->db->escape($this->perms)."',"; $sql .= " '".$this->db->escape($this->perms)."',";
$sql.= " '".$this->db->escape($this->enabled)."',"; $sql .= " '".$this->db->escape($this->enabled)."',";
$sql.= " '".$this->db->escape($this->user)."'"; $sql .= " '".$this->db->escape($this->user)."'";
$sql.= ")"; $sql .= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu");
@ -283,7 +283,7 @@ class Menubase
} }
else else
{ {
$this->error="Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
} }
@ -312,22 +312,22 @@ class Menubase
//global $conf, $langs; //global $conf, $langs;
// Clean parameters // Clean parameters
$this->rowid=trim($this->rowid); $this->rowid = trim($this->rowid);
$this->menu_handler=trim($this->menu_handler); $this->menu_handler = trim($this->menu_handler);
$this->module=trim($this->module); $this->module = trim($this->module);
$this->type=trim($this->type); $this->type = trim($this->type);
$this->mainmenu=trim($this->mainmenu); $this->mainmenu = trim($this->mainmenu);
$this->leftmenu=trim($this->leftmenu); $this->leftmenu = trim($this->leftmenu);
$this->fk_menu = (int) $this->fk_menu; $this->fk_menu = (int) $this->fk_menu;
$this->fk_mainmenu=trim($this->fk_mainmenu); $this->fk_mainmenu = trim($this->fk_mainmenu);
$this->fk_leftmenu=trim($this->fk_leftmenu); $this->fk_leftmenu = trim($this->fk_leftmenu);
$this->position = (int) $this->position; $this->position = (int) $this->position;
$this->url=trim($this->url); $this->url = trim($this->url);
$this->target=trim($this->target); $this->target = trim($this->target);
$this->titre=trim($this->titre); $this->titre = trim($this->titre);
$this->langs=trim($this->langs); $this->langs = trim($this->langs);
$this->perms=trim($this->perms); $this->perms = trim($this->perms);
$this->enabled=trim($this->enabled); $this->enabled = trim($this->enabled);
$this->user = (int) $this->user; $this->user = (int) $this->user;
// Check parameters // Check parameters
@ -335,29 +335,29 @@ class Menubase
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET";
$sql.= " menu_handler='".$this->db->escape($this->menu_handler)."',"; $sql .= " menu_handler='".$this->db->escape($this->menu_handler)."',";
$sql.= " module='".$this->db->escape($this->module)."',"; $sql .= " module='".$this->db->escape($this->module)."',";
$sql.= " type='".$this->db->escape($this->type)."',"; $sql .= " type='".$this->db->escape($this->type)."',";
$sql.= " mainmenu='".$this->db->escape($this->mainmenu)."',"; $sql .= " mainmenu='".$this->db->escape($this->mainmenu)."',";
$sql.= " leftmenu='".$this->db->escape($this->leftmenu)."',"; $sql .= " leftmenu='".$this->db->escape($this->leftmenu)."',";
$sql.= " fk_menu=".$this->fk_menu.","; $sql .= " fk_menu=".$this->fk_menu.",";
$sql.= " fk_mainmenu=".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").","; $sql .= " fk_mainmenu=".($this->fk_mainmenu ? "'".$this->db->escape($this->fk_mainmenu)."'" : "null").",";
$sql.= " fk_leftmenu=".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").","; $sql .= " fk_leftmenu=".($this->fk_leftmenu ? "'".$this->db->escape($this->fk_leftmenu)."'" : "null").",";
$sql.= " position=".($this->position > 0 ? $this->position : 0).","; $sql .= " position=".($this->position > 0 ? $this->position : 0).",";
$sql.= " url='".$this->db->escape($this->url)."',"; $sql .= " url='".$this->db->escape($this->url)."',";
$sql.= " target='".$this->db->escape($this->target)."',"; $sql .= " target='".$this->db->escape($this->target)."',";
$sql.= " titre='".$this->db->escape($this->titre)."',"; $sql .= " titre='".$this->db->escape($this->titre)."',";
$sql.= " langs='".$this->db->escape($this->langs)."',"; $sql .= " langs='".$this->db->escape($this->langs)."',";
$sql.= " perms='".$this->db->escape($this->perms)."',"; $sql .= " perms='".$this->db->escape($this->perms)."',";
$sql.= " enabled='".$this->db->escape($this->enabled)."',"; $sql .= " enabled='".$this->db->escape($this->enabled)."',";
$sql.= " usertype='".$this->db->escape($this->user)."'"; $sql .= " usertype='".$this->db->escape($this->user)."'";
$sql.= " WHERE rowid=".$this->id; $sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) if (!$resql)
{ {
$this->error="Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
@ -377,37 +377,37 @@ class Menubase
//global $langs; //global $langs;
$sql = "SELECT"; $sql = "SELECT";
$sql.= " t.rowid,"; $sql .= " t.rowid,";
$sql.= " t.menu_handler,"; $sql .= " t.menu_handler,";
$sql.= " t.entity,"; $sql .= " t.entity,";
$sql.= " t.module,"; $sql .= " t.module,";
$sql.= " t.type,"; $sql .= " t.type,";
$sql.= " t.mainmenu,"; $sql .= " t.mainmenu,";
$sql.= " t.leftmenu,"; $sql .= " t.leftmenu,";
$sql.= " t.fk_menu,"; $sql .= " t.fk_menu,";
$sql.= " t.fk_mainmenu,"; $sql .= " t.fk_mainmenu,";
$sql.= " t.fk_leftmenu,"; $sql .= " t.fk_leftmenu,";
$sql.= " t.position,"; $sql .= " t.position,";
$sql.= " t.url,"; $sql .= " t.url,";
$sql.= " t.target,"; $sql .= " t.target,";
$sql.= " t.titre,"; $sql .= " t.titre,";
$sql.= " t.langs,"; $sql .= " t.langs,";
$sql.= " t.perms,"; $sql .= " t.perms,";
$sql.= " t.enabled,"; $sql .= " t.enabled,";
$sql.= " t.usertype as user,"; $sql .= " t.usertype as user,";
$sql.= " t.tms"; $sql .= " t.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as t"; $sql .= " FROM ".MAIN_DB_PREFIX."menu as t";
$sql.= " WHERE t.rowid = ".$id; $sql .= " WHERE t.rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
if ($this->db->num_rows($resql)) if ($this->db->num_rows($resql))
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->menu_handler = $obj->menu_handler; $this->menu_handler = $obj->menu_handler;
$this->entity = $obj->entity; $this->entity = $obj->entity;
@ -434,7 +434,7 @@ class Menubase
} }
else else
{ {
$this->error="Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
} }
@ -451,13 +451,13 @@ class Menubase
//global $conf, $langs; //global $conf, $langs;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
$sql.= " WHERE rowid=".$this->id; $sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) if (!$resql)
{ {
$this->error="Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
@ -474,25 +474,25 @@ class Menubase
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
$this->id=0; $this->id = 0;
$this->menu_handler='all'; $this->menu_handler = 'all';
$this->module='specimen'; $this->module = 'specimen';
$this->type='top'; $this->type = 'top';
$this->mainmenu=''; $this->mainmenu = '';
$this->fk_menu='0'; $this->fk_menu = '0';
$this->position=''; $this->position = '';
$this->url='http://dummy'; $this->url = 'http://dummy';
$this->target=''; $this->target = '';
$this->titre='Specimen menu'; // deprecated $this->titre = 'Specimen menu'; // deprecated
$this->title='Specimen menu'; $this->title = 'Specimen menu';
$this->langs=''; $this->langs = '';
$this->level=''; $this->level = '';
$this->leftmenu=''; $this->leftmenu = '';
$this->perms=''; $this->perms = '';
$this->enabled=''; $this->enabled = '';
$this->user=''; $this->user = '';
$this->tms=''; $this->tms = '';
} }
@ -508,16 +508,16 @@ class Menubase
*/ */
public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
{ {
global $langs, $user, $conf; // To export to dol_eval function global $langs, $user, $conf; // To export to dol_eval function
global $mainmenu,$leftmenu; // To export to dol_eval function global $mainmenu, $leftmenu; // To export to dol_eval function
$mainmenu=$mymainmenu; // To export to dol_eval function $mainmenu = $mymainmenu; // To export to dol_eval function
$leftmenu=$myleftmenu; // To export to dol_eval function $leftmenu = $myleftmenu; // To export to dol_eval function
$newTabMenu=array(); $newTabMenu = array();
foreach($tabMenu as $val) foreach ($tabMenu as $val)
{ {
if ($val['type']=='top') $newTabMenu[]=$val; if ($val['type'] == 'top') $newTabMenu[] = $val;
} }
return $newTabMenu; return $newTabMenu;
@ -537,20 +537,20 @@ class Menubase
*/ */
public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
{ {
global $langs, $user, $conf; // To export to dol_eval function global $langs, $user, $conf; // To export to dol_eval function
global $mainmenu,$leftmenu; // To export to dol_eval function global $mainmenu, $leftmenu; // To export to dol_eval function
$mainmenu=$mymainmenu; // To export to dol_eval function $mainmenu = $mymainmenu; // To export to dol_eval function
$leftmenu=$myleftmenu; // To export to dol_eval function $leftmenu = $myleftmenu; // To export to dol_eval function
// Detect what is top mainmenu id // Detect what is top mainmenu id
$menutopid=''; $menutopid = '';
foreach($tabMenu as $key => $val) foreach ($tabMenu as $key => $val)
{ {
// Define menutopid of mainmenu // Define menutopid of mainmenu
if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu) if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu)
{ {
$menutopid=$val['rowid']; $menutopid = $val['rowid'];
break; break;
} }
} }
@ -562,7 +562,7 @@ class Menubase
$this->recur($tabMenu, $menutopid, 1); $this->recur($tabMenu, $menutopid, 1);
// Now complete $this->newmenu->list when fk_menu value is -1 (left menu added by modules with no top menu) // Now complete $this->newmenu->list when fk_menu value is -1 (left menu added by modules with no top menu)
foreach($tabMenu as $key => $val) foreach ($tabMenu as $key => $val)
{ {
//var_dump($tabMenu); //var_dump($tabMenu);
if ($val['fk_menu'] == -1 && $val['fk_mainmenu'] == $mainmenu) // We found a menu entry not linked to parent with good mainmenu if ($val['fk_menu'] == -1 && $val['fk_mainmenu'] == $mainmenu) // We found a menu entry not linked to parent with good mainmenu
@ -578,16 +578,16 @@ class Menubase
else else
{ {
// Search first menu with this couple (mainmenu,leftmenu)=(fk_mainmenu,fk_leftmenu) // Search first menu with this couple (mainmenu,leftmenu)=(fk_mainmenu,fk_leftmenu)
$searchlastsub=0;$lastid=0;$nextid=0;$found=0; $searchlastsub = 0; $lastid = 0; $nextid = 0; $found = 0;
foreach($this->newmenu->liste as $keyparent => $valparent) foreach ($this->newmenu->liste as $keyparent => $valparent)
{ {
//var_dump($valparent); //var_dump($valparent);
if ($searchlastsub) // If we started to search for last submenu if ($searchlastsub) // If we started to search for last submenu
{ {
if ($valparent['level'] >= $searchlastsub) $lastid=$keyparent; if ($valparent['level'] >= $searchlastsub) $lastid = $keyparent;
if ($valparent['level'] < $searchlastsub) if ($valparent['level'] < $searchlastsub)
{ {
$nextid=$keyparent; $nextid = $keyparent;
break; break;
} }
} }
@ -595,9 +595,9 @@ class Menubase
{ {
//print "We found parent: keyparent='.$keyparent.' - level=".$valparent['level'].' - '.join(',',$valparent).'<br>'; //print "We found parent: keyparent='.$keyparent.' - level=".$valparent['level'].' - '.join(',',$valparent).'<br>';
// Now we look to find last subelement of this parent (we add at end) // Now we look to find last subelement of this parent (we add at end)
$searchlastsub=($valparent['level']+1); $searchlastsub = ($valparent['level'] + 1);
$lastid=$keyparent; $lastid = $keyparent;
$found=1; $found = 1;
} }
} }
//print 'We must insert menu entry between entry '.$lastid.' and '.$nextid.'<br>'; //print 'We must insert menu entry between entry '.$lastid.' and '.$nextid.'<br>';
@ -629,16 +629,16 @@ class Menubase
global $langs, $user, $conf; // To export to dol_eval function global $langs, $user, $conf; // To export to dol_eval function
global $mainmenu, $leftmenu; // To export to dol_eval function global $mainmenu, $leftmenu; // To export to dol_eval function
$mainmenu=$mymainmenu; // To export to dol_eval function $mainmenu = $mymainmenu; // To export to dol_eval function
$leftmenu=$myleftmenu; // To export to dol_eval function $leftmenu = $myleftmenu; // To export to dol_eval function
$sql = "SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position"; $sql = "SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position";
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql.= " WHERE m.entity IN (0,".$conf->entity.")"; $sql .= " WHERE m.entity IN (0,".$conf->entity.")";
$sql.= " AND m.menu_handler IN ('".$menu_handler."','all')"; $sql .= " AND m.menu_handler IN ('".$menu_handler."','all')";
if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)"; if ($type_user == 0) $sql .= " AND m.usertype IN (0,2)";
if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)"; if ($type_user == 1) $sql .= " AND m.usertype IN (1,2)";
$sql.= " ORDER BY m.position, m.rowid"; $sql .= " ORDER BY m.position, m.rowid";
//print $sql; //print $sql;
//dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)."", LOG_DEBUG); //dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)."", LOG_DEBUG);
@ -658,8 +658,8 @@ class Menubase
$perms = true; $perms = true;
if ($menu['perms']) if ($menu['perms'])
{ {
$tmpcond=$menu['perms']; $tmpcond = $menu['perms'];
if ($leftmenu == 'all') $tmpcond=preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true if ($leftmenu == 'all') $tmpcond = preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true
$perms = verifCond($tmpcond); $perms = verifCond($tmpcond);
//print "verifCond rowid=".$menu['rowid']." ".$tmpcond.":".$perms."<br>\n"; //print "verifCond rowid=".$menu['rowid']." ".$tmpcond.":".$perms."<br>\n";
} }
@ -668,19 +668,19 @@ class Menubase
$enabled = true; $enabled = true;
if ($menu['enabled']) if ($menu['enabled'])
{ {
$tmpcond=$menu['enabled']; $tmpcond = $menu['enabled'];
if ($leftmenu == 'all') $tmpcond=preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true if ($leftmenu == 'all') $tmpcond = preg_replace('/\$leftmenu\s*==\s*["\'a-zA-Z_]+/', '1==1', $tmpcond); // Force part of condition to true
$enabled = verifCond($tmpcond); $enabled = verifCond($tmpcond);
} }
// Define $title // Define $title
if ($enabled) if ($enabled)
{ {
$title = $langs->trans($menu['titre']); // If $menu['titre'] start with $, a dol_eval is done. $title = $langs->trans($menu['titre']); // If $menu['titre'] start with $, a dol_eval is done.
//var_dump($title.'-'.$menu['titre']); //var_dump($title.'-'.$menu['titre']);
if ($title == $menu['titre']) // Translation not found if ($title == $menu['titre']) // Translation not found
{ {
if (! empty($menu['langs'])) // If there is a dedicated translation file if (!empty($menu['langs'])) // If there is a dedicated translation file
{ {
//print 'Load file '.$menu['langs'].'<br>'; //print 'Load file '.$menu['langs'].'<br>';
$langs->load($menu['langs']); $langs->load($menu['langs']);
@ -715,10 +715,10 @@ class Menubase
$tabMenu[$b]['module'] = $menu['module']; $tabMenu[$b]['module'] = $menu['module'];
$tabMenu[$b]['fk_menu'] = $menu['fk_menu']; $tabMenu[$b]['fk_menu'] = $menu['fk_menu'];
$tabMenu[$b]['url'] = $menu['url']; $tabMenu[$b]['url'] = $menu['url'];
if (! preg_match("/^(http:\/\/|https:\/\/)/i", $tabMenu[$b]['url'])) if (!preg_match("/^(http:\/\/|https:\/\/)/i", $tabMenu[$b]['url']))
{ {
if (preg_match('/\?/', $tabMenu[$b]['url'])) $tabMenu[$b]['url'].='&amp;idmenu='.$menu['rowid']; if (preg_match('/\?/', $tabMenu[$b]['url'])) $tabMenu[$b]['url'] .= '&amp;idmenu='.$menu['rowid'];
else $tabMenu[$b]['url'].='?idmenu='.$menu['rowid']; else $tabMenu[$b]['url'] .= '?idmenu='.$menu['rowid'];
} }
$tabMenu[$b]['titre'] = $title; $tabMenu[$b]['titre'] = $title;
$tabMenu[$b]['target'] = $menu['target']; $tabMenu[$b]['target'] = $menu['target'];
@ -767,10 +767,10 @@ class Menubase
for ($x = 0; $x < $num; $x++) for ($x = 0; $x < $num; $x++)
{ {
//si un element a pour pere : $pere //si un element a pour pere : $pere
if ( (($tab[$x]['fk_menu'] >= 0 && $tab[$x]['fk_menu'] == $pere)) && $tab[$x]['enabled']) if ((($tab[$x]['fk_menu'] >= 0 && $tab[$x]['fk_menu'] == $pere)) && $tab[$x]['enabled'])
{ {
$this->newmenu->add($tab[$x]['url'], $tab[$x]['titre'], ($level-1), $tab[$x]['perms'], $tab[$x]['target'], $tab[$x]['mainmenu'], $tab[$x]['leftmenu']); $this->newmenu->add($tab[$x]['url'], $tab[$x]['titre'], ($level - 1), $tab[$x]['perms'], $tab[$x]['target'], $tab[$x]['mainmenu'], $tab[$x]['leftmenu']);
$this->recur($tab, $tab[$x]['rowid'], ($level+1)); $this->recur($tab, $tab[$x]['rowid'], ($level + 1));
} }
} }
} }

View File

@ -3911,9 +3911,9 @@ function dol_print_error($db = '', $error = '', $errors = null)
} }
if (empty($dolibarr_main_prod)) print $out; if (empty($dolibarr_main_prod)) print $out;
else else // This should not happen, except if there is a bug somewhere. Enabled and check log in such case.
{ {
print 'This website is currently temporarly offline. This may be due to a maintenance operation. Current status of operation are on next line...<br><br>'."\n"; print 'This website is currently temporarly offline.<br><br>This may be due to a maintenance operation. Current status of operation are on next line...<br><br>'."\n";
$langs->load("errors"); $langs->load("errors");
print $langs->trans("DolibarrHasDetectedError").'. '; print $langs->trans("DolibarrHasDetectedError").'. ';
print $langs->trans("YouCanSetOptionDolibarrMainProdToZero"); print $langs->trans("YouCanSetOptionDolibarrMainProdToZero");

View File

@ -42,9 +42,9 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
global $db, $langs; global $db, $langs;
if (empty($objectname)) return -1; if (empty($objectname)) return -1;
if (empty($readdir)) $readdir=$destdir; if (empty($readdir)) $readdir = $destdir;
if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval']))
{ {
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.'); dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
return -1; return -1;
@ -63,17 +63,17 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2; return -2;
} }
if (! preg_match('/^(integer|price|sellist|date|varchar|double|text|html)/', $addfieldentry['type']) if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
&& ! preg_match('/^(boolean|real|timestamp)$/', $addfieldentry['type'])) && !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
{ {
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors'); setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
return -2; return -2;
} }
} }
$pathoffiletoeditsrc=$readdir.'/class/'.strtolower($objectname).'.class.php'; $pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
$pathoffiletoedittarget=$destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : ''); $pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
if (! dol_is_file($pathoffiletoeditsrc)) if (!dol_is_file($pathoffiletoeditsrc))
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors'); setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
@ -86,7 +86,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
try try
{ {
include_once $pathoffiletoeditsrc; include_once $pathoffiletoeditsrc;
if (class_exists($objectname)) $object=new $objectname($db); if (class_exists($objectname)) $object = new $objectname($db);
else return -4; else return -4;
// Backup old file // Backup old file
@ -100,86 +100,86 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
{ {
if (is_array($addfieldentry) && count($addfieldentry)) if (is_array($addfieldentry) && count($addfieldentry))
{ {
$name=$addfieldentry['name']; $name = $addfieldentry['name'];
unset($addfieldentry['name']); unset($addfieldentry['name']);
$object->fields[$name]=$addfieldentry; $object->fields[$name] = $addfieldentry;
} }
if (! empty($delfieldentry)) if (!empty($delfieldentry))
{ {
$name=$delfieldentry; $name = $delfieldentry;
unset($object->fields[$name]); unset($object->fields[$name]);
} }
} }
dol_sort_array($object->fields, 'position'); dol_sort_array($object->fields, 'position');
$i=0; $i = 0;
$texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n"; $texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
$texttoinsert.= "\t".'/**'."\n"; $texttoinsert .= "\t".'/**'."\n";
$texttoinsert.= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n"; $texttoinsert .= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n";
$texttoinsert.= "\t".' */'."\n"; $texttoinsert .= "\t".' */'."\n";
$texttoinsert.= "\t".'public $fields=array('."\n"; $texttoinsert .= "\t".'public $fields=array('."\n";
if (count($object->fields)) if (count($object->fields))
{ {
foreach($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
$i++; $i++;
$texttoinsert.= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; $texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
$texttoinsert.= " 'enabled'=>".($val['enabled']!=''?$val['enabled']:1).","; $texttoinsert .= " 'enabled'=>".($val['enabled'] != '' ? $val['enabled'] : 1).",";
$texttoinsert.= " 'position'=>".($val['position']!=''?$val['position']:50).","; $texttoinsert .= " 'position'=>".($val['position'] != '' ? $val['position'] : 50).",";
$texttoinsert.= " 'notnull'=>".(empty($val['notnull'])?0:$val['notnull']).","; $texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
$texttoinsert.= " 'visible'=>".($val['visible']!=''?$val['visible']:-1).","; $texttoinsert .= " 'visible'=>".($val['visible'] != '' ? $val['visible'] : -1).",";
if ($val['noteditable']) $texttoinsert.= " 'noteditable'=>'".$val['noteditable']."',"; if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
if ($val['default']) $texttoinsert.= " 'default'=>'".$val['default']."',"; if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
if ($val['index']) $texttoinsert.= " 'index'=>".$val['index'].","; if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
if ($val['foreignkey']) $texttoinsert.= " 'foreignkey'=>'".$val['foreignkey']."',"; if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
if ($val['searchall']) $texttoinsert.= " 'searchall'=>".$val['searchall'].","; if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
if ($val['isameasure']) $texttoinsert.= " 'isameasure'=>'".$val['isameasure']."',"; if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
if ($val['css']) $texttoinsert.= " 'css'=>'".$val['css']."',"; if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
if ($val['help']) $texttoinsert.= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\","; if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
if ($val['showoncombobox']) $texttoinsert.= " 'showoncombobox'=>'".$val['showoncombobox']."',"; if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
if ($val['disabled']) $texttoinsert.= " 'disabled'=>'".$val['disabled']."',"; if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
if ($val['arrayofkeyval']) if ($val['arrayofkeyval'])
{ {
$texttoinsert.= " 'arrayofkeyval'=>array("; $texttoinsert .= " 'arrayofkeyval'=>array(";
$i=0; $i = 0;
foreach($val['arrayofkeyval'] as $key2 => $val2) foreach ($val['arrayofkeyval'] as $key2 => $val2)
{ {
if ($i) $texttoinsert.=", "; if ($i) $texttoinsert .= ", ";
$texttoinsert.="'".$key2."'=>'".$val2."'"; $texttoinsert .= "'".$key2."'=>'".$val2."'";
$i++; $i++;
} }
$texttoinsert.= "),"; $texttoinsert .= "),";
} }
if ($val['comment']) $texttoinsert.= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\""; if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
$texttoinsert.= "),\n"; $texttoinsert .= "),\n";
} }
} }
$texttoinsert.= "\t".');'."\n"; $texttoinsert .= "\t".');'."\n";
//print ($texttoinsert);exit; //print ($texttoinsert);exit;
if (count($object->fields)) if (count($object->fields))
{ {
$typetotypephp=array('integer'=>'integer', 'varchar'=>'string'); //$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
foreach($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
$i++; $i++;
//$typephp=$typetotypephp[$val['type']]; //$typephp=$typetotypephp[$val['type']];
$texttoinsert.= "\t".'public $'.$key.";"; $texttoinsert .= "\t".'public $'.$key.";";
//if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; //if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
//if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; //if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
//$texttoinsert.= ($val['notnull']?' NOT NULL':''); //$texttoinsert.= ($val['notnull']?' NOT NULL':'');
//if ($i < count($object->fields)) $texttoinsert.=";"; //if ($i < count($object->fields)) $texttoinsert.=";";
$texttoinsert.= "\n"; $texttoinsert .= "\n";
} }
} }
$texttoinsert.= "\t".'// END MODULEBUILDER PROPERTIES'; $texttoinsert .= "\t".'// END MODULEBUILDER PROPERTIES';
//print($texttoinsert);exit; //print($texttoinsert);exit;
@ -193,7 +193,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
return $object; return $object;
} }
catch(Exception $e) catch (Exception $e)
{ {
print $e->getMessage(); print $e->getMessage();
return -5; return -5;
@ -219,14 +219,14 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
$error = 0; $error = 0;
if (empty($objectname)) return -1; if (empty($objectname)) return -1;
if (empty($readdir)) $readdir=$destdir; if (empty($readdir)) $readdir = $destdir;
$pathoffiletoclasssrc=$readdir.'/class/'.strtolower($objectname).'.class.php'; $pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
// Edit .sql file // Edit .sql file
$pathoffiletoeditsrc=$readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'; $pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
$pathoffiletoedittarget=$destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : ''); $pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
if (! dol_is_file($pathoffiletoeditsrc)) if (!dol_is_file($pathoffiletoeditsrc))
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors'); setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
@ -236,14 +236,14 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
// Load object from myobject.class.php // Load object from myobject.class.php
try try
{ {
if (! is_object($object)) if (!is_object($object))
{ {
include_once $pathoffiletoclasssrc; include_once $pathoffiletoclasssrc;
if (class_exists($objectname)) $object=new $objectname($db); if (class_exists($objectname)) $object = new $objectname($db);
else return -1; else return -1;
} }
} }
catch(Exception $e) catch (Exception $e)
{ {
print $e->getMessage(); print $e->getMessage();
} }
@ -253,38 +253,38 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r'); $contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$i=0; $i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n"; $texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
if (count($object->fields)) if (count($object->fields))
{ {
foreach($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
$i++; $i++;
$type = $val['type']; $type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php' $type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
elseif ($type == 'link' || $type == 'sellist') $type = 'integer'; elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
$texttoinsert.= "\t".$key." ".$type; $texttoinsert .= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
else else
{ {
if ($val['default'] != '') if ($val['default'] != '')
{ {
if (preg_match('/^null$/i', $val['default'])) $texttoinsert.= " DEFAULT NULL"; if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
elseif (preg_match('/varchar/', $type)) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'"; elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
else $texttoinsert.= (($val['default'] > 0)?' DEFAULT '.$val['default']:''); else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
} }
} }
$texttoinsert.= (($val['notnull'] > 0)?' NOT NULL':''); $texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
if ($i < count($object->fields)) $texttoinsert.=", "; if ($i < count($object->fields)) $texttoinsert .= ", ";
$texttoinsert.= "\n"; $texttoinsert .= "\n";
} }
} }
$texttoinsert.= "\t".'-- END MODULEBUILDER FIELDS'; $texttoinsert .= "\t".'-- END MODULEBUILDER FIELDS';
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql); $contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
@ -299,35 +299,35 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
} }
// Edit .key.sql file // Edit .key.sql file
$pathoffiletoeditsrc=$destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'; $pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
$pathoffiletoedittarget=$destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : ''); $pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r'); $contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$i=0; $i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n"; $texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
if (count($object->fields)) if (count($object->fields))
{ {
foreach($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
$i++; $i++;
if (! empty($val['index'])) if (!empty($val['index']))
{ {
$texttoinsert.= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");"; $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
$texttoinsert.= "\n"; $texttoinsert .= "\n";
} }
if (! empty($val['foreignkey'])) if (!empty($val['foreignkey']))
{ {
$tmp=explode('.', $val['foreignkey']); $tmp = explode('.', $val['foreignkey']);
if (! empty($tmp[0]) && ! empty($tmp[1])) if (!empty($tmp[0]) && !empty($tmp[1]))
{ {
$texttoinsert.= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES ".$tmp[0]."(".$tmp[1].");"; $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES ".$tmp[0]."(".$tmp[1].");";
$texttoinsert.= "\n"; $texttoinsert .= "\n";
} }
} }
} }
} }
$texttoinsert.= '-- END MODULEBUILDER INDEXES'; $texttoinsert .= '-- END MODULEBUILDER INDEXES';
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql); $contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql);

View File

@ -422,7 +422,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
if (! empty($objectid) && $objectid > 0) if (! empty($objectid) && $objectid > 0)
{ {
$ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select);
return $ok ? 1 : accessforbidden(); $params=array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2);
return $ok ? 1 : accessforbidden('', 1, 1, 0, $params);
} }
return 1; return 1;
@ -660,13 +661,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
* Show a message to say access is forbidden and stop program * Show a message to say access is forbidden and stop program
* Calling this function terminate execution of PHP. * Calling this function terminate execution of PHP.
* *
* @param string $message Force error message * @param string $message Force error message
* @param int $printheader Show header before * @param int $printheader Show header before
* @param int $printfooter Show footer after * @param int $printfooter Show footer after
* @param int $showonlymessage Show only message parameter. Otherwise add more information. * @param int $showonlymessage Show only message parameter. Otherwise add more information.
* @param array|null $params Send params
* @return void * @return void
*/ */
function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0) function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null)
{ {
global $conf, $db, $user, $langs, $hookmanager; global $conf, $db, $user, $langs, $hookmanager;
if (! is_object($langs)) if (! is_object($langs))
@ -697,7 +699,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('main')); $hookmanager->initHooks(array('main'));
} }
$parameters = array('message'=>$message); $parameters = array('message'=>$message, 'params'=>$params);
$reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))

View File

@ -508,7 +508,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
$title = $langs->trans("GoIntoSetupToChangeLogo"); $title = $langs->trans("GoIntoSetupToChangeLogo");
print "\n".'<!-- Show logo on menu -->'."\n"; print "\n".'<!-- Show logo on menu -->'."\n";
print_start_menu_entry('companylogo', 'class="tmenu tmenucompanylogo"', 1); print_start_menu_entry('companylogo', 'class="tmenu tmenucompanylogo nohover"', 1);
print '<div class="center '.$logoContainerAdditionalClass.' menulogocontainer"><img class="mycompany" title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 100px"></div>'."\n"; print '<div class="center '.$logoContainerAdditionalClass.' menulogocontainer"><img class="mycompany" title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 100px"></div>'."\n";

View File

@ -264,12 +264,12 @@ class modEmailCollector extends DolibarrModules
*/ */
public function init($options = '') public function init($options = '')
{ {
global $conf, $user;
//$this->_load_tables('/dav/sql/'); //$this->_load_tables('/dav/sql/');
// Create extrafields // Create extrafields
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db); //$extrafields = new ExtraFields($this->db);
//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled'); //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled'); //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled'); //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
@ -278,6 +278,60 @@ class modEmailCollector extends DolibarrModules
$sql = array(); $sql = array();
$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity;
$tmpresql = $this->db->query($tmpsql);
if ($tmpresql) {
if ($this->db->num_rows($tmpresql) == 0) {
$sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
$sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requets', 'Example to collect ticket requests', 'This collector will scan your mailbox to find emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from the ticket, you may also see answers of your customers or partners directly on the ticket view.', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
$sqlforexampleA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
$sqlforexampleA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
$sqlforexampleA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";
$sqlforexampleA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
$sqlforexampleA4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";
$sqlforexampleA4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'ticket', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
$sql[] = $sqlforexampleA1;
$sql[] = $sqlforexampleA2;
$sql[] = $sqlforexampleA3;
$sql[] = $sqlforexampleA4;
}
} else dol_print_error($this->db);
$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity;
$tmpresql = $this->db->query($tmpsql);
if ($tmpresql) {
if ($this->db->num_rows($tmpresql) == 0) {
$sqlforexampleB1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
$sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses', 'Example to collect any email responses', 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event with the email response will be recorded at the good place (Module Agenda must be enabled). For example, if your send a commercial proposal, order or invoice by email and your customer answers your email, the system will automatically find the answer and add it into your ERP.', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
$sqlforexampleB2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
$sqlforexampleB2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity."), 'withtrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
$sqlforexampleB3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";
$sqlforexampleB3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity."), 'recordevent', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
$sql[] = $sqlforexampleB1;
$sql[] = $sqlforexampleB2;
$sql[] = $sqlforexampleB3;
}
} else dol_print_error($this->db);
$tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity;
$tmpresql = $this->db->query($tmpsql);
if ($tmpresql) {
if ($this->db->num_rows($tmpresql) == 0) {
$sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
$sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', 'Example to collect leads', 'This collector will scan your mailbox to find emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.<br>Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can''t be found in database (new customer), the lead will be attached to the thirdparty with ID 1.', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
$sqlforexampleC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
$sqlforexampleC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
$sqlforexampleC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";
$sqlforexampleC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'to', 'sales@example.com', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
$sqlforexampleC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)";
$sqlforexampleC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'project', 'tmp_aaa=EXTRACT:HEADER:^From:(.*);description=EXTRACT:BODY:(.*);title=SET:Lead or message by __tmp_aaa__ receivied by email;socid=SETIFEMPTY:1', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
$sql[] = $sqlforexampleC1;
$sql[] = $sqlforexampleC2;
$sql[] = $sqlforexampleC3;
$sql[] = $sqlforexampleC4;
}
} else dol_print_error($this->db);
return $this->_init($sql, $options); return $this->_init($sql, $options);
} }

View File

@ -35,7 +35,6 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
*/ */
class modExpedition extends DolibarrModules class modExpedition extends DolibarrModules
{ {
/** /**
* Constructor. Define names, constants, directories, boxes, permissions * Constructor. Define names, constants, directories, boxes, permissions
* *
@ -133,7 +132,9 @@ class modExpedition extends DolibarrModules
$r++; $r++;
// Boxes // Boxes
$this->boxes = array(); $this->boxes = array(
0=>array('file'=>'box_shipments.php','enabledbydefaulton'=>'Home'),
);
// Permissions // Permissions
$this->rights = array(); $this->rights = array();
@ -187,7 +188,7 @@ class modExpedition extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 1101; $this->rights[$r][0] = 1101;
$this->rights[$r][1] = 'Lire les bons de livraison'; $this->rights[$r][1] = 'Read delivery receipts';
$this->rights[$r][2] = 'r'; $this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison'; $this->rights[$r][4] = 'livraison';
@ -195,7 +196,7 @@ class modExpedition extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 1102; $this->rights[$r][0] = 1102;
$this->rights[$r][1] = 'Creer modifier les bons de livraison'; $this->rights[$r][1] = 'Create/modify delivery receipts';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison'; $this->rights[$r][4] = 'livraison';
@ -203,7 +204,7 @@ class modExpedition extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 1104; $this->rights[$r][0] = 1104;
$this->rights[$r][1] = 'Valider les bons de livraison'; $this->rights[$r][1] = 'Validate delivery receipts';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison_advance'; $this->rights[$r][4] = 'livraison_advance';
@ -211,7 +212,7 @@ class modExpedition extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 1109; $this->rights[$r][0] = 1109;
$this->rights[$r][1] = 'Supprimer les bons de livraison'; $this->rights[$r][1] = 'Delete delivery receipts';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison'; $this->rights[$r][4] = 'livraison';

View File

@ -269,4 +269,45 @@ class modHoliday extends DolibarrModules
// $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
// $r++; // $r++;
} }
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function init($options = '')
{
global $conf;
// Permissions
$this->remove($options);
//ODT template
/*$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/holiday/template_holiday.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/holiday';
$dest=$dirodt.'/template_order.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
$result=dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}
$sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".$conf->entity,
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".$conf->entity.")"
);*/
return $this->_init($sql, $options);
}
} }

View File

@ -29,70 +29,70 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("products","other")); $langs->loadLangs(array("products", "other"));
$id=GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$action=GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$modulepart=GETPOST('modulepart', 'alpha')?GETPOST('modulepart', 'alpha'):'produit|service'; $modulepart = GETPOST('modulepart', 'alpha') ?GETPOST('modulepart', 'alpha') : 'produit|service';
$original_file = GETPOST("file"); $original_file = GETPOST("file");
$backtourl=GETPOST('backtourl'); $backtourl = GETPOST('backtourl');
$cancel=GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
// Security check // Security check
if (empty($modulepart)) accessforbidden('Bad value for modulepart'); if (empty($modulepart)) accessforbidden('Bad value for modulepart');
$accessallowed=0; $accessallowed = 0;
if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service')
{ {
$result=restrictedArea($user, 'produit|service', $id, 'product&product'); $result = restrictedArea($user, 'produit|service', $id, 'product&product');
if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); if ($modulepart == 'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) accessforbidden();
$accessallowed=1; $accessallowed = 1;
} }
elseif ($modulepart == 'project') elseif ($modulepart == 'project')
{ {
$result=restrictedArea($user, 'projet', $id); $result = restrictedArea($user, 'projet', $id);
if (! $user->rights->projet->lire) accessforbidden(); if (!$user->rights->projet->lire) accessforbidden();
$accessallowed=1; $accessallowed = 1;
} }
elseif ($modulepart == 'bom') elseif ($modulepart == 'bom')
{ {
$result=restrictedArea($user, $modulepart, $id, 'bom_bom'); $result = restrictedArea($user, $modulepart, $id, 'bom_bom');
if (! $user->rights->bom->read) accessforbidden(); if (!$user->rights->bom->read) accessforbidden();
$accessallowed=1; $accessallowed = 1;
} }
elseif ($modulepart == 'member') elseif ($modulepart == 'member')
{ {
$result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); $result = restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid');
if (! $user->rights->adherent->lire) accessforbidden(); if (!$user->rights->adherent->lire) accessforbidden();
$accessallowed=1; $accessallowed = 1;
} }
elseif ($modulepart == 'user') elseif ($modulepart == 'user')
{ {
$result=restrictedArea($user, $modulepart, $id, $modulepart); $result = restrictedArea($user, $modulepart, $id, $modulepart);
if (! $user->rights->user->user->lire) accessforbidden(); if (!$user->rights->user->user->lire) accessforbidden();
$accessallowed=1; $accessallowed = 1;
} }
elseif ($modulepart == 'tax') elseif ($modulepart == 'tax')
{ {
$result=restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges'); $result = restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges');
if (! $user->rights->tax->charges->lire) accessforbidden(); if (!$user->rights->tax->charges->lire) accessforbidden();
$accessallowed=1; $accessallowed = 1;
} }
elseif ($modulepart == 'bank') elseif ($modulepart == 'bank')
{ {
$result=restrictedArea($user, 'banque', $id, 'bank_account'); $result = restrictedArea($user, 'banque', $id, 'bank_account');
if (! $user->rights->banque->lire) accessforbidden(); if (!$user->rights->banque->lire) accessforbidden();
$accessallowed=1; $accessallowed = 1;
} }
else // ticket, holiday, expensereport, societe... else // ticket, holiday, expensereport, societe...
{ {
$result=restrictedArea($user, $modulepart, $id, $modulepart); $result = restrictedArea($user, $modulepart, $id, $modulepart);
if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) accessforbidden(); if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) accessforbidden();
$accessallowed=1; $accessallowed = 1;
} }
// Security: // Security:
// Limit access if permissions are wrong // Limit access if permissions are wrong
if (! $accessallowed) if (!$accessallowed)
{ {
accessforbidden(); accessforbidden();
} }
@ -106,9 +106,9 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->product->multidir_output[$object->entity]; // By default $dir = $conf->product->multidir_output[$object->entity]; // By default
if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; if ($object->type == Product::TYPE_PRODUCT) $dir = $conf->product->multidir_output[$object->entity];
if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; if ($object->type == Product::TYPE_SERVICE) $dir = $conf->service->multidir_output[$object->entity];
} }
} }
elseif ($modulepart == 'project') elseif ($modulepart == 'project')
@ -119,7 +119,7 @@ elseif ($modulepart == 'project')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->projet->dir_output; // By default $dir = $conf->projet->dir_output; // By default
} }
} }
elseif ($modulepart == 'holiday') elseif ($modulepart == 'holiday')
@ -130,7 +130,7 @@ elseif ($modulepart == 'holiday')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default $dir = $conf->$modulepart->dir_output; // By default
} }
} }
elseif ($modulepart == 'member') elseif ($modulepart == 'member')
@ -141,7 +141,7 @@ elseif ($modulepart == 'member')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->adherent->dir_output; // By default $dir = $conf->adherent->dir_output; // By default
} }
} }
elseif ($modulepart == 'societe') elseif ($modulepart == 'societe')
@ -152,7 +152,7 @@ elseif ($modulepart == 'societe')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; $dir = $conf->$modulepart->dir_output;
} }
} }
elseif ($modulepart == 'user') elseif ($modulepart == 'user')
@ -163,7 +163,7 @@ elseif ($modulepart == 'user')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default $dir = $conf->$modulepart->dir_output; // By default
} }
} }
elseif ($modulepart == 'expensereport') elseif ($modulepart == 'expensereport')
@ -174,7 +174,7 @@ elseif ($modulepart == 'expensereport')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->expensereport->dir_output; // By default $dir = $conf->expensereport->dir_output; // By default
} }
} }
elseif ($modulepart == 'tax') elseif ($modulepart == 'tax')
@ -185,7 +185,7 @@ elseif ($modulepart == 'tax')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default $dir = $conf->$modulepart->dir_output; // By default
} }
} }
elseif ($modulepart == 'ticket') elseif ($modulepart == 'ticket')
@ -196,7 +196,7 @@ elseif ($modulepart == 'ticket')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default $dir = $conf->$modulepart->dir_output; // By default
} }
} }
elseif ($modulepart == 'bom') elseif ($modulepart == 'bom')
@ -207,7 +207,7 @@ elseif ($modulepart == 'bom')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->$modulepart->dir_output; // By default $dir = $conf->$modulepart->dir_output; // By default
} }
} }
elseif ($modulepart == 'bank') elseif ($modulepart == 'bank')
@ -218,7 +218,7 @@ elseif ($modulepart == 'bank')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object'); if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->bank->dir_output; // By default $dir = $conf->bank->dir_output; // By default
} }
} }
else { else {
@ -227,17 +227,17 @@ else {
if (empty($backtourl)) if (empty($backtourl))
{ {
if (in_array($modulepart, array('product','produit','service','produit|service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); if (in_array($modulepart, array('product', 'produit', 'service', 'produit|service'))) $backtourl = DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('expensereport'))) $backtourl = DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
elseif (in_array($modulepart, array('bank'))) $backtourl=DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
else $backtourl=DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]); else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]);
} }
@ -261,9 +261,9 @@ if ($cancel)
if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != ""))
{ {
$fullpath=$dir."/".$original_file; $fullpath = $dir."/".$original_file;
$result=dol_imageResizeOrCrop($fullpath, 0, $_POST['sizex'], $_POST['sizey']); $result = dol_imageResizeOrCrop($fullpath, 0, $_POST['sizex'], $_POST['sizey']);
if ($result == $fullpath) if ($result == $fullpath)
{ {
@ -274,7 +274,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
$rel_filename = preg_replace('/^[\\/]/', '', $rel_filename); $rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db); $ecmfile = new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filename); $result = $ecmfile->fetch(0, '', $rel_filename);
if ($result > 0) // If found if ($result > 0) // If found
{ {
@ -295,11 +295,11 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
$ecmfile->filepath = $rel_dir; $ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename; $ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->fullpath_orig = $fullpath; $ecmfile->fullpath_orig = $fullpath;
$ecmfile->gen_or_uploaded = 'unknown'; $ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content $ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content $ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user); $result = $ecmfile->create($user);
if ($result < 0) if ($result < 0)
{ {
@ -322,18 +322,18 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
else else
{ {
setEventMessages($result, null, 'errors'); setEventMessages($result, null, 'errors');
$_GET['file']=$_POST["file"]; $_GET['file'] = $_POST["file"];
$action=''; $action = '';
} }
} }
// Crop d'une image // Crop d'une image
if ($action == 'confirm_crop') if ($action == 'confirm_crop')
{ {
$fullpath=$dir."/".$original_file; $fullpath = $dir."/".$original_file;
//var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit;
$result=dol_imageResizeOrCrop($fullpath, 1, $_POST['w'], $_POST['h'], $_POST['x'], $_POST['y']); $result = dol_imageResizeOrCrop($fullpath, 1, $_POST['w'], $_POST['h'], $_POST['x'], $_POST['y']);
if ($result == $fullpath) if ($result == $fullpath)
{ {
@ -344,7 +344,7 @@ if ($action == 'confirm_crop')
$rel_filename = preg_replace('/^[\\/]/', '', $rel_filename); $rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($db); $ecmfile = new EcmFiles($db);
$result = $ecmfile->fetch(0, '', $rel_filename); $result = $ecmfile->fetch(0, '', $rel_filename);
if ($result > 0) // If found if ($result > 0) // If found
{ {
@ -365,11 +365,11 @@ if ($action == 'confirm_crop')
$ecmfile->filepath = $rel_dir; $ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename; $ecmfile->filename = $filename;
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
$ecmfile->fullpath_orig = $fullpath; $ecmfile->fullpath_orig = $fullpath;
$ecmfile->gen_or_uploaded = 'unknown'; $ecmfile->gen_or_uploaded = 'unknown';
$ecmfile->description = ''; // indexed content $ecmfile->description = ''; // indexed content
$ecmfile->keyword = ''; // keyword content $ecmfile->keyword = ''; // keyword content
$result = $ecmfile->create($user); $result = $ecmfile->create($user);
if ($result < 0) if ($result < 0)
{ {
@ -392,8 +392,8 @@ if ($action == 'confirm_crop')
else else
{ {
setEventMessages($result, null, 'errors'); setEventMessages($result, null, 'errors');
$_GET['file']=$_POST["file"]; $_GET['file'] = $_POST["file"];
$action=''; $action = '';
} }
} }
@ -402,14 +402,14 @@ if ($action == 'confirm_crop')
* View * View
*/ */
llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js','/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css')); llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js', '/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css'));
print load_fiche_titre($langs->trans("ImageEditor")); print load_fiche_titre($langs->trans("ImageEditor"));
$infoarray=dol_getImageSize($dir."/".GETPOST("file", 'alpha')); $infoarray = dol_getImageSize($dir."/".GETPOST("file", 'alpha'));
$height=$infoarray['height']; $height = $infoarray['height'];
$width=$infoarray['width']; $width = $infoarray['width'];
print $langs->trans("CurrentInformationOnImage").': '; print $langs->trans("CurrentInformationOnImage").': ';
print $langs->trans("Width").': <strong>'.$width.'</strong> x '.$langs->trans("Height").': <strong>'.$height.'</strong><br>'; print $langs->trans("Width").': <strong>'.$width.'</strong> x '.$langs->trans("Height").': <strong>'.$height.'</strong><br>';
@ -450,18 +450,18 @@ print '<br>'."\n";
print '<br>'."\n"; print '<br>'."\n";
if (! empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax))
{ {
$infoarray=dol_getImageSize($dir."/".GETPOST("file")); $infoarray = dol_getImageSize($dir."/".GETPOST("file"));
$height=$infoarray['height']; $height = $infoarray['height'];
$width=$infoarray['width']; $width = $infoarray['width'];
$widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1; $widthforcrop = $width; $refsizeforcrop = 'orig'; $ratioforcrop = 1;
// If image is too large, we use another scale. // If image is too large, we use another scale.
if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2))) if (!empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth'] / 2)))
{ {
$ratioforcrop=2; $ratioforcrop = 2;
$widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop); $widthforcrop = round($_SESSION['dol_screenwidth'] / $ratioforcrop);
$refsizeforcrop='screenwidth'; $refsizeforcrop = 'screenwidth';
} }
print '<!-- Form to crop -->'."\n"; print '<!-- Form to crop -->'."\n";

View File

@ -91,7 +91,7 @@ $(document).ready(function () {
<form id="login" name="login" method="post" action="<?php echo $php_self; ?>"> <form id="login" name="login" method="post" action="<?php echo $php_self; ?>">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" /> <input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<input type="hidden" name="action" value="login"> <input type="hidden" name="actionlogin" value="login">
<input type="hidden" name="loginfunction" value="loginfunction" /> <input type="hidden" name="loginfunction" value="loginfunction" />
<!-- Add fields to send local user information --> <!-- Add fields to send local user information -->
<input type="hidden" name="tz" id="tz" value="" /> <input type="hidden" name="tz" id="tz" value="" />

View File

@ -455,7 +455,7 @@ if ($action == 'create')
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '</tbody>'; print '</tbody>';
@ -589,7 +589,7 @@ if (!empty($id) && $action == 'edit')
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print "</table>\n"; print "</table>\n";

View File

@ -667,22 +667,56 @@ class EmailCollector extends CommonObject
/** /**
* Return the connectstring to use with IMAP connection function * Return the connectstring to use with IMAP connection function
* *
* @param int $ssl Add /ssl tag
* @param int $norsh Add /norsh to connectstring
* @return string * @return string
*/ */
public function getConnectStringIMAP() public function getConnectStringIMAP($ssl = 1, $norsh = 0)
{ {
global $conf;
// Connect to IMAP // Connect to IMAP
$flags = '/service=imap'; // IMAP $flags = '/service=imap'; // IMAP
$flags .= '/ssl'; // '/tls' if ($ssl) $flags .= '/ssl'; // '/tls'
$flags .= '/novalidate-cert'; $flags .= '/novalidate-cert';
//$flags.='/readonly'; //$flags.='/readonly';
//$flags.='/debug'; //$flags.='/debug';
if ($norsh || ! empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh';
$connectstringserver = '{'.$this->host.':993'.$flags.'}'; $connectstringserver = '{'.$this->host.':993'.$flags.'}';
return $connectstringserver; return $connectstringserver;
} }
/**
* Convert str to UTF-7 imap default mailbox names
*
* @param string $str String to encode
* @return string Encode string
*/
public function getEncodedUtf7($str)
{
if (function_exists('mb_convert_encoding')) {
// change spaces by entropy because mb_convert fail with spaces
$str=preg_replace("/ /", "xyxy", $str);
// if mb_convert work
if ($str = mb_convert_encoding($str, "UTF-7")) {
// change characters
$str=preg_replace("/\+A/", "&A", $str);
// change to spaces again
$str=preg_replace("/xyxy/", " ", $str);
return $str;
} else {
// print error and return false
$this->error = "error: is not possible to encode this string '".$str."'";
return false;
}
}
else {
return $str;
}
}
/** /**
* Action executed by scheduler * Action executed by scheduler
* CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters' * CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters'
@ -854,7 +888,7 @@ class EmailCollector extends CommonObject
dol_syslog("EmailCollector::doCollectOneCollector start", LOG_DEBUG); dol_syslog("EmailCollector::doCollectOneCollector start", LOG_DEBUG);
$langs->loadLangs(array("project", "companies", "mails", "errors", "ticket")); $langs->loadLangs(array("project", "companies", "mails", "errors", "ticket", "agenda"));
$error = 0; $error = 0;
$this->output = ''; $this->output = '';
@ -864,17 +898,17 @@ class EmailCollector extends CommonObject
if (empty($this->host)) if (empty($this->host))
{ {
$this->error = $langs->trans('ErrorFieldRequired', 'EMailHost'); $this->error = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('EMailHost'));
return -1; return -1;
} }
if (empty($this->login)) if (empty($this->login))
{ {
$this->error = $langs->trans('ErrorFieldRequired', 'Login'); $this->error = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Login'));
return -1; return -1;
} }
if (empty($this->source_directory)) if (empty($this->source_directory))
{ {
$this->error = $langs->trans('ErrorFieldRequired', 'MailboxSourceDirectory'); $this->error = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('MailboxSourceDirectory'));
return -1; return -1;
} }
if (!function_exists('imap_open')) if (!function_exists('imap_open'))
@ -1060,7 +1094,6 @@ class EmailCollector extends CommonObject
// If there is a filter on trackid // If there is a filter on trackid
if ($searchfilterdoltrackid > 0) if ($searchfilterdoltrackid > 0)
{ {
//if (empty($headers['X-Dolibarr-TRACKID'])) continue;
if (empty($headers['References']) || !preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) if (empty($headers['References']) || !preg_match('/@'.preg_quote($host, '/').'/', $headers['References']))
{ {
$nbemailprocessed++; $nbemailprocessed++;
@ -1074,7 +1107,6 @@ class EmailCollector extends CommonObject
$nbemailprocessed++; $nbemailprocessed++;
continue; continue;
} }
//if (! empty($headers['X-Dolibarr-TRACKID']) continue;
} }
$thirdpartystatic = new Societe($this->db); $thirdpartystatic = new Societe($this->db);
@ -1090,11 +1122,30 @@ class EmailCollector extends CommonObject
$this->db->begin(); $this->db->begin();
// GET Email meta datas // GET Email meta datas
$overview = imap_fetch_overview($connection, $imapemail, 0); $overview = imap_fetch_overview($connection, $imapemail, 0);
dol_syslog("** Process email - msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." subject=".$overview[0]->subject); dol_syslog("** Process email - msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." subject=".$overview[0]->subject);
// Decode $overview[0]->subject according to RFC2047
// Can use also imap_mime_header_decode($str)
// Can use also mb_decode_mimeheader($str)
// Can use also iconv_mime_decode($str, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8')
if (function_exists('imap_mime_header_decode')) {
$elements = imap_mime_header_decode($overview[0]->subject);
$newstring = '';
if (! empty($elements)) {
for ($i = 0; $i < count($elements); $i++) {
$newstring .= ($newstring ? ' ' : '').$elements[$i]->text;
}
$overview[0]->subject = $newstring;
}
}
elseif (function_exists('mb_decode_mimeheader')) {
$overview[0]->subject = mb_decode_mimeheader($overview[0]->subject);
}
// Parse IMAP email structure // Parse IMAP email structure
global $htmlmsg, $plainmsg, $charset, $attachments; global $htmlmsg, $plainmsg, $charset, $attachments;
$this->getmsg($connection, $imapemail); $this->getmsg($connection, $imapemail);
@ -1459,78 +1510,85 @@ class EmailCollector extends CommonObject
// Create event // Create event
elseif ($operation['type'] == 'recordevent') elseif ($operation['type'] == 'recordevent')
{ {
if ($projectstatic->id > 0) $alreadycreated = 0;
{ // TODO Check if $msg ID already in database for $conf->entity
if ($projectfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby);
}
if ($thirdpartystatic->id > 0)
{
if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby);
}
if ($contactstatic->id > 0)
{
if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby);
}
$description = $descriptiontitle;
$description = dol_concatdesc($description, "-----");
$description = dol_concatdesc($description, $descriptionmeta);
$description = dol_concatdesc($description, "-----");
$description = dol_concatdesc($description, $messagetext);
$descriptionfull = $description; if (! $alreadycreated)
$descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); {
$descriptionfull = dol_concatdesc($descriptionfull, $header); if ($projectstatic->id > 0)
{
if ($projectfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby);
}
if ($thirdpartystatic->id > 0)
{
if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby);
}
if ($contactstatic->id > 0)
{
if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby);
}
// Insert record of emails sent $description = $descriptiontitle;
$actioncomm = new ActionComm($this->db); $description = dol_concatdesc($description, "-----");
$actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $description = dol_concatdesc($description, $descriptionmeta);
$actioncomm->code = 'AC_'.$actioncode; $description = dol_concatdesc($description, "-----");
$actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; $description = dol_concatdesc($description, $messagetext);
$actioncomm->note_private= $descriptionfull;
$actioncomm->fk_project = $projectstatic->id;
$actioncomm->datep = $date;
$actioncomm->datef = $date;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->socid = $thirdpartystatic->id;
$actioncomm->contactid = $contactstatic->id;
$actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array());
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $msgid;
$actioncomm->email_from = $fromstring;
$actioncomm->email_sender= $sender;
$actioncomm->email_to = $to;
$actioncomm->email_tocc = $sendtocc;
$actioncomm->email_tobcc = $sendtobcc;
$actioncomm->email_subject = $subject;
$actioncomm->errors_to = '';
if (! in_array($fk_element_type, array('societe','contact','project','user'))) $descriptionfull = $description;
{ $descriptionfull = dol_concatdesc($descriptionfull, "----- Header");
$actioncomm->fk_element = $fk_element_id; $descriptionfull = dol_concatdesc($descriptionfull, $header);
$actioncomm->elementtype = $fk_element_type;
}
//$actioncomm->extraparams = $extraparams; // Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
$actioncomm->code = 'AC_'.$actioncode;
$actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from;
$actioncomm->note_private= $descriptionfull;
$actioncomm->fk_project = $projectstatic->id;
$actioncomm->datep = $date;
$actioncomm->datef = $date;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->socid = $thirdpartystatic->id;
$actioncomm->contactid = $contactstatic->id;
$actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array());
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $msgid;
$actioncomm->email_from = $fromstring;
$actioncomm->email_sender= $sender;
$actioncomm->email_to = $to;
$actioncomm->email_tocc = $sendtocc;
$actioncomm->email_tobcc = $sendtobcc;
$actioncomm->email_subject = $subject;
$actioncomm->errors_to = '';
// Overwrite values with values extracted from source email if (! in_array($fk_element_type, array('societe','contact','project','user')))
$errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header); {
$actioncomm->fk_element = $fk_element_id;
$actioncomm->elementtype = $fk_element_type;
}
if ($errorforthisaction) //$actioncomm->extraparams = $extraparams;
{
$errorforactions++; // Overwrite values with values extracted from source email
} $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header);
else
{ if ($errorforthisaction)
$result = $actioncomm->create($user); {
if ($result <= 0) $errorforactions++;
{ }
$errorforactions++; else
$this->errors = $actioncomm->errors; {
} $result = $actioncomm->create($user);
} if ($result <= 0)
{
$errorforactions++;
$this->errors = $actioncomm->errors;
}
}
}
} }
// Create event // Create event
elseif ($operation['type'] == 'project') elseif ($operation['type'] == 'project')

View File

@ -1025,7 +1025,7 @@ if ($action == 'create')
print "</td></tr>\n"; print "</td></tr>\n";
// Other attributes // Other attributes
$parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid' => $socid);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $expe, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $expe, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
@ -1034,7 +1034,7 @@ if ($action == 'create')
if ($object->fetch_optionals() > 0) { if ($object->fetch_optionals() > 0) {
$expe->array_options = array_merge($expe->array_options, $object->array_options); $expe->array_options = array_merge($expe->array_options, $object->array_options);
} }
print $expe->showOptionals($extrafields, 'edit'); print $expe->showOptionals($extrafields, 'edit', $parameters);
} }
@ -1994,7 +1994,7 @@ elseif ($id || $ref)
} }
// Other attributes // Other attributes
$parameters = array('colspan' => ' colspan="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 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
@ -2459,10 +2459,10 @@ elseif ($id || $ref)
if (!empty($conf->productbatch->enabled)) $colspan++; if (!empty($conf->productbatch->enabled)) $colspan++;
if (!empty($conf->stock->enabled)) $colspan++; if (!empty($conf->stock->enabled)) $colspan++;
$lines[$i]->fetch_optionals($lines[$i]->id); $line = $lines[$i];
$line->fetch_optionals($line->id);
print '<tr class="oddeven">'; if ($action == 'editline' && $line->id == $line_id)
if ($action == 'editline' && $lines[$i]->id == $line_id)
{ {
print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), $indiceAsked); print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), $indiceAsked);
} }
@ -2470,7 +2470,6 @@ elseif ($id || $ref)
{ {
print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), $indiceAsked); print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), $indiceAsked);
} }
print '</tr>';
} }
} }
} }

View File

@ -17,7 +17,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf)) if (empty($conf) || !is_object($conf))
{ {
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
@ -35,14 +35,14 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
// Load translation files required by the page // Load translation files required by the page
$langs->load("sendings"); $langs->load("sendings");
$total=0; $total = 0;
$ilink=0; $ilink = 0;
foreach($linkedObjectBlock as $key => $objectlink) foreach ($linkedObjectBlock as $key => $objectlink)
{ {
$ilink++; $ilink++;
$trclass='oddeven'; $trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
?> ?>
<tr class="<?php echo $trclass; ?>"> <tr class="<?php echo $trclass; ?>">
<td><?php echo $langs->trans("Shipment"); ?></td> <td><?php echo $langs->trans("Shipment"); ?></td>
@ -58,9 +58,9 @@ foreach($linkedObjectBlock as $key => $objectlink)
<td class="right"> <td class="right">
<?php <?php
// For now, shipments must stay linked to order, so link is not deletable // For now, shipments must stay linked to order, so link is not deletable
if($object->element != 'commande') { if ($object->element != 'commande') {
?> ?>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> <a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
<?php <?php
} }
?> ?>
@ -69,7 +69,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
} }
if (count($linkedObjectBlock) > 1) { if (count($linkedObjectBlock) > 1) {
?> ?>
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter)?'liste_sub_total':''); ?>"> <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
<td><?php echo $langs->trans("Total"); ?></td> <td><?php echo $langs->trans("Total"); ?></td>
<td></td> <td></td>
<td class="center"></td> <td class="center"></td>

View File

@ -1532,11 +1532,11 @@ if ($action == 'create')
} }
// Other attributes // Other attributes
$parameters = array('colspan' => ' colspan="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 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) { if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit', $parameters);
} }
print '<tbody>'; print '<tbody>';

View File

@ -49,7 +49,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($objectlink->total_ht); echo price($objectlink->total_ht);
} ?></td> } ?></td>
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr> </tr>
<?php <?php
} }

View File

@ -906,18 +906,17 @@ if ($action == 'create')
print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="socid" value='.$soc->id.'>';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head(''); dol_fiche_head('');
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<input type="hidden" name="socid" value='.$soc->id.'>';
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("ThirdParty").'</td><td>'.$soc->getNomUrl(1).'</td></tr>'; print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("ThirdParty").'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
print '<input type="hidden" name="action" value="add">';
// Ref // Ref
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans("Draft").'</td></tr>';
// Description (must be a textarea and not html must be allowed (used in list view) // Description (must be a textarea and not html must be allowed (used in list view)
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>'; print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
@ -963,15 +962,15 @@ if ($action == 'create')
// Model // Model
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>'; print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td colspan="2">'; print '<td>';
$liste = ModelePDFFicheinter::liste_modeles($db); $liste = ModelePDFFicheinter::liste_modeles($db);
print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF); print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF);
print "</td></tr>"; print "</td></tr>";
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td colspan="2">'; print '<td>';
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
//print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>'; //print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
@ -982,7 +981,7 @@ if ($action == 'create')
{ {
print '<tr>'; print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td colspan="2">'; print '<td>';
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
//print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>'; //print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
@ -990,7 +989,7 @@ if ($action == 'create')
} }
// Other attributes // Other attributes
$parameters = array('colspan' => ' colspan="2"'); $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $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; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))

View File

@ -50,7 +50,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
<td class="center"><?php echo dol_print_date($objectlink->datev, 'day'); ?></td> <td class="center"><?php echo dol_print_date($objectlink->datev, 'day'); ?></td>
<td></td> <td></td>
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr> </tr>
<?php <?php
} }

View File

@ -1610,15 +1610,13 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans('RefSupplier').'</td><td><input name="refsupplier" type="text"></td>'; print '<tr><td>'.$langs->trans('RefSupplier').'</td><td><input name="refsupplier" type="text"></td>';
print '</tr>'; print '</tr>';
print '</td></tr>';
// Payment term // Payment term
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
$form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Payment mode // Payment mode
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
$form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id');
print '</td></tr>'; print '</td></tr>';
@ -1636,7 +1634,7 @@ if ($action == 'create')
if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled))
{ {
$langs->load("bank"); $langs->load("bank");
print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('BankAccount').'</td><td>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1); $form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>'; print '</td></tr>';
} }
@ -1647,10 +1645,9 @@ if ($action == 'create')
$formproject = new FormProjets($db); $formproject = new FormProjets($db);
$langs->load('projects'); $langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('Project').'</td><td>';
$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$societe->id).'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$societe->id).'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
print '</td></tr>'; print '</td></tr>';
} }
@ -1659,7 +1656,7 @@ if ($action == 'create')
{ {
print '<tr>'; print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->label_incoterms, 1).'</label></td>'; print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $object->label_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">'; print '<td class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''));
print '</td></tr>'; print '</td></tr>';
} }
@ -1669,7 +1666,7 @@ if ($action == 'create')
{ {
print '<tr>'; print '<tr>';
print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>'; print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">'; print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>'; print '</td></tr>';
} }
@ -1700,26 +1697,26 @@ if ($action == 'create')
print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">'; print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
$newclassname = $classname; $newclassname = $classname;
print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans($newclassname).'</td><td>'.$objectsrc->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountHT').'</td><td colspan="2">'.price($objectsrc->total_ht).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($objectsrc->total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="2">'.price($objectsrc->total_tva)."</td></tr>"; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($objectsrc->total_tva)."</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
{ {
print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td><td colspan="2">'.price($objectsrc->total_localtax1)."</td></tr>"; print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax1)."</td></tr>";
} }
if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
{ {
print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td><td colspan="2">'.price($objectsrc->total_localtax2)."</td></tr>"; print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax2)."</td></tr>";
} }
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td colspan="2">'.price($objectsrc->total_ttc)."</td></tr>"; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($objectsrc->total_ttc)."</td></tr>";
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
print '<tr><td>'.$langs->trans('MulticurrencyAmountHT').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_ht).'</td></tr>'; print '<tr><td>'.$langs->trans('MulticurrencyAmountHT').'</td><td>'.price($objectsrc->multicurrency_total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('MulticurrencyAmountVAT').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_tva).'</td></tr>'; print '<tr><td>'.$langs->trans('MulticurrencyAmountVAT').'</td><td>'.price($objectsrc->multicurrency_total_tva).'</td></tr>';
print '<tr><td>'.$langs->trans('MulticurrencyAmountTTC').'</td><td colspan="2">'.price($objectsrc->multicurrency_total_ttc).'</td></tr>'; print '<tr><td>'.$langs->trans('MulticurrencyAmountTTC').'</td><td>'.price($objectsrc->multicurrency_total_ttc).'</td></tr>';
} }
} }

View File

@ -336,22 +336,22 @@ if ($action == 'create' && !$error) {
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Ref // Ref
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>'; print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans('Draft').'</td></tr>';
// Ref supplier // Ref supplier
print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.dol_escape_htmltag(isset($_POST['ref_supplier']) ? GETPOST('ref_supplier', 'alpha', 2) : '').'" type="text"></td>'; print '<tr><td class="fieldrequired">'.$langs->trans('RefSupplier').'</td><td><input name="ref_supplier" value="'.dol_escape_htmltag(isset($_POST['ref_supplier']) ? GETPOST('ref_supplier', 'alpha', 2) : '').'" type="text"></td>';
print '</tr>'; print '</tr>';
// Date invoice // Date invoice
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">'; print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
print $html->selectDate('', '', '', '', '', "add", 1, 1); print $html->selectDate('', '', '', '', '', "add", 1, 1);
print '</td></tr>'; print '</td></tr>';
// Payment term // Payment term
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
$html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); $html->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Payment mode // Payment mode
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
$html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Project // Project
@ -359,7 +359,7 @@ if ($action == 'create' && !$error) {
$formproject = new FormProjets($db); $formproject = new FormProjets($db);
$langs->load('projects'); $langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('Project').'</td><td>';
$formproject->select_projects($soc->id, $projectid, 'projectid'); $formproject->select_projects($soc->id, $projectid, 'projectid');
print '</td></tr>'; print '</td></tr>';
} }
@ -367,9 +367,7 @@ if ($action == 'create' && !$error) {
// Other attributes // Other attributes
$parameters = array( $parameters = array(
'objectsrc' => $objectsrc, 'objectsrc' => $objectsrc,
'idsrc' => $listoforders, 'idsrc' => $listoforders
'colspan' => ' colspan="2"',
'cols'=>2
); );
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $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; print $hookmanager->resPrint;
@ -390,7 +388,7 @@ if ($action == 'create' && !$error) {
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td colspan="2">'; print '<td>';
print '<textarea name="note_public" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'; print '<textarea name="note_public" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">';
print $langs->trans("Orders").": ".implode(', ', $listoforders); print $langs->trans("Orders").": ".implode(', ', $listoforders);
@ -401,7 +399,7 @@ if ($action == 'create' && !$error) {
if (empty($user->socid)) { if (empty($user->socid)) {
print '<tr>'; print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>'; print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td colspan="2">'; print '<td>';
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'; print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">';
print '</textarea></td></tr>'; print '</textarea></td></tr>';

View File

@ -55,7 +55,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($objectlink->total_ht); echo price($objectlink->total_ht);
} ?></td> } ?></td>
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr> </tr>
<?php <?php
} }

View File

@ -2674,11 +2674,14 @@ else
else $calculationrule = (empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND) ? 'totalofround' : 'roundoftotal'); else $calculationrule = (empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND) ? 'totalofround' : 'roundoftotal');
if ($calculationrule == 'totalofround') $calculationrulenum = 1; if ($calculationrule == 'totalofround') $calculationrulenum = 1;
else $calculationrulenum = 2; else $calculationrulenum = 2;
$s = $langs->trans("ReCalculate").' '; // Show link for "recalculate"
$s .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=calculate&calculationrule=totalofround">'.$langs->trans("Mode1").'</a>'; if ($object->getVentilExportCompta() == 0) {
$s .= ' / '; $s = $langs->trans("ReCalculate").' ';
$s .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=calculate&calculationrule=roundoftotal">'.$langs->trans("Mode2").'</a>'; $s .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=calculate&calculationrule=totalofround">'.$langs->trans("Mode1").'</a>';
print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc", $calculationrulenum).'<br>'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('', 'help')); $s .= ' / ';
$s .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=calculate&calculationrule=roundoftotal">'.$langs->trans("Mode2").'</a>';
print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc", $calculationrulenum).'<br>'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('', 'help'));
}
print '</div></td></tr>'; print '</div></td></tr>';
// Amount Local Taxes // Amount Local Taxes

View File

@ -66,7 +66,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
} }
} ?></td> } ?></td>
<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td> <td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr> </tr>
<?php <?php
} }

View File

@ -304,12 +304,31 @@ class Holiday extends CommonObject
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
if (!$notrigger) if ($this->id)
{ {
// Call trigger // update ref
$result = $this->call_trigger('HOLIDAY_CREATE', $user); $initialref = '(PROV'.$this->id.')';
if ($result < 0) { $error++; } if (!empty($this->ref)) $initialref = $this->ref;
// End call triggers
$sql = 'UPDATE '.MAIN_DB_PREFIX."holiday SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
$this->ref = $initialref;
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0) $error++;
}
if (!$error && !$notrigger)
{
// Call trigger
$result = $this->call_trigger('HOLIDAY_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
}
} }
} }
@ -337,7 +356,7 @@ class Holiday extends CommonObject
* *
* @param int $id Id object * @param int $id Id object
* @param string $ref Ref object * @param string $ref Ref object
* @return int <0 if KO, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $ref = '') public function fetch($id, $ref = '')
{ {
@ -402,12 +421,17 @@ class Holiday extends CommonObject
$this->fk_user_create = $obj->fk_user_create; $this->fk_user_create = $obj->fk_user_create;
$this->fk_type = $obj->fk_type; $this->fk_type = $obj->fk_type;
$this->entity = $obj->entity; $this->entity = $obj->entity;
$this->fetch_optionals();
$result = 1;
}
else {
$result = 0;
} }
$this->db->free($resql); $this->db->free($resql);
$this->fetch_optionals(); return $result;
return 1;
} }
else else
{ {

View File

@ -1,360 +0,0 @@
// jquery.multi-select.js
// by mySociety
// https://github.com/mysociety/jquery-multi-select
;(function($) {
"use strict";
var pluginName = "multiSelect",
defaults = {
'containerHTML': '<div class="multi-select-container">',
'menuHTML': '<div class="multi-select-menu">',
'buttonHTML': '<span class="multi-select-button">',
'menuItemsHTML': '<div class="multi-select-menuitems">',
'menuItemHTML': '<label class="multi-select-menuitem">',
'presetsHTML': '<div class="multi-select-presets">',
'activeClass': 'multi-select-container--open',
'noneText': '-- Select --',
'allText': undefined,
'presets': undefined,
'positionedMenuClass': 'multi-select-container--positioned',
'positionMenuWithin': undefined,
'viewportBottomGutter': 20,
'menuMinHeight': 200
};
/**
* @constructor
*/
function MultiSelect(element, options) {
this.element = element;
this.$element = $(element);
this.settings = $.extend( {}, defaults, options );
this._defaults = defaults;
this._name = pluginName;
this.init();
}
function arraysAreEqual(array1, array2) {
if ( array1.length != array2.length ){
return false;
}
array1.sort();
array2.sort();
for ( var i = 0; i < array1.length; i++ ){
if ( array1[i] !== array2[i] ){
return false;
}
}
return true;
}
$.extend(MultiSelect.prototype, {
init: function() {
this.checkSuitableInput();
this.findLabels();
this.constructContainer();
this.constructButton();
this.constructMenu();
this.setUpBodyClickListener();
this.setUpLabelsClickListener();
this.$element.hide();
},
checkSuitableInput: function(text) {
if ( this.$element.is('select[multiple]') === false ) {
throw new Error('$.multiSelect only works on <select multiple> elements');
}
},
findLabels: function() {
this.$labels = $('label[for="' + this.$element.attr('id') + '"]');
},
constructContainer: function() {
this.$container = $(this.settings['containerHTML']);
this.$element.data('multi-select-container', this.$container);
this.$container.insertAfter(this.$element);
},
constructButton: function() {
var _this = this;
this.$button = $(this.settings['buttonHTML']);
this.$button.attr({
'role': 'button',
'aria-haspopup': 'true',
'tabindex': 0,
'aria-label': this.$labels.eq(0).text()
})
.on('keydown.multiselect', function(e) {
var key = e.which;
var returnKey = 13;
var spaceKey = 32;
if ((key === returnKey) || (key === spaceKey)) {
_this.$button.click();
}
}).on('click.multiselect', function(e) {
_this.menuToggle();
})
.appendTo(this.$container);
this.$element.on('change.multiselect', function() {
_this.updateButtonContents();
});
this.updateButtonContents();
},
updateButtonContents: function() {
var _this = this;
var options = [];
var selected = [];
this.$element.children('option').each(function() {
var text = /** @type string */ ($(this).text());
options.push(text);
if ($(this).is(':selected')) {
selected.push( $.trim(text) );
}
});
this.$button.empty();
if (selected.length == 0) {
this.$button.text( this.settings['noneText'] );
} else if ( (selected.length === options.length) && this.settings['allText']) {
this.$button.text( this.settings['allText'] );
} else {
this.$button.text( selected.join(', ') );
}
},
constructMenu: function() {
var _this = this;
this.$menu = $(this.settings['menuHTML']);
this.$menu.attr({
'role': 'menu'
}).on('keyup.multiselect', function(e){
var key = e.which;
var escapeKey = 27;
if (key === escapeKey) {
_this.menuHide();
}
})
.appendTo(this.$container);
this.constructMenuItems();
if ( this.settings['presets'] ) {
this.constructPresets();
}
},
constructMenuItems: function() {
var _this = this;
this.$menuItems = $(this.settings['menuItemsHTML']);
this.$menu.append(this.$menuItems);
this.$element.on('change.multiselect', function(e, internal) {
// Don't need to update the menu items if this
// change event was fired by our tickbox handler.
if(internal !== true){
_this.updateMenuItems();
}
});
this.updateMenuItems();
},
updateMenuItems: function() {
var _this = this;
this.$menuItems.empty();
this.$element.children('option').each(function(option_index, option) {
var $item = _this.constructMenuItem($(option), option_index);
_this.$menuItems.append($item);
});
},
constructPresets: function() {
var _this = this;
this.$presets = $(this.settings['presetsHTML']);
this.$menu.prepend(this.$presets);
$.each(this.settings['presets'], function(i, preset){
var unique_id = _this.$element.attr('name') + '_preset_' + i;
var $item = $(_this.settings['menuItemHTML'])
.attr({
'for': unique_id,
'role': 'menuitem'
})
.text(' ' + preset.name)
.appendTo(_this.$presets);
var $input = $('<input>')
.attr({
'type': 'radio',
'name': _this.$element.attr('name') + '_presets',
'id': unique_id
})
.prependTo($item);
$input.on('change.multiselect', function(){
_this.$element.val(preset.options);
_this.$element.trigger('change');
});
});
this.$element.on('change.multiselect', function() {
_this.updatePresets();
});
this.updatePresets();
},
updatePresets: function() {
var _this = this;
$.each(this.settings['presets'], function(i, preset){
var unique_id = _this.$element.attr('name') + '_preset_' + i;
var $input = _this.$presets.find('#' + unique_id);
if ( arraysAreEqual(preset.options || [], _this.$element.val() || []) ){
$input.prop('checked', true);
} else {
$input.prop('checked', false);
}
});
},
constructMenuItem: function($option, option_index) {
var unique_id = this.$element.attr('name') + '_' + option_index;
var $item = $(this.settings['menuItemHTML'])
.attr({
'for': unique_id,
'role': 'menuitem'
})
.text(' ' + $option.text());
var $input = $('<input>')
.attr({
'type': 'checkbox',
'id': unique_id,
'value': $option.val()
})
.prependTo($item);
if ( $option.is(':disabled') ) {
$input.attr('disabled', 'disabled');
}
if ( $option.is(':selected') ) {
$input.prop('checked', 'checked');
}
$input.on('change.multiselect', function() {
if ($(this).prop('checked')) {
$option.prop('selected', true);
} else {
$option.prop('selected', false);
}
// .prop() on its own doesn't generate a change event.
// Other plugins might want to do stuff onChange.
$option.trigger('change', [true]);
});
return $item;
},
setUpBodyClickListener: function() {
var _this = this;
// Hide the $menu when you click outside of it.
$('html').on('click.multiselect', function(){
_this.menuHide();
});
// Stop click events from inside the $button or $menu from
// bubbling up to the body and closing the menu!
this.$container.on('click.multiselect', function(e){
e.stopPropagation();
});
},
setUpLabelsClickListener: function() {
var _this = this;
this.$labels.on('click.multiselect', function(e) {
e.preventDefault();
e.stopPropagation();
_this.menuToggle();
});
},
menuShow: function() {
$('html').trigger('click.multiselect'); // Close any other open menus
this.$container.addClass(this.settings['activeClass']);
if ( this.settings['positionMenuWithin'] && this.settings['positionMenuWithin'] instanceof $ ) {
var menuLeftEdge = this.$menu.offset().left + this.$menu.outerWidth();
var withinLeftEdge = this.settings['positionMenuWithin'].offset().left +
this.settings['positionMenuWithin'].outerWidth();
if ( menuLeftEdge > withinLeftEdge ) {
this.$menu.css( 'width', (withinLeftEdge - this.$menu.offset().left) );
this.$container.addClass(this.settings['positionedMenuClass']);
}
}
var menuBottom = this.$menu.offset().top + this.$menu.outerHeight();
var viewportBottom = $(window).scrollTop() + $(window).height();
if ( menuBottom > viewportBottom - this.settings['viewportBottomGutter'] ) {
this.$menu.css({
'maxHeight': Math.max(
viewportBottom - this.settings['viewportBottomGutter'] - this.$menu.offset().top,
this.settings['menuMinHeight']
),
'overflow': 'scroll'
});
} else {
this.$menu.css({
'maxHeight': '',
'overflow': ''
});
}
},
menuHide: function() {
this.$container.removeClass(this.settings['activeClass']);
this.$container.removeClass(this.settings['positionedMenuClass']);
this.$menu.css('width', 'auto');
},
menuToggle: function() {
if ( this.$container.hasClass(this.settings['activeClass']) ) {
this.menuHide();
} else {
this.menuShow();
}
}
});
$.fn[ pluginName ] = function(options) {
return this.each(function() {
if ( !$.data(this, "plugin_" + pluginName) ) {
$.data(this, "plugin_" + pluginName,
new MultiSelect(this, options) );
}
});
};
})(jQuery);

View File

@ -1,9 +0,0 @@
(function(c){function f(b,a){this.b=c(b);this.a=c.extend({},g,a);this.H()}var g={containerHTML:'<div class="multi-select-container">',menuHTML:'<div class="multi-select-menu">',buttonHTML:'<span class="multi-select-button">',menuItemsHTML:'<div class="multi-select-menuitems">',menuItemHTML:'<label class="multi-select-menuitem">',presetsHTML:'<div class="multi-select-presets">',activeClass:"multi-select-container--open",noneText:"-- Select --",allText:void 0,presets:void 0,positionedMenuClass:"multi-select-container--positioned",
positionMenuWithin:void 0,viewportBottomGutter:20,menuMinHeight:200};c.extend(f.prototype,{H:function(){this.v();this.G();this.A();this.w();this.B();this.J();this.K();this.b.hide()},v:function(){if(!1===this.b.is("select[multiple]"))throw Error("$.multiSelect only works on <select multiple> elements");},G:function(){this.l=c('label[for="'+this.b.attr("id")+'"]')},A:function(){this.f=c(this.a.containerHTML);this.b.data("multi-select-container",this.f);this.f.insertAfter(this.b)},w:function(){var b=
this;this.g=c(this.a.buttonHTML);this.g.attr({role:"button","aria-haspopup":"true",tabindex:0,"aria-label":this.l.eq(0).text()}).on("keydown.multiselect",function(a){a=a.which;13!==a&&32!==a||b.g.click()}).on("click.multiselect",function(){b.m()}).appendTo(this.f);this.b.on("change.multiselect",function(){b.o()});this.o()},o:function(){var b=[],a=[];this.b.children("option").each(function(){var d=c(this).text();b.push(d);c(this).is(":selected")&&a.push(c.trim(d))});this.g.empty();0==a.length?this.g.text(this.a.noneText):
a.length===b.length&&this.a.allText?this.g.text(this.a.allText):this.g.text(a.join(", "))},B:function(){var b=this;this.c=c(this.a.menuHTML);this.c.attr({role:"menu"}).on("keyup.multiselect",function(a){27===a.which&&b.j()}).appendTo(this.f);this.D();this.a.presets&&this.F()},D:function(){var b=this;this.h=c(this.a.menuItemsHTML);this.c.append(this.h);this.b.on("change.multiselect",function(a,c){!0!==c&&b.s()});this.s()},s:function(){var b=this;this.h.empty();this.b.children("option").each(function(a,
d){a=b.C(c(d),a);b.h.append(a)})},F:function(){var b=this;this.i=c(this.a.presetsHTML);this.c.prepend(this.i);c.each(this.a.presets,function(a,d){a=b.b.attr("name")+"_preset_"+a;var h=c(b.a.menuItemHTML).attr({"for":a,role:"menuitem"}).text(" "+d.name).appendTo(b.i);c("<input>").attr({type:"radio",name:b.b.attr("name")+"_presets",id:a}).prependTo(h).on("change.multiselect",function(){b.b.val(d.options);b.b.trigger("change")})});this.b.on("change.multiselect",function(){b.u()});this.u()},u:function(){var b=
this;c.each(this.a.presets,function(a,c){a=b.b.attr("name")+"_preset_"+a;a=b.i.find("#"+a);a:{c=c.options||[];var d=b.b.val()||[];if(c.length!=d.length)c=!1;else{c.sort();d.sort();for(var e=0;e<c.length;e++)if(c[e]!==d[e]){c=!1;break a}c=!0}}c?a.prop("checked",!0):a.prop("checked",!1)})},C:function(b,a){var d=this.b.attr("name")+"_"+a;a=c(this.a.menuItemHTML).attr({"for":d,role:"menuitem"}).text(" "+b.text());d=c("<input>").attr({type:"checkbox",id:d,value:b.val()}).prependTo(a);b.is(":disabled")&&
d.attr("disabled","disabled");b.is(":selected")&&d.prop("checked","checked");d.on("change.multiselect",function(){c(this).prop("checked")?b.prop("selected",!0):b.prop("selected",!1);b.trigger("change",[!0])});return a},J:function(){var b=this;c("html").on("click.multiselect",function(){b.j()});this.f.on("click.multiselect",function(a){a.stopPropagation()})},K:function(){var b=this;this.l.on("click.multiselect",function(a){a.preventDefault();a.stopPropagation();b.m()})},I:function(){c("html").trigger("click.multiselect");
this.f.addClass(this.a.activeClass);if(this.a.positionMenuWithin&&this.a.positionMenuWithin instanceof c){var b=this.c.offset().left+this.c.outerWidth(),a=this.a.positionMenuWithin.offset().left+this.a.positionMenuWithin.outerWidth();b>a&&(this.c.css("width",a-this.c.offset().left),this.f.addClass(this.a.positionedMenuClass))}b=this.c.offset().top+this.c.outerHeight();a=c(window).scrollTop()+c(window).height();b>a-this.a.viewportBottomGutter?this.c.css({maxHeight:Math.max(a-this.a.viewportBottomGutter-
this.c.offset().top,this.a.menuMinHeight),overflow:"scroll"}):this.c.css({maxHeight:"",overflow:""})},j:function(){this.f.removeClass(this.a.activeClass);this.f.removeClass(this.a.positionedMenuClass);this.c.css("width","auto")},m:function(){this.f.hasClass(this.a.activeClass)?this.j():this.I()}});c.fn.multiSelect=function(b){return this.each(function(){c.data(this,"plugin_multiSelect")||c.data(this,"plugin_multiSelect",new f(this,b))})}})(jQuery);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -48,9 +48,19 @@ UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2');
ALTER TABLE llx_adherent_type ADD UNIQUE INDEX uk_adherent_type_libelle (libelle, entity); ALTER TABLE llx_adherent_type ADD UNIQUE INDEX uk_adherent_type_libelle (libelle, entity);
ALTER TABLE llx_mailing_cibles MODIFY COLUMN lastname varchar(160);
ALTER TABLE llx_mailing_cibles MODIFY COLUMN firstname varchar(160);
ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN login varchar(128);
ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN codelastresult varchar(16);
ALTER TABLE llx_emailcollector_emailcollectoraction ADD COLUMN position integer DEFAULT 0;
-- For v11 -- For v11
ALTER TABLE llx_c_email_senderprofile MODIFY COLUMN active tinyint DEFAULT 1 NOT NULL;
insert into llx_c_type_container (code,label,module,active) values ('menu', 'Menu', 'system', 1); insert into llx_c_type_container (code,label,module,active) values ('menu', 'Menu', 'system', 1);
INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('HELP', '15', 'Request for functionnal help', 1, 0, NULL); INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('HELP', '15', 'Request for functionnal help', 1, 0, NULL);
@ -498,3 +508,30 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663);
ALTER TABLE llx_comment ADD COLUMN fk_user_modif integer DEFAULT NULL; ALTER TABLE llx_comment ADD COLUMN fk_user_modif integer DEFAULT NULL;
CREATE TABLE llx_mrp_production(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
fk_mo integer NOT NULL,
position integer NOT NULL DEFAULT 0,
fk_product integer NOT NULL,
fk_warehouse integer,
qty integer NOT NULL DEFAULT 1,
batch varchar(30),
role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation)
fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce'
fk_stock_movement integer, -- id of stock movement when movements are validated
date_creation datetime NOT NULL,
tms timestamp,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14)
) ENGINE=innodb;
ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_mo FOREIGN KEY (fk_mo) REFERENCES llx_mrp_mo (rowid);
ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_stock_movement FOREIGN KEY (fk_stock_movement) REFERENCES llx_stock_mouvement (rowid);
ALTER TABLE llx_mrp_production ADD INDEX idx_mrp_production_fk_mo (fk_mo);
ALTER TABLE llx_emailcollector_emailcollector ADD UNIQUE INDEX uk_emailcollector_emailcollector_ref(ref, entity);

0
htdocs/install/mysql/migration/3.5.0-3.6.0.sql Executable file → Normal file
View File

0
htdocs/install/mysql/migration/3.6.0-3.7.0.sql Executable file → Normal file
View File

0
htdocs/install/mysql/migration/3.7.0-3.8.0.sql Executable file → Normal file
View File

View File

@ -328,6 +328,9 @@ UPDATE llx_c_shipment_mode SET label = 'https://www.laposte.fr/outils/suivre-vos
UPDATE llx_c_shipment_mode SET label = 'https://www.laposte.fr/outils/suivre-vos-envois?code={TRACKID}' WHERE code IN ('LETTREMAX'); UPDATE llx_c_shipment_mode SET label = 'https://www.laposte.fr/outils/suivre-vos-envois?code={TRACKID}' WHERE code IN ('LETTREMAX');
-- VMYSQL4.3 ALTER TABLE llx_holiday MODIFY COLUMN ref varchar(30) NULL;
-- VPGSQL8.2 ALTER TABLE llx_holiday ALTER COLUMN ref DROP NOT NULL;
create table llx_reception create table llx_reception
( (

0
htdocs/install/mysql/migration/repair.sql Executable file → Normal file
View File

View File

@ -50,7 +50,7 @@ CREATE TABLE llx_accounting_bookkeeping
code_journal varchar(32) NOT NULL, -- FEC:JournalCode code_journal varchar(32) NOT NULL, -- FEC:JournalCode
journal_label varchar(255), -- FEC:JournalLib journal_label varchar(255), -- FEC:JournalLib
date_validated datetime, -- FEC:ValidDate | if empty: movement not validated / if not empty: movement validated (No deleting / No modification) date_validated datetime, -- FEC:ValidDate | if empty: movement not validated / if not empty: movement validated (No deleting / No modification)
date_export datetime DEFAULT NULL, -- date_export datetime DEFAULT NULL, --
import_key varchar(14), import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format extraparams varchar(255) -- for other parameters with json format
) ENGINE=innodb; ) ENGINE=innodb;

View File

@ -19,7 +19,5 @@ ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_entit
ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_status (status); ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_status (status);
-- END MODULEBUILDER INDEXES -- END MODULEBUILDER INDEXES
--ALTER TABLE llx_emailcollector_emailcollector ADD UNIQUE INDEX uk_emailcollector_emailcollector_fieldxyz(fieldx, fieldy); ALTER TABLE llx_emailcollector_emailcollector ADD UNIQUE INDEX uk_emailcollector_emailcollector_ref(ref, entity);
--ALTER TABLE llx_emailcollector_emailcollector ADD CONSTRAINT llx_emailcollector_emailcollector_field_id FOREIGN KEY (fk_field) REFERENCES llx_myotherobject(rowid);

View File

@ -0,0 +1,21 @@
-- Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see http://www.gnu.org/licenses/.
ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_mo FOREIGN KEY (fk_mo) REFERENCES llx_mrp_mo (rowid);
ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_stock_movement FOREIGN KEY (fk_stock_movement) REFERENCES llx_stock_mouvement (rowid);
ALTER TABLE llx_mrp_production ADD INDEX idx_mrp_production_fk_mo (fk_mo);

View File

@ -0,0 +1,34 @@
-- Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see http://www.gnu.org/licenses/.
CREATE TABLE llx_mrp_production(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
fk_mo integer NOT NULL,
position integer NOT NULL DEFAULT 0,
fk_product integer NOT NULL,
fk_warehouse integer,
qty integer NOT NULL DEFAULT 1,
batch varchar(30),
role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation)
fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce'
fk_stock_movement integer, -- id of stock movement when movements are validated
date_creation datetime NOT NULL,
tms timestamp,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
import_key varchar(14)
) ENGINE=innodb;

View File

@ -17,6 +17,7 @@
-- --
-- This table is dedicated to store detail (lots/serial) of a stock -- This table is dedicated to store detail (lots/serial) of a stock
-- ============================================================================ -- ============================================================================
CREATE TABLE llx_product_batch ( CREATE TABLE llx_product_batch (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp, tms timestamp,

Some files were not shown because too many files have changed in this diff Show More