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. diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c588830d83d..1925b71992e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -155,7 +155,7 @@ 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 - + /** * @deprecated * @see date @@ -1620,7 +1620,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 +1673,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; 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; 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).","; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b173f7912dd..52445134f0f 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" third party type (so third party must be Prospect or Customer but can't be both) 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 ' ';