Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2020-10-26 19:35:09 +01:00
commit fc66e01be8
14 changed files with 256 additions and 322 deletions

View File

@ -208,6 +208,11 @@ class Categorie extends CommonObject
*/
public $color;
/**
* @var int Visible
*/
public $visible;
/**
* @var int Id of thirdparty when CATEGORY_ASSIGNED_TO_A_CUSTOMER is set
*/
@ -312,40 +317,36 @@ class Categorie extends CommonObject
$sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext";
$sql .= ", date_creation, tms, fk_user_creat, fk_user_modif";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie";
if ($id > 0)
{
if ($id > 0) {
$sql .= " WHERE rowid = ".$id;
} elseif (!empty($ref_ext))
{
} elseif (!empty($ref_ext)) {
$sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'";
} else {
$sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")";
if (!is_null($type)) $sql .= " AND type = ".$this->db->escape($type);
if (!is_null($type)) $sql .= " AND type = ".((int) $type);
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql) > 0)
{
if ($resql) {
if ($this->db->num_rows($resql) > 0) {
$res = $this->db->fetch_array($resql);
$this->id = $res['rowid'];
//$this->ref = $res['rowid'];
$this->fk_parent = $res['fk_parent'];
$this->fk_parent = (int) $res['fk_parent'];
$this->label = $res['label'];
$this->description = $res['description'];
$this->color = $res['color'];
$this->socid = $res['fk_soc'];
$this->visible = $res['visible'];
$this->type = $res['type'];
$this->socid = (int) $res['fk_soc'];
$this->visible = (int) $res['visible'];
$this->type = (int) $res['type'];
$this->ref_ext = $res['ref_ext'];
$this->entity = $res['entity'];
$this->entity = (int) $res['entity'];
$this->date_creation = $this->db->jdate($res['date_creation']);
$this->date_modification = $this->db->jdate($res['tms']);
$this->user_creation = $res['fk_user_creat'];
$this->user_modification = $res['fk_user_modif'];
$this->user_creation = (int) $res['fk_user_creat'];
$this->user_modification = (int) $res['fk_user_modif'];
// Retrieve all extrafield
// fetch optionals attributes and labels
@ -397,8 +398,7 @@ class Categorie extends CommonObject
if (empty($this->visible)) $this->visible = 0;
$this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0);
if ($this->already_exists())
{
if ($this->already_exists()) {
$this->error = $langs->trans("ImpossibleAddCat", $this->label);
$this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel");
dol_syslog($this->error, LOG_WARNING);
@ -412,8 +412,7 @@ class Categorie extends CommonObject
$sql .= " label,";
$sql .= " description,";
$sql .= " color,";
if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
{
if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
$sql .= "fk_soc,";
}
$sql .= " visible,";
@ -424,54 +423,47 @@ class Categorie extends CommonObject
$sql .= " date_creation,";
$sql .= " fk_user_creat";
$sql .= ") VALUES (";
$sql .= $this->db->escape($this->fk_parent).",";
$sql .= (int) $this->fk_parent.",";
$sql .= "'".$this->db->escape($this->label)."',";
$sql .= "'".$this->db->escape($this->description)."',";
$sql .= "'".$this->db->escape($this->color)."',";
if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
{
if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
$sql .= ($this->socid != -1 ? $this->socid : 'null').",";
}
$sql .= "'".$this->db->escape($this->visible)."',";
$sql .= $this->db->escape($type).",";
$sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').",";
$sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').",";
$sql .= $this->db->escape($conf->entity).",";
$sql .= (int) $conf->entity.",";
$sql .= "'".$this->db->idate($now)."', ";
$sql .= (int) $user->id;
$sql .= ")";
$res = $this->db->query($sql);
if ($res)
{
if ($res) {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."categorie");
if ($id > 0)
{
if ($id > 0) {
$this->id = $id;
$action = 'create';
// Actions on extra fields
if (!$error)
{
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
}
}
if (!$error)
{
if (!$error) {
// Call trigger
$result = $this->call_trigger('CATEGORY_CREATE', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return $id;
} else {
@ -510,8 +502,7 @@ class Categorie extends CommonObject
$this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0);
$this->visible = ($this->visible != "" ? intval($this->visible) : 0);
if ($this->already_exists())
{
if ($this->already_exists()) {
$this->error = $langs->trans("ImpossibleUpdateCat");
$this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel");
return -1;
@ -524,32 +515,27 @@ class Categorie extends CommonObject
$sql .= " description = '".$this->db->escape($this->description)."',";
$sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',";
$sql .= " color = '".$this->db->escape($this->color)."'";
if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
{
if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) {
$sql .= ", fk_soc = ".($this->socid != -1 ? $this->socid : 'null');
}
$sql .= ", visible = '".$this->db->escape($this->visible)."'";
$sql .= ", fk_parent = ".$this->fk_parent;
$sql .= ", visible = ".(int) $this->visible;
$sql .= ", fk_parent = ".(int) $this->fk_parent;
$sql .= ", fk_user_modif = ".(int) $user->id;
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
$action = 'update';
// Actions on extra fields
if (!$error)
{
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
}
}
if (!$error)
{
if (!$error) {
// Call trigger
$result = $this->call_trigger('CATEGORY_MODIFY', $user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
@ -586,8 +572,7 @@ class Categorie extends CommonObject
$this->db->begin();
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CATEGORY_DELETE', $user);
if ($result < 0) $error++;
@ -595,14 +580,12 @@ class Categorie extends CommonObject
}
/* FIX #1317 : Check for child category and move up 1 level*/
if (!$error)
{
if (!$error) {
$sql = "UPDATE ".MAIN_DB_PREFIX."categorie";
$sql .= " SET fk_parent = ".$this->fk_parent;
$sql .= " WHERE fk_parent = ".$this->id;
if (!$this->db->query($sql))
{
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$error++;
}
@ -630,18 +613,15 @@ class Categorie extends CommonObject
}
// Removed extrafields
if (!$error)
{
if (!$error) {
$result = $this->deleteExtraFields();
if ($result < 0)
{
if ($result < 0) {
$error++;
dol_syslog(get_class($this)."::delete erreur ".$this->error, LOG_ERR);
}
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -676,29 +656,23 @@ class Categorie extends CommonObject
$sql .= " VALUES (".$this->id.", ".$obj->id.")";
dol_syslog(get_class($this).'::add_type', LOG_DEBUG);
if ($this->db->query($sql))
{
if (!empty($conf->global->CATEGORIE_RECURSIV_ADD))
{
if ($this->db->query($sql)) {
if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
$sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie';
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::add_type", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql) > 0)
{
if ($resql) {
if ($this->db->num_rows($resql) > 0) {
$objparent = $this->db->fetch_object($resql);
if (!empty($objparent->fk_parent))
{
if (!empty($objparent->fk_parent)) {
$cat = new Categorie($this->db);
$cat->id = $objparent->fk_parent;
if (!$cat->containsObject($type, $obj->id)) {
$result = $cat->add_type($obj, $type);
if ($result < 0)
{
if ($result < 0) {
$this->error = $cat->error;
$error++;
}
@ -710,8 +684,7 @@ class Categorie extends CommonObject
$this->error = $this->db->lasterror();
}
if ($error)
{
if ($error) {
$this->db->rollback();
return -1;
}
@ -725,8 +698,7 @@ class Categorie extends CommonObject
if ($result < 0) { $error++; }
// End call triggers
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -735,8 +707,7 @@ class Categorie extends CommonObject
}
} else {
$this->db->rollback();
if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$this->error = $this->db->lasterrno();
return -3;
} else {
@ -778,16 +749,14 @@ class Categorie extends CommonObject
$sql .= " AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".$obj->id;
dol_syslog(get_class($this).'::del_type', LOG_DEBUG);
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
// Call trigger
$this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger
$result = $this->call_trigger('CATEGORY_UNLINK', $user);
if ($result < 0) { $error++; }
// End call triggers
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -829,8 +798,7 @@ class Categorie extends CommonObject
$sql .= " AND c.fk_categorie = ".$this->id;
$sql .= " AND c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = o.rowid";
// 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;
}
if ($limit > 0 || $offset > 0) $sql .= $this->db->plimit($limit + 1, $offset);
@ -838,10 +806,8 @@ class Categorie extends CommonObject
dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
while ($rec = $this->db->fetch_array($resql))
{
if ($resql) {
while ($rec = $this->db->fetch_array($resql)) {
if ($onlyids) {
$objs[] = $rec['fk_'.(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])];
} else {
@ -927,20 +893,17 @@ class Categorie extends CommonObject
$offset = 0;
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $this->db->query($sql);
$nbtotalofrecords = $this->db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
}
if ($limit) {
if ($page < 0)
{
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@ -949,17 +912,14 @@ class Categorie extends CommonObject
}
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$i = 0;
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
while ($i < $min) {
$obj = $this->db->fetch_object($result);
$category_static = new Categorie($this->db);
if ($category_static->fetch($obj->rowid))
{
if ($category_static->fetch($obj->rowid)) {
$categories[$i]['id'] = $category_static->id;
$categories[$i]['fk_parent'] = $category_static->fk_parent;
$categories[$i]['label'] = $category_static->label;
@ -1004,11 +964,9 @@ class Categorie extends CommonObject
$sql .= " AND entity IN (".getEntity('category').")";
$res = $this->db->query($sql);
if ($res)
{
if ($res) {
$cats = array();
while ($rec = $this->db->fetch_array($res))
{
while ($rec = $this->db->fetch_array($res)) {
$cat = new Categorie($this->db);
$cat->fetch($rec['rowid']);
$cats[] = $cat;
@ -1039,10 +997,8 @@ class Categorie extends CommonObject
dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$this->motherof[$obj->id_son] = $obj->id_parent;
}
return 1;
@ -1083,19 +1039,15 @@ class Categorie extends CommonObject
return -1;
}
if (is_string($markafterid))
{
if (is_string($markafterid)) {
$markafterid = explode(',', $markafterid);
} elseif (is_numeric($markafterid))
{
if ($markafterid > 0)
{
} elseif (is_numeric($markafterid)) {
if ($markafterid > 0) {
$markafterid = array($markafterid);
} else {
$markafterid = array();
}
} elseif (!is_array($markafterid))
{
} elseif (!is_array($markafterid)) {
$markafterid = array();
}
@ -1115,11 +1067,9 @@ class Categorie extends CommonObject
dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$i = 0;
while ($obj = $this->db->fetch_object($resql))
{
while ($obj = $this->db->fetch_object($resql)) {
$this->cats[$obj->rowid]['rowid'] = $obj->rowid;
$this->cats[$obj->rowid]['id'] = $obj->rowid;
$this->cats[$obj->rowid]['fk_parent'] = $obj->fk_parent;
@ -1137,15 +1087,13 @@ class Categorie extends CommonObject
// We add the fullpath property to each elements of first level (no parent exists)
dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG);
foreach ($this->cats as $key => $val)
{
foreach ($this->cats as $key => $val) {
//print 'key='.$key.'<br>'."\n";
$this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent)
}
// Include or exclude leaf including $markafterid from tree
if (count($markafterid) > 0)
{
if (count($markafterid) > 0) {
$keyfiltercatid = '('.implode('|', $markafterid).')';
//print "Look to discard category ".$markafterid."\n";
@ -1153,13 +1101,11 @@ class Categorie extends CommonObject
$keyfilter2 = '_'.$keyfiltercatid.'$';
$keyfilter3 = '^'.$keyfiltercatid.'_';
$keyfilter4 = '_'.$keyfiltercatid.'_';
foreach ($this->cats as $key => $val)
{
foreach ($this->cats as $key => $val) {
$test = (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath'])
|| preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath']));
if (($test && !$include) || (!$test && $include))
{
if (($test && !$include) || (!$test && $include)) {
unset($this->cats[$key]);
}
}
@ -1189,8 +1135,7 @@ class Categorie extends CommonObject
// phpcs:enable
dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
if (!empty($this->cats[$id_categ]['fullpath']))
{
if (!empty($this->cats[$id_categ]['fullpath'])) {
// Already defined
dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
return;
@ -1204,8 +1149,7 @@ class Categorie extends CommonObject
$this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
$i = 0; $cursor_categ = $id_categ;
//print 'Work for id_categ='.$id_categ.'<br>'."\n";
while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ]))
{
while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) {
//print '&nbsp; cursor_categ='.$cursor_categ.' i='.$i.' '.$this->motherof[$cursor_categ].'<br>'."\n";
$this->cats[$id_categ]['fullpath'] = '_'.$this->motherof[$cursor_categ].$this->cats[$id_categ]['fullpath'];
$this->cats[$id_categ]['fulllabel'] = $this->cats[$this->motherof[$cursor_categ]]['label'].' >> '.$this->cats[$id_categ]['fulllabel'];
@ -1231,8 +1175,7 @@ class Categorie extends CommonObject
{
// phpcs:enable
// Display $this->cats
foreach ($this->cats as $key => $val)
{
foreach ($this->cats as $key => $val) {
print 'id: '.$this->cats[$key]['id'];
print ' label: '.$this->cats[$key]['label'];
print ' mother: '.$this->cats[$key]['fk_parent'];
@ -1260,16 +1203,14 @@ class Categorie extends CommonObject
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$sql .= " WHERE entity IN (".getEntity('category').")";
if (!is_null($type))
$sql .= " AND type = ".$type;
$sql .= " AND type = ".(int) $type;
if ($parent)
$sql .= " AND fk_parent = 0";
$res = $this->db->query($sql);
if ($res)
{
if ($res) {
$cats = array();
while ($rec = $this->db->fetch_array($res))
{
while ($rec = $this->db->fetch_array($res)) {
$cat = new Categorie($this->db);
$cat->fetch($rec['rowid']);
$cats[$rec['rowid']] = $cat;
@ -1319,18 +1260,15 @@ class Categorie extends CommonObject
dol_syslog(get_class($this)."::already_exists", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql) > 0) // Checking for empty resql
{
if ($resql) {
if ($this->db->num_rows($resql) > 0) { // Checking for empty resql
$obj = $this->db->fetch_array($resql);
/* If object called create, obj cannot have is id.
* If object called update, he mustn't have the same label as an other category for this mother.
* So if the result have the same id, update is not for label, and if result have an other one,
* update may be for label.
*/
if ($obj[0] > 0 && $obj[0] != $this->id)
{
if ($obj[0] > 0 && $obj[0] != $this->id) {
dol_syslog(get_class($this)."::already_exists category with name=".$this->label." and parent ".$this->fk_parent." exists: rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG);
return 1;
}
@ -1361,24 +1299,19 @@ class Categorie extends CommonObject
$ways = array();
$allways = $this->get_all_ways(); // Load array of categories
foreach ($allways as $way)
{
foreach ($allways as $way) {
$w = array();
$i = 0;
$forced_color = '';
foreach ($way as $cat)
{
foreach ($way as $cat) {
$i++;
if (empty($nocolor))
{
if (empty($nocolor)) {
$forced_color = 'toreplace';
if ($i == count($way))
{
if ($i == count($way)) {
// Check contrast with background and correct text color
$forced_color = 'categtextwhite';
if ($cat->color)
{
if ($cat->color) {
if (colorIsLight($cat->color)) $forced_color = 'categtextblack';
}
}
@ -1421,12 +1354,9 @@ class Categorie extends CommonObject
$res = $this->db->query($sql);
if ($res)
{
while ($rec = $this->db->fetch_array($res))
{
if ($rec['fk_parent'] > 0)
{
if ($res) {
while ($rec = $this->db->fetch_array($res)) {
if ($rec['fk_parent'] > 0) {
$cat = new Categorie($this->db);
$cat->fetch($rec['fk_parent']);
$parents[] = $cat;
@ -1452,13 +1382,10 @@ class Categorie extends CommonObject
$ways = array();
$parents = $this->get_meres();
if (!empty($parents))
{
foreach ($parents as $parent)
{
if (!empty($parents)) {
foreach ($parents as $parent) {
$allways = $parent->get_all_ways();
foreach ($allways as $way)
{
foreach ($allways as $way) {
$w = $way;
$w[] = $this;
$ways[] = $w;
@ -1488,8 +1415,7 @@ class Categorie extends CommonObject
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type];
if ($type === Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code
{
if ($type === Categorie::TYPE_BANK_LINE) { // TODO Remove this with standard category code
// Load bank groups
$sql = "SELECT c.label, c.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
@ -1497,10 +1423,8 @@ class Categorie extends CommonObject
$sql .= " ORDER BY c.label";
$res = $this->db->query($sql);
if ($res)
{
while ($obj = $this->db->fetch_object($res))
{
if ($res) {
while ($obj = $this->db->fetch_object($res)) {
if ($mode == 'id') {
$cats[] = $obj->rowid;
} elseif ($mode == 'label') {
@ -1523,10 +1447,8 @@ class Categorie extends CommonObject
$sql .= " AND c.entity IN (".getEntity('category').")";
$res = $this->db->query($sql);
if ($res)
{
while ($obj = $this->db->fetch_object($res))
{
if ($res) {
while ($obj = $this->db->fetch_object($res)) {
if ($mode == 'id') {
$cats[] = $obj->rowid;
} elseif ($mode == 'label') {
@ -1579,24 +1501,20 @@ class Categorie extends CommonObject
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$sql .= " WHERE type = ".$this->MAP_ID[$type];
$sql .= " AND entity IN (".getEntity('category').")";
if ($nom)
{
if ($nom) {
if (!$exact)
$nom = '%'.str_replace('*', '%', $nom).'%';
if (!$case)
$sql .= " AND label LIKE '".$this->db->escape($nom)."'";
else $sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'";
}
if ($id)
{
if ($id) {
$sql .= " AND rowid = '".$id."'";
}
$res = $this->db->query($sql);
if ($res)
{
while ($rec = $this->db->fetch_array($res))
{
if ($res) {
while ($rec = $this->db->fetch_array($res)) {
$cat = new Categorie($this->db);
$cat->fetch($rec['rowid']);
$cats[] = $cat;
@ -1628,8 +1546,7 @@ class Categorie extends CommonObject
// Check contrast with background and correct text color
$forced_color = 'categtextwhite';
if ($this->color)
{
if ($this->color) {
if (colorIsLight($this->color)) $forced_color = 'categtextblack';
}
@ -1662,14 +1579,12 @@ class Categorie extends CommonObject
$dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, 'category').$this->id."/";
$dir .= "photos/";
if (!file_exists($dir))
{
if (!file_exists($dir)) {
dol_mkdir($dir);
}
if (file_exists($dir)) {
if (is_array($file['name']) && count($file['name']) > 0)
{
if (is_array($file['name']) && count($file['name']) > 0) {
$nbfile = count($file['name']);
for ($i = 0; $i <= $nbfile; $i++) {
$originImage = $dir.$file['name'][$i];
@ -1714,22 +1629,17 @@ class Categorie extends CommonObject
$dirthumb = $dir.'thumbs/';
if (file_exists($dir))
{
if (file_exists($dir)) {
$handle = opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file))
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) {
$nbphoto++;
$photo = $file;
// On determine nom du fichier vignette
$photo_vignette = '';
if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs))
{
if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) {
$photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0];
}
@ -1773,11 +1683,9 @@ class Categorie extends CommonObject
dol_delete_file($file, 1);
// Si elle existe, on efface la vignette
if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs))
{
if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs)) {
$photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_small'.$regs[0];
if (file_exists($dirthumb.$photo_vignette))
{
if (file_exists($dirthumb.$photo_vignette)) {
dol_delete_file($dirthumb.$photo_vignette, 1);
}
}
@ -1812,8 +1720,7 @@ class Categorie extends CommonObject
$langs_available = $langs->get_available_languages();
$current_lang = $langs->getDefaultLang();
foreach ($langs_available as $key => $value)
{
foreach ($langs_available as $key => $value) {
$sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang";
$sql .= " WHERE fk_category=".$this->id;
@ -1821,10 +1728,8 @@ class Categorie extends CommonObject
$result = $this->db->query($sql);
if ($key == $current_lang)
{
if ($this->db->num_rows($result)) // si aucune ligne dans la base
{
if ($key == $current_lang) {
if ($this->db->num_rows($result)) { // si aucune ligne dans la base
$sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
$sql2 .= " SET label='".$this->db->escape($this->label)."',";
$sql2 .= " description='".$this->db->escape($this->description)."'";
@ -1835,15 +1740,12 @@ class Categorie extends CommonObject
$sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
}
dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
if (!$this->db->query($sql2))
{
if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror();
return -1;
}
} elseif (isset($this->multilangs["$key"]))
{
if ($this->db->num_rows($result)) // si aucune ligne dans la base
{
} elseif (isset($this->multilangs["$key"])) {
if ($this->db->num_rows($result)) { // si aucune ligne dans la base
$sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
$sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
$sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
@ -1857,8 +1759,7 @@ class Categorie extends CommonObject
// on ne sauvegarde pas des champs vides
if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"])
dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
if (!$this->db->query($sql2))
{
if (!$this->db->query($sql2)) {
$this->error = $this->db->lasterror();
return -1;
}
@ -1892,13 +1793,10 @@ class Categorie extends CommonObject
$sql .= " WHERE fk_category=".$this->id;
$result = $this->db->query($sql);
if ($result)
{
while ($obj = $this->db->fetch_object($result))
{
if ($result) {
while ($obj = $this->db->fetch_object($result)) {
//print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
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->description = $obj->description;
}
@ -1988,26 +1886,21 @@ class Categorie extends CommonObject
{
if ($type == 'bank_account') $type = 'account';
if (empty($searchList) && !is_array($searchList))
{
if (empty($searchList) && !is_array($searchList)) {
return "";
}
foreach ($searchList as $searchCategory)
{
if (intval($searchCategory) == -2)
{
foreach ($searchList as $searchCategory) {
if (intval($searchCategory) == -2) {
$searchCategorySqlList[] = " cp.fk_categorie IS NULL";
} elseif (intval($searchCategory) > 0)
{
} elseif (intval($searchCategory) > 0) {
$searchCategorySqlList[] = " ".$rowIdName
." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type
." WHERE fk_categorie = ".$searchCategory.")";
}
}
if (!empty($searchCategorySqlList))
{
if (!empty($searchCategorySqlList)) {
return " AND (".implode(' AND ', $searchCategorySqlList).")";
} else {
return "";

View File

@ -34,7 +34,7 @@ $langs->load("categories");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alphanohtml');
$type = GETPOST('type', 'alphanohtml');
$type = (int) GETPOST('type', 'int');
$action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit');
$confirm = GETPOST('confirm');
$cancel = GETPOST('cancel', 'alpha');
@ -43,11 +43,10 @@ $socid = GETPOST('socid', 'int');
$label = GETPOST('label', 'alphanohtml');
$description = GETPOST('description', 'restricthtml');
$color = preg_replace('/[^0-9a-f#]/i', '', GETPOST('color', 'alphanohtml'));
$visible = GETPOST('visible');
$parent = GETPOST('parent');
$visible = (int) GETPOST('visible', 'int');
$parent = (int) GETPOST('parent', 'int');
if ($id == "")
{
if ($id == "") {
dol_print_error('', 'Missing parameter id');
exit();
}
@ -56,8 +55,7 @@ if ($id == "")
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
if ($id > 0)
{
if ($id > 0) {
$result = $object->fetch($id);
}
@ -72,40 +70,32 @@ $hookmanager->initHooks(array('categorycard'));
* Actions
*/
if ($cancel)
{
if ($cancel) {
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
exit;
}
// Action mise a jour d'une categorie
if ($action == 'update' && $user->rights->categorie->creer)
{
if ($action == 'update' && $user->rights->categorie->creer) {
$object->oldcopy = dol_clone($object);
$object->label = $label;
$object->description = dol_htmlcleanlastbr($description);
$object->color = $color;
$object->socid = ($socid ? $socid : 'null');
$object->visible = $visible;
if ($parent != "-1")
$object->fk_parent = $parent;
else $object->fk_parent = "";
$object->fk_parent = $parent != -1 ? $parent : 0;
if (empty($object->label))
{
if (empty($object->label)) {
$error++;
$action = 'edit';
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
}
if (!$error && empty($object->error))
{
if (!$error && empty($object->error)) {
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (!$error && $object->update($user) > 0)
{
if (!$error && $object->update($user) > 0) {
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
exit;
} else {
@ -173,8 +163,7 @@ print '</td></tr>';
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit', $parameters);
}

View File

@ -3952,7 +3952,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss
* However, one must try to call it only within php pages, classes must return their error through their property "error".
*
* @param DoliDB $db Database handler
* @param string|[string] $error String or array of errors strings to show
* @param string|string[] $error String or array of errors strings to show
* @param array $errors Array of errors
* @return void
* @see dol_htmloutput_errors()
@ -6691,7 +6691,7 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
* Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function.
* Note: Prefer to use setEventMessages instead.
*
* @param string|[string] $mesgs Message string or array
* @param string|string[] $mesgs Message string or array
* @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors')
* @return void
* @see dol_htmloutput_events()

View File

@ -108,7 +108,7 @@ if ($permission)
<?php
$tmpobject = $object;
if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc;
echo $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal');
$formcompany->selectTypeContact($tmpobject, '', 'type', 'internal');
?></div>
<div class="tagtd">&nbsp;</div>
<div class="tagtd center"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>"></div>
@ -117,8 +117,7 @@ if ($permission)
<?php
}
if (empty($hideaddcontactforthirdparty))
{
if (empty($hideaddcontactforthirdparty)) {
?>
<form class="tagtr pair nohover" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">

View File

@ -52,7 +52,14 @@ $arrayofjs = array(
'/includes/jstz/jstz.min.js'.(empty($conf->dol_use_jmobile) ? '' : '?version='.urlencode(DOL_VERSION)),
'/core/js/dst.js'.(empty($conf->dol_use_jmobile) ? '' : '?version='.urlencode(DOL_VERSION))
);
$titleofloginpage = $langs->trans('Login').' @ '.$titletruedolibarrversion; // $titletruedolibarrversion is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page and find true dolibarr version.
// We display application title instead Login term
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$titleofloginpage = $conf->global->MAIN_APPLICATION_TITLE;
} else {
$titleofloginpage = $langs->trans('Login');
}
$titleofloginpage.= ' @ '.$titletruedolibarrversion; // $titletruedolibarrversion is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page and find true dolibarr version.
$disablenofollow = 1;
if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) $disablenofollow = 0;

View File

@ -152,7 +152,7 @@ class DataPolicy
* @param mixed $contact Contact
* @return void
*/
public function sendMailDataPolicyContact($contact)
public static function sendMailDataPolicyContact($contact)
{
global $langs, $conf, $db, $user;
@ -167,6 +167,7 @@ class DataPolicy
} else {
$l = $langs->defaultlang;
}
// TODO Use a dolibarr email template
$s = "DATAPOLICIESSUBJECT_".$l;
$ma = "DATAPOLICIESCONTENT_".$l;
$la = 'TXTLINKDATAPOLICIESACCEPT_'.$l;
@ -226,7 +227,7 @@ class DataPolicy
* @param Societe $societe Object societe
* @return void
*/
public function sendMailDataPolicyCompany($societe)
public static function sendMailDataPolicyCompany($societe)
{
global $langs, $conf, $db, $user;
@ -242,6 +243,7 @@ class DataPolicy
} else {
$l = $langs->defaultlang;
}
// TODO Use a dolibarr email template
$s = "DATAPOLICIESSUBJECT_".$l;
$ma = "DATAPOLICIESCONTENT_".$l;
$la = 'TXTLINKDATAPOLICIESACCEPT_'.$l;
@ -264,10 +266,8 @@ class DataPolicy
$actiontypecode = 'AC_EMAIL';
$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
if ($message)
{
if ($sendtocc)
{
if ($message) {
if ($sendtocc) {
$actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc);
}
$actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
@ -300,7 +300,7 @@ class DataPolicy
* @param Adherent $adherent Member
* @return void
*/
public function sendMailDataPolicyAdherent($adherent)
public static function sendMailDataPolicyAdherent($adherent)
{
global $langs, $conf, $db, $user;
@ -310,9 +310,6 @@ class DataPolicy
$sendto = $adherent->email;
// TODO Use a dolibarr email template
$s = 'TXTLINKDATAPOLICIESSUBJECT_'.$l;
$ma = 'TXTLINKDATAPOLICIESMESSAGE_'.$l;
$code = md5($adherent->email);
if (!empty($adherent->default_lang)) {
@ -320,6 +317,9 @@ class DataPolicy
} else {
$l = $langs->defaultlang;
}
// TODO Use a dolibarr email template
$s = 'TXTLINKDATAPOLICIESSUBJECT_'.$l;
$ma = 'TXTLINKDATAPOLICIESMESSAGE_'.$l;
$la = 'TXTLINKDATAPOLICIESACCEPT_'.$l;
$lr = 'TXTLINKDATAPOLICIESREFUSE_'.$l;

View File

@ -67,8 +67,19 @@ class Delivery extends CommonObject
*/
public $picto = 'sending';
public $draft;
public $socid;
/**
* @var int draft status
*/
public $draft;
/**
* @var int thirdparty id
*/
public $socid;
/**
* @var string ref custome
*/
public $ref_customer;
/**
@ -86,7 +97,9 @@ class Delivery extends CommonObject
*/
public $date_valid;
/**
* @var string model pdf
*/
public $model_pdf;

View File

@ -6,7 +6,7 @@
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.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
@ -97,6 +97,10 @@ class Don extends CommonObject
* @var string Email
*/
public $email;
/**
* @var int 0 or 1
*/
public $public;
/**
@ -111,7 +115,11 @@ class Don extends CommonObject
public $num_payment;
public $date_valid;
public $modepaymentid = 0;
/**
* @var int payment mode id
*/
public $modepaymentid = 0;
/**
* @var array Array of status label
@ -230,7 +238,7 @@ class Don extends CommonObject
$this->socid = 1;
$this->date = $now;
$this->date_valid = $now;
$this->amount = 100;
$this->amount = 100.90;
$this->public = 1;
$this->societe = 'The Company';
$this->address = 'Twist road';
@ -239,7 +247,8 @@ class Don extends CommonObject
$this->note_private = 'Private note';
$this->note_public = 'Public note';
$this->email = 'email@email.com';
$this->note = '';
$this->phone = '0123456789';
$this->phone_mobile = '0606060606';
$this->statut = 1;
}
@ -392,17 +401,17 @@ class Don extends CommonObject
$sql .= ", '".$this->db->escape($this->address)."'";
$sql .= ", '".$this->db->escape($this->zip)."'";
$sql .= ", '".$this->db->escape($this->town)."'";
$sql .= ", ".($this->country_id > 0 ? $this->country_id : '0');
$sql .= ", ".((int) $this->public);
$sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null");
$sql .= ", ".(int) ($this->country_id > 0 ? $this->country_id : 0);
$sql .= ", ".(int) $this->public;
$sql .= ", ".($this->fk_project > 0 ? (int) $this->fk_project : "null");
$sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL");
$sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL");
$sql .= ", ".$user->id;
$sql .= ", null";
$sql .= ", '".$this->db->idate($this->date)."'";
$sql .= ", '".$this->db->escape($this->email)."'";
$sql .= ", '".$this->db->escape($this->phone)."'";
$sql .= ", '".$this->db->escape($this->phone_mobile)."'";
$sql .= ", '".$this->db->escape(trim($this->email))."'";
$sql .= ", '".$this->db->escape(trim($this->phone))."'";
$sql .= ", '".$this->db->escape(trim($this->phone_mobile))."'";
$sql .= ")";
$resql = $this->db->query($sql);
@ -426,13 +435,9 @@ class Don extends CommonObject
// Update extrafield
if (!$error) {
if (!$error)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
@ -490,9 +495,9 @@ class Don extends CommonObject
$sql .= ",note_public=".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL");
$sql .= ",datedon='".$this->db->idate($this->date)."'";
$sql .= ",date_valid=".($this->date_valid ? "'".$this->db->idate($this->date)."'" : "null");
$sql .= ",email='".$this->db->escape($this->email)."'";
$sql .= ",phone='".$this->db->escape($this->phone)."'";
$sql .= ",phone_mobile='".$this->db->escape($this->phone_mobile)."'";
$sql .= ",email='".$this->db->escape(trim($this->email))."'";
$sql .= ",phone='".$this->db->escape(trim($this->phone))."'";
$sql .= ",phone_mobile='".$this->db->escape(trim($this->phone_mobile))."'";
$sql .= ",fk_statut=".$this->statut;
$sql .= " WHERE rowid = ".$this->id;
@ -511,13 +516,10 @@ class Don extends CommonObject
// Update extrafield
if (!$error)
{
if (!$error)
$result = $this->insertExtraFields();
if ($result < 0)
{
$result = $this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$error++;
}
}
@ -555,18 +557,14 @@ class Don extends CommonObject
$this->db->begin();
if (!$error)
{
if (!$notrigger)
{
// Call trigger
$result = $this->call_trigger('DON_DELETE', $user);
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('DON_DELETE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
if ($result < 0) {
$error++;
}
// End call triggers
}
// Delete donation

View File

@ -2304,7 +2304,8 @@ if ($action == 'create')
if ($action == 'valid')
{
// We check if number is temporary number
if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) { // empty should not happened, but when it occurs, the test save life
if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) {
// empty should not happened, but when it occurs, the test save life
$numref = $object->getNextNumRef($societe);
} else {
$numref = $object->ref;

View File

@ -456,9 +456,12 @@ ALTER TABLE llx_delivery ADD CONSTRAINT fk_delivery_fk_soc FOREIGN KEY (fk_soc
ALTER TABLE llx_delivery ADD CONSTRAINT fk_delivery_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
ALTER TABLE llx_delivery ADD CONSTRAINT fk_delivery_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
ALTER TABLE llx_deliverydet CHANGE COLUMN fk_livraison fk_delivery integer;
ALTER TABLE llx_deliverydet DROP CONSTRAINT fk_livraisondet_fk_livraison;
ALTER TABLE llx_deliverydet DROP INDEX idx_livraisondet_fk_expedition;
ALTER TABLE llx_deliverydet CHANGE COLUMN fk_livraison fk_delivery integer;
ALTER TABLE llx_deliverydet ADD INDEX idx_deliverydet_fk_delivery (fk_delivery);
ALTER TABLE llx_deliverydet ADD CONSTRAINT fk_deliverydet_fk_delivery FOREIGN KEY (fk_delivery) REFERENCES llx_delivery (rowid);
-- update llx_extrafields
UPDATE llx_extrafields SET elementtype = 'delivery' WHERE elementtype = 'livraison';
UPDATE llx_extrafields SET elementtype = 'deliverydet' WHERE elementtype = 'livraisondet';

View File

@ -18,5 +18,5 @@
-- ===================================================================
ALTER TABLE llx_deliverydet ADD INDEX idx_deliverydet_fk_expedition (fk_delivery);
ALTER TABLE llx_deliverydet ADD INDEX idx_deliverydet_fk_delivery (fk_delivery);
ALTER TABLE llx_deliverydet ADD CONSTRAINT fk_deliverydet_fk_delivery FOREIGN KEY (fk_delivery) REFERENCES llx_delivery (rowid);

View File

@ -50,6 +50,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
// Hook added by Payzen.
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('newpayment'));
// Load translation files
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data
@ -202,6 +206,12 @@ if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->strip
// Initialize $validpaymentmethod
$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
// This hook is used to push to $validpaymentmethod the Payzen payment method as valid.
$parameters = [
'paymentmethod' => $paymentmethod,
'validpaymentmethod' => &$validpaymentmethod
];
$reshook = $hookmanager->executeHooks('doValidatePayment', $parameters, $object, $action);
// Check security token
$valid = true;
@ -1641,6 +1651,12 @@ if ($action != 'dopayment')
{
if ($found && !$error) // We are in a management option and no error
{
// Check status of the object (Invoice) to verify if it is paid in Payzen.
$parameters = [
'source' => $source,
'object' => $object
];
$reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action);
if ($source == 'order' && $object->billed)
{
print '<br><br><span class="amountpaymentcomplete">'.$langs->trans("OrderBilled").'</span>';
@ -1661,6 +1677,11 @@ if ($action != 'dopayment')
// Buttons for all payments registration methods
// This hook is used to add Payzen Button to newpayment.php.
$parameters = [
'paymentmethod' => $paymentmethod
];
$reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action);
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled))
{
print '<div class="button buttonpayment" id="div_dopayment_paybox"><span class="fa fa-credit-card"></span> <input class="" type="submit" id="dopayment_paybox" name="dopayment_paybox" value="'.$langs->trans("PayBoxDoPayment").'">';
@ -2249,6 +2270,14 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment
print '</script>';
}
}
// This hook is used to show the embedded form to make payments with Payzen.
$parameters = [
'paymentmethod' => $paymentmethod,
'amount' => price2num(GETPOST("newamount"), 'MT'),
'tag' => GETPOST("tag", 'alpha'),
'dopayment' => GETPOST('dopayment', 'alpha')
];
$reshook = $hookmanager->executeHooks('doPayment', $parameters, $object, $action);
}

View File

@ -293,15 +293,15 @@ if ($result)
$s = '';
if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
{
$s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
$s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$thirdparty_static->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
}
if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
{
$s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
$s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$thirdparty_static->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
}
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur)
{
$s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
$s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$thirdparty_static->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
}
print $s;
print '</td>';

View File

@ -1515,6 +1515,8 @@ class Ticket extends CommonObject
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$sendtocc = '';
$deliveryreceipt = 0;
$mailfile = new CMailFile($subject, $info_sendto['email'], $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, 0);
if ($mailfile->error || $mailfile->errors) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');