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

This commit is contained in:
Florian HENRY 2021-02-12 11:32:07 +01:00
commit f063606f27
11 changed files with 122 additions and 128 deletions

View File

@ -18,6 +18,7 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup.
* API /setup/shipment_methods has been replaced with API /setup/shipping_methods

View File

@ -3,7 +3,7 @@
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2017 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2020 Thibault FOUCART <support@ptibogxiv.net>
*
*
@ -624,63 +624,6 @@ class Setup extends DolibarrApi
}
}
/**
* Get the list of shipment methods.
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
* @param int $active Payment term is active or not {@min 0} {@max 1}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
*
* @return array List of shipment methods
*
* @url GET dictionary/shipment_methods
*
* @throws RestException
*/
public function getListOfShipmentMethods($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{
$list = array();
$sql = "SELECT t.rowid, t.code, t.libelle as label, t.description, t.tracking";
$sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
$sql .= " WHERE t.active = ".$active;
// Add sql filters
if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
$sql .= $this->db->plimit($limit, $offset);
}
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
for ($i = 0; $i < $min; $i++) {
$list[] = $this->db->fetch_object($result);
}
} else {
throw new RestException(503, 'Error when retrieving list of shipment methods : '.$this->db->lasterror());
}
return $list;
}
/**
* Get the list of events types.

View File

@ -40,11 +40,11 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
*/
public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
{
$this->db = $db;
$this->db = $db;
$this->dirmodule = $dirmodule;
$this->targetmodule = $targetmodule;
$this->canvas = $canvas;
$this->card = $card;
$this->targetmodule = $targetmodule;
$this->canvas = $canvas;
$this->card = $card;
}
/**
@ -55,13 +55,19 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
*/
private function getTitle($action)
{
global $langs;
global $langs, $conf;
$out = '';
if ($action == 'view') $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contact") : $langs->trans("ContactAddress"));
if ($action == 'edit') $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("EditContact") : $langs->trans("EditContactAddress"));
if ($action == 'create') $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
if ($action == 'view') {
$out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contact") : $langs->trans("ContactAddress"));
}
if ($action == 'edit') {
$out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("EditContact") : $langs->trans("EditContactAddress"));
}
if ($action == 'create') {
$out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
}
return $out;
}
@ -89,8 +95,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->tpl['error'] = $this->error;
$this->tpl['errors'] = $this->errors;
if ($action == 'view')
{
if ($action == 'view') {
// Card header
$head = contact_prepare_head($this->object);
$title = $this->getTitle($action);
@ -106,14 +111,12 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
} else {
// Confirm delete contact
if ($action == 'delete' && $user->rights->societe->contact->supprimer)
{
if ($action == 'delete' && $user->rights->societe->contact->supprimer) {
$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
}
}
if ($action == 'list')
{
if ($action == 'list') {
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
}
}

View File

@ -260,10 +260,25 @@ class Contact extends CommonObject
public $birthday;
public $default_lang;
public $ref_facturation; // Reference number of invoice for which it is contact
public $ref_contrat; // Nb de reference contrat pour lequel il est contact
public $ref_commande; // Nb de reference commande pour lequel il est contact
public $ref_propal; // Nb de reference propal pour lequel il est contact
/**
* @var int Number of invoices for which he is contact
*/
public $ref_facturation;
/**
* @var int Number of contracts for which he is contact
*/
public $ref_contrat;
/**
* @var int Number of orders for which he is contact
*/
public $ref_commande;
/**
* @var int Number of proposals for which he is contact
*/
public $ref_propal;
/**
* @var int user ID
@ -412,9 +427,15 @@ class Contact extends CommonObject
$this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name);
$this->firstname = trim($this->firstname);
$this->setUpperOrLowerCase();
if (empty($this->socid)) $this->socid = 0;
if (empty($this->priv)) $this->priv = 0;
if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
if (empty($this->socid)) {
$this->socid = 0;
}
if (empty($this->priv)) {
$this->priv = 0;
}
if (empty($this->statut)) {
$this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
}
$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
@ -610,88 +631,72 @@ class Contact extends CommonObject
$tmpobj = new User($this->db);
$tmpobj->fetch($this->user_id);
$usermustbemodified = 0;
if ($tmpobj->office_phone != $this->phone_pro)
{
if ($tmpobj->office_phone != $this->phone_pro) {
$tmpobj->office_phone = $this->phone_pro;
$usermustbemodified++;
}
if ($tmpobj->office_fax != $this->fax)
{
if ($tmpobj->office_fax != $this->fax) {
$tmpobj->office_fax = $this->fax;
$usermustbemodified++;
}
if ($tmpobj->address != $this->address)
{
if ($tmpobj->address != $this->address) {
$tmpobj->address = $this->address;
$usermustbemodified++;
}
if ($tmpobj->town != $this->town)
{
if ($tmpobj->town != $this->town) {
$tmpobj->town = $this->town;
$usermustbemodified++;
}
if ($tmpobj->zip != $this->zip)
{
if ($tmpobj->zip != $this->zip) {
$tmpobj->zip = $this->zip;
$usermustbemodified++;
}
if ($tmpobj->zip != $this->zip)
{
if ($tmpobj->zip != $this->zip) {
$tmpobj->state_id = $this->state_id;
$usermustbemodified++;
}
if ($tmpobj->country_id != $this->country_id)
{
if ($tmpobj->country_id != $this->country_id) {
$tmpobj->country_id = $this->country_id;
$usermustbemodified++;
}
if ($tmpobj->email != $this->email)
{
if ($tmpobj->email != $this->email) {
$tmpobj->email = $this->email;
$usermustbemodified++;
}
if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks)))
{
if (!empty(array_diff($tmpobj->socialnetworks, $this->socialnetworks))) {
$tmpobj->socialnetworks = $this->socialnetworks;
$usermustbemodified++;
}
// if ($tmpobj->skype != $this->skype)
// {
// if ($tmpobj->skype != $this->skype) {
// $tmpobj->skype = $this->skype;
// $usermustbemodified++;
// }
// if ($tmpobj->twitter != $this->twitter)
// {
// if ($tmpobj->twitter != $this->twitter) {
// $tmpobj->twitter = $this->twitter;
// $usermustbemodified++;
// }
// if ($tmpobj->facebook != $this->facebook)
// {
// if ($tmpobj->facebook != $this->facebook) {
// $tmpobj->facebook = $this->facebook;
// $usermustbemodified++;
// }
// if ($tmpobj->linkedin != $this->linkedin)
// {
// if ($tmpobj->linkedin != $this->linkedin) {
// $tmpobj->linkedin = $this->linkedin;
// $usermustbemodified++;
// }
if ($usermustbemodified)
{
if ($usermustbemodified) {
$result = $tmpobj->update($user, 0, 1, 1, 1);
if ($result < 0) { $error++; }
}
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_MODIFY', $user);
if ($result < 0) { $error++; }
// End call triggers
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -723,9 +728,13 @@ class Contact extends CommonObject
// phpcs:enable
global $conf;
$dn = '';
if ($mode == 0) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
elseif ($mode == 1) $dn = $conf->global->LDAP_CONTACT_DN;
elseif ($mode == 2) $dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS];
if ($mode == 0) {
$dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
} elseif ($mode == 1) {
$dn = $conf->global->LDAP_CONTACT_DN;
} elseif ($mode == 2) {
$dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS];
}
return $dn;
}

View File

@ -638,12 +638,15 @@ abstract class CommonObject
$this->lastname = dol_ucwords(dol_strtolower($this->lastname));
$this->firstname = dol_ucwords(dol_strtolower($this->firstname));
$this->name = dol_ucwords(dol_strtolower($this->name));
$this->name_alias = dol_ucwords(dol_strtolower($this->name_alias));
}
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) {
$this->lastname = dol_strtoupper($this->lastname);
$this->name = dol_strtoupper($this->name);
$this->name_alias = dol_strtoupper($this->name_alias);
}
if (!empty($conf->global->MAIN_ALL_TOWN_TO_UPPER)) {
$this->address = dol_strtoupper($this->address);
$this->town = dol_strtoupper($this->town);
}
}

View File

@ -736,8 +736,8 @@ class CommandeFournisseur extends CommonOrder
}
if ($status == 5 && $billed) $statusClass = 'status6';
$statusLong = $langs->trans($this->statuts[$status]).$billedtext;
$statusShort = $langs->trans($this->statutshort[$status]);
$statusLong = $langs->transnoentitiesnoconv($this->statuts[$status]).$billedtext;
$statusShort = $langs->transnoentitiesnoconv($this->statutshort[$status]);
return dolGetStatus($statusLong, $statusShort, '', $statusClass, $mode);
}

View File

@ -1712,7 +1712,8 @@ if (is_array($listofmodules) && count($listofmodules) > 0) {
$urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1);
$linktoenabledisable .= ' &nbsp; <a href="'.$urltouse.(preg_match('/\?/', $urltouse) ? '&' : '?').'save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').'</a>';
} else {
$urltouse = $urlpage;
// Case standard admin page (not a page provided by the module but a page
$urltouse = DOL_URL_ROOT.'/admin/'.$urlpage;
$linktoenabledisable .= ' &nbsp; <a href="'.$urltouse.(preg_match('/\?/', $urltouse) ? '&' : '?').'save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').'</a>';
}
}

View File

@ -159,6 +159,40 @@ class MouvementStock extends CommonObject
$error = 0;
dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse_id=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.", eatby=".$eatby.", sellby=".$sellby.", batch=".$batch.", skip_batch=".$skip_batch);
// start hook at beginning
global $action, $hookmanager;
$hookmanager->initHooks(array('mouvementstock'));
// Hook of thirdparty module
if (is_object($hookmanager)) {
$parameters = array(
'currentcontext' => 'mouvementstock',
'user' => &$user,
'fk_product' => &$fk_product,
'entrepot_id' => &$entrepot_id,
'qty' => &$qty,
'type' => &$type,
'price' => &$price,
'label' => &$label,
'inventorycode' => &$inventorycode,
'datem' => &$datem,
'eatby' => &$eatby,
'sellby' => &$sellby,
'batch' => &$batch,
'skip_batch' => &$skip_batch,
'id_product_batch' => &$id_product_batch
);
$reshook = $hookmanager->executeHooks('stockMovementCreate', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
if (!empty($hookmanager->resPrint))
dol_print_error('', $hookmanager->resPrint);
return $reshook;
} elseif ($reshook > 0) {
return $hookmanager->resPrint;
}
}
// end hook at beginning
// Clean parameters
$price = price2num($price, 'MU'); // Clean value for the casse we receive a float zero value, to have it a real zero value.
if (empty($price)) $price = 0;

View File

@ -187,7 +187,7 @@ class SupplierProposalTest extends PHPUnit\Framework\TestCase
/**
* testSupplierProposalAddLine
*
* @param int $localobject Proposal
* @param SupplierProposal $localobject Proposal
* @return void
*
* @depends testSupplierProposalFetch

View File

@ -174,7 +174,7 @@ class UserGroupTest extends PHPUnit\Framework\TestCase
/**
* testUserGroupUpdate
*
* @param Object $localobject Group
* @param UserGroup $localobject Group
* @return void
* @depends testUserGroupFetch
* The depends says test is run only if previous is ok
@ -198,7 +198,7 @@ class UserGroupTest extends PHPUnit\Framework\TestCase
/**
* testUserGroupAddRight
*
* @param Object $localobject Object to show
* @param UserGroup $localobject Object to show
* @return void
* @depends testUserGroupUpdate
* The depends says test is run only if previous is ok
@ -221,7 +221,7 @@ class UserGroupTest extends PHPUnit\Framework\TestCase
/**
* testUserGroupDelRight
*
* @param Object $localobject Object
* @param UserGroup $localobject Object
* @return void
* @depends testUserGroupAddRight
* The depends says test is run only if previous is ok
@ -244,7 +244,7 @@ class UserGroupTest extends PHPUnit\Framework\TestCase
/**
* testUserGroupOther
*
* @param Object $localobject Object
* @param UserGroup $localobject Object
* @return void
* @depends testUserGroupDelRight
* The depends says test is run only if previous is ok

View File

@ -179,7 +179,7 @@ class UserTest extends PHPUnit\Framework\TestCase
/**
* testUserUpdate
*
* @param Object $localobject User
* @param User $localobject User
* @return void
* @depends testUserFetch
* The depends says test is run only if previous is ok
@ -210,7 +210,7 @@ class UserTest extends PHPUnit\Framework\TestCase
/**
* testUserDisable
*
* @param Object $localobject User
* @param User $localobject User
* @return void
* @depends testUserUpdate
* The depends says test is run only if previous is ok
@ -234,7 +234,7 @@ class UserTest extends PHPUnit\Framework\TestCase
/**
* testUserOther
*
* @param Object $localobject User
* @param User $localobject User
* @return void
* @depends testUserDisable
* The depends says test is run only if previous is ok
@ -262,7 +262,7 @@ class UserTest extends PHPUnit\Framework\TestCase
/**
* testUserDelete
*
* @param Object $id User
* @param int $id User id
* @return void
* @depends testUserOther
* The depends says test is run only if previous is ok
@ -287,7 +287,7 @@ class UserTest extends PHPUnit\Framework\TestCase
/**
* testUserAddPermission
*
* @param Object $id User
* @param int $id User id
* @return void
* @depends testUserDelete
* The depends says test is run only if previous is ok
@ -314,7 +314,7 @@ class UserTest extends PHPUnit\Framework\TestCase
/**
* Edit an object to test updates
*
* @param mixed $localobject Object User
* @param Object $localobject Object User
* @return void
*/
public function changeProperties(&$localobject)