From fa78ab7c66336ce6283d3274685d68a3ddb61978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 16 Oct 2018 23:20:13 +0200 Subject: [PATCH 1/8] do not trim int --- htdocs/contrat/class/contrat.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 398da806c2d..7e0c2d13ca5 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -10,6 +10,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015-2017 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2018 Frédéric France * * 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 @@ -2887,9 +2888,9 @@ class ContratLigne extends CommonObjectLine $error=0; // Clean parameters - $this->fk_contrat=trim($this->fk_contrat); - $this->fk_product=trim($this->fk_product); - $this->statut=(int) $this->statut; + $this->fk_contrat = (int) $this->fk_contrat; + $this->fk_product = (int) $this->fk_product; + $this->statut = (int) $this->statut; $this->label=trim($this->label); $this->description=trim($this->description); $this->vat_src_code=trim($this->vat_src_code); @@ -2899,7 +2900,7 @@ class ContratLigne extends CommonObjectLine $this->qty=trim($this->qty); $this->remise_percent=trim($this->remise_percent); $this->remise=trim($this->remise); - $this->fk_remise_except=trim($this->fk_remise_except); + $this->fk_remise_except = (int) $this->fk_remise_except; $this->subprice=price2num($this->subprice); $this->price_ht=price2num($this->price_ht); $this->total_ht=trim($this->total_ht); @@ -2908,9 +2909,9 @@ class ContratLigne extends CommonObjectLine $this->total_localtax2=trim($this->total_localtax2); $this->total_ttc=trim($this->total_ttc); $this->info_bits=trim($this->info_bits); - $this->fk_user_author=trim($this->fk_user_author); - $this->fk_user_ouverture=trim($this->fk_user_ouverture); - $this->fk_user_cloture=trim($this->fk_user_cloture); + $this->fk_user_author = (int) $this->fk_user_author; + $this->fk_user_ouverture = (int) $this->fk_user_ouverture; + $this->fk_user_cloture = (int) $this->fk_user_cloture; $this->commentaire=trim($this->commentaire); //if (empty($this->subprice)) $this->subprice = 0; if (empty($this->price_ht)) $this->price_ht = 0; From 27b7cf8beaa34985efc3c193504a9d9c0a16a3d0 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 16 Oct 2018 23:31:19 +0200 Subject: [PATCH 2/8] Fix uniformization dates of order in API --- htdocs/commande/class/commande.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c588830d83d..7f2a8c98dbe 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -155,7 +155,10 @@ class Commande extends CommonOrder public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...) public $demand_reason_code; public $date; // Date commande - + public $date_creation; // Date commande + public $date_validation; // Date commande + public $date_modification; // Date commande + /** * @deprecated * @see date @@ -1620,7 +1623,7 @@ class Commande extends CommonOrder $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql.= ', c.fk_account'; - $sql.= ', c.date_commande'; + $sql.= ', c.date_commande, c.date_valid, c.tms'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_shipping_method'; $sql.= ', c.fk_warehouse'; @@ -1673,6 +1676,9 @@ class Commande extends CommonOrder $this->total_ttc = $obj->total_ttc; $this->date = $this->db->jdate($obj->date_commande); $this->date_commande = $this->db->jdate($obj->date_commande); + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_validation = $this->db->jdate($obj->date_valid); + $this->date_modification = $this->db->jdate($obj->tms); $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; From 70b6c502dab209a0db427df3e0132e7d1f975a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 16 Oct 2018 23:36:00 +0200 Subject: [PATCH 3/8] Update menubase.class.php --- htdocs/core/class/menubase.class.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 0daf4fe56da..17ada096fd1 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2018 Frédéric France * * 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 @@ -59,15 +60,18 @@ class Menubase public $fk_menu; /** - * @var int ID + * @var string fk_mainmenu */ public $fk_mainmenu; /** - * @var int ID + * @var string fk_leftmenu */ public $fk_leftmenu; + /** + * @var int position + */ public $position; public $url; public $target; @@ -111,10 +115,10 @@ class Menubase $this->type=trim($this->type); $this->mainmenu=trim($this->mainmenu); $this->leftmenu=trim($this->leftmenu); - $this->fk_menu=trim($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_leftmenu=trim($this->fk_leftmenu); - $this->position=trim($this->position); + $this->position = (int) $this->position; $this->url=trim($this->url); $this->target=trim($this->target); $this->titre=trim($this->titre); @@ -155,7 +159,7 @@ class Menubase $sql = "SELECT count(*)"; $sql.= " FROM ".MAIN_DB_PREFIX."menu"; $sql.= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'"; - $sql.= " AND fk_menu = ".((int) $this->db->escape($this->fk_menu)); + $sql.= " AND fk_menu = ".((int) $this->fk_menu); $sql.= " AND position = ".((int) $this->position); $sql.= " AND url = '".$this->db->escape($this->url)."'"; $sql.= " AND entity = ".$conf->entity; @@ -252,10 +256,10 @@ class Menubase $this->type=trim($this->type); $this->mainmenu=trim($this->mainmenu); $this->leftmenu=trim($this->leftmenu); - $this->fk_menu=trim($this->fk_menu); + $this->fk_menu = (int) $this->fk_menu; $this->fk_mainmenu=trim($this->fk_mainmenu); $this->fk_leftmenu=trim($this->fk_leftmenu); - $this->position=trim($this->position); + $this->position = (int) $this->position; $this->url=trim($this->url); $this->target=trim($this->target); $this->titre=trim($this->titre); @@ -274,7 +278,7 @@ class Menubase $sql.= " type='".$this->db->escape($this->type)."',"; $sql.= " mainmenu='".$this->db->escape($this->mainmenu)."',"; $sql.= " leftmenu='".$this->db->escape($this->leftmenu)."',"; - $sql.= " fk_menu='".$this->db->escape($this->fk_menu)."',"; + $sql.= " fk_menu=".$this->fk_menu.","; $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.= " position=".($this->position > 0 ? $this->position : 0).","; From 7c35eae2026ac0eb96e1ed6f11acf71cf2981936 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 17 Oct 2018 00:06:24 +0200 Subject: [PATCH 4/8] Update commande.class.php --- htdocs/commande/class/commande.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7f2a8c98dbe..4f5051f3411 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -155,9 +155,9 @@ class Commande extends CommonOrder public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...) public $demand_reason_code; public $date; // Date commande - public $date_creation; // Date commande - public $date_validation; // Date commande - public $date_modification; // Date commande + public $date_creation; // Date commande + public $date_validation; // Date commande + public $date_modification; // Date commande /** * @deprecated @@ -1676,9 +1676,9 @@ class Commande extends CommonOrder $this->total_ttc = $obj->total_ttc; $this->date = $this->db->jdate($obj->date_commande); $this->date_commande = $this->db->jdate($obj->date_commande); - $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_validation = $this->db->jdate($obj->date_valid); - $this->date_modification = $this->db->jdate($obj->tms); + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_validation = $this->db->jdate($obj->date_valid); + $this->date_modification = $this->db->jdate($obj->tms); $this->remise = $obj->remise; $this->remise_percent = $obj->remise_percent; $this->remise_absolue = $obj->remise_absolue; From f2d0004a3e542afb3f520dccc9b0bf7eb9515821 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 17 Oct 2018 00:36:40 +0200 Subject: [PATCH 5/8] ADD civility list in API --- htdocs/api/class/api_setup.class.php | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 3ec618dc92a..304abf46432 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -380,6 +380,66 @@ class Setup extends DolibarrApi return $list; } + /** + * Get the list of civility. + * + * @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 string $module To filter on module events + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return List of events types + * + * @url GET dictionary/civility + * + * @throws RestException + */ + function getListOfCivility($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT rowid, code, label, module"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_civility as t"; + $sql.= " WHERE t.active = 1"; + if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; + // 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 civility : '.$this->db->lasterror()); + } + + return $list; + } /** * Get the list of extra fields. From d86c44e641b336a46a6b673298db44704a019090 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Wed, 17 Oct 2018 15:55:46 +0200 Subject: [PATCH 6/8] Add conf to disable a thirdparty type --- htdocs/langs/en_US/admin.lang | 1 + htdocs/societe/admin/societe.php | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4630757dbad..4054ca8c254 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1821,3 +1821,4 @@ DisabledResourceLinkUser=Disable feature to link a resource to users DisabledResourceLinkContact=Disable feature to link a resource to contacts ConfirmUnactivation=Confirm module reset OnMobileOnly=On small screen (smartphone) only +DisableProspectCustomerType=Disable the "Prospect/customer" thirdparty type diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 3a7b26505c7..49a9538e225 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -211,6 +211,21 @@ if ($action=="setaskforshippingmet") { } } +//Activate "Disable prospect/customer type" +if ($action=="setdisableprospectcustomer") { + $setdisableprospectcustomer = GETPOST('value','int'); + $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer,'yesno',0,'',$conf->entity); + if (! $res > 0) $error++; + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + //Activate ProfId unique if ($action == 'setprofid') { @@ -821,6 +836,25 @@ else print ''; print ''; +// Disable Prospect/Customer thirdparty type +print ''; +print ''.$langs->trans("DisableProspectCustomerType").''; +print ' '; +print ''; +if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) +{ + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); + +} +else +{ + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); +} +print ''; +print ''; + /*print ''; print ''.$langs->trans("OnSearchAndListGoOnCustomerOrSupplierCard").''; print ' '; From 5f309bf155887f48cd3a6a6e3ab5ed56eb83e84f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Oct 2018 13:38:23 +0200 Subject: [PATCH 7/8] Update commande.class.php --- htdocs/commande/class/commande.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4f5051f3411..1925b71992e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -155,9 +155,6 @@ class Commande extends CommonOrder public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...) public $demand_reason_code; public $date; // Date commande - public $date_creation; // Date commande - public $date_validation; // Date commande - public $date_modification; // Date commande /** * @deprecated From c1d25569659de4cc2790304207b4f698e9250e48 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Oct 2018 13:47:18 +0200 Subject: [PATCH 8/8] Update admin.lang --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4054ca8c254..3acc7c3c046 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1821,4 +1821,4 @@ DisabledResourceLinkUser=Disable feature to link a resource to users DisabledResourceLinkContact=Disable feature to link a resource to contacts ConfirmUnactivation=Confirm module reset OnMobileOnly=On small screen (smartphone) only -DisableProspectCustomerType=Disable the "Prospect/customer" thirdparty type +DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be Prospect or Customer but can't be both)