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

This commit is contained in:
Laurent Destailleur 2018-10-19 14:29:32 +02:00
commit 4e82a6da46
6 changed files with 120 additions and 17 deletions

View File

@ -380,6 +380,66 @@ class Setup extends DolibarrApi
return $list; 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. * Get the list of extra fields.

View File

@ -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 = '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.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.fk_account';
$sql.= ', c.date_commande'; $sql.= ', c.date_commande, c.date_valid, c.tms';
$sql.= ', c.date_livraison'; $sql.= ', c.date_livraison';
$sql.= ', c.fk_shipping_method'; $sql.= ', c.fk_shipping_method';
$sql.= ', c.fk_warehouse'; $sql.= ', c.fk_warehouse';
@ -1673,6 +1673,9 @@ class Commande extends CommonOrder
$this->total_ttc = $obj->total_ttc; $this->total_ttc = $obj->total_ttc;
$this->date = $this->db->jdate($obj->date_commande); $this->date = $this->db->jdate($obj->date_commande);
$this->date_commande = $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 = $obj->remise;
$this->remise_percent = $obj->remise_percent; $this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue; $this->remise_absolue = $obj->remise_absolue;

View File

@ -10,6 +10,7 @@
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2017 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015-2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018 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
@ -2887,9 +2888,9 @@ class ContratLigne extends CommonObjectLine
$error=0; $error=0;
// Clean parameters // Clean parameters
$this->fk_contrat=trim($this->fk_contrat); $this->fk_contrat = (int) $this->fk_contrat;
$this->fk_product=trim($this->fk_product); $this->fk_product = (int) $this->fk_product;
$this->statut=(int) $this->statut; $this->statut = (int) $this->statut;
$this->label=trim($this->label); $this->label=trim($this->label);
$this->description=trim($this->description); $this->description=trim($this->description);
$this->vat_src_code=trim($this->vat_src_code); $this->vat_src_code=trim($this->vat_src_code);
@ -2899,7 +2900,7 @@ class ContratLigne extends CommonObjectLine
$this->qty=trim($this->qty); $this->qty=trim($this->qty);
$this->remise_percent=trim($this->remise_percent); $this->remise_percent=trim($this->remise_percent);
$this->remise=trim($this->remise); $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->subprice=price2num($this->subprice);
$this->price_ht=price2num($this->price_ht); $this->price_ht=price2num($this->price_ht);
$this->total_ht=trim($this->total_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_localtax2=trim($this->total_localtax2);
$this->total_ttc=trim($this->total_ttc); $this->total_ttc=trim($this->total_ttc);
$this->info_bits=trim($this->info_bits); $this->info_bits=trim($this->info_bits);
$this->fk_user_author=trim($this->fk_user_author); $this->fk_user_author = (int) $this->fk_user_author;
$this->fk_user_ouverture=trim($this->fk_user_ouverture); $this->fk_user_ouverture = (int) $this->fk_user_ouverture;
$this->fk_user_cloture=trim($this->fk_user_cloture); $this->fk_user_cloture = (int) $this->fk_user_cloture;
$this->commentaire=trim($this->commentaire); $this->commentaire=trim($this->commentaire);
//if (empty($this->subprice)) $this->subprice = 0; //if (empty($this->subprice)) $this->subprice = 0;
if (empty($this->price_ht)) $this->price_ht = 0; if (empty($this->price_ht)) $this->price_ht = 0;

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2018 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
@ -59,15 +60,18 @@ class Menubase
public $fk_menu; public $fk_menu;
/** /**
* @var int ID * @var string fk_mainmenu
*/ */
public $fk_mainmenu; public $fk_mainmenu;
/** /**
* @var int ID * @var string fk_leftmenu
*/ */
public $fk_leftmenu; public $fk_leftmenu;
/**
* @var int position
*/
public $position; public $position;
public $url; public $url;
public $target; public $target;
@ -111,10 +115,10 @@ class Menubase
$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=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_mainmenu=trim($this->fk_mainmenu);
$this->fk_leftmenu=trim($this->fk_leftmenu); $this->fk_leftmenu=trim($this->fk_leftmenu);
$this->position=trim($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);
@ -155,7 +159,7 @@ class Menubase
$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->db->escape($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;
@ -252,10 +256,10 @@ class Menubase
$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=trim($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=trim($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);
@ -274,7 +278,7 @@ class Menubase
$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->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_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).",";

View File

@ -1821,3 +1821,4 @@ DisabledResourceLinkUser=Disable feature to link a resource to users
DisabledResourceLinkContact=Disable feature to link a resource to contacts DisabledResourceLinkContact=Disable feature to link a resource to contacts
ConfirmUnactivation=Confirm module reset ConfirmUnactivation=Confirm module reset
OnMobileOnly=On small screen (smartphone) only 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)

View File

@ -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 //Activate ProfId unique
if ($action == 'setprofid') if ($action == 'setprofid')
{ {
@ -821,6 +836,25 @@ else
print '</a></td>'; print '</a></td>';
print '</tr>'; print '</tr>';
// Disable Prospect/Customer thirdparty type
print '<tr class="oddeven">';
print '<td width="80%">'.$langs->trans("DisableProspectCustomerType").'</td>';
print '<td>&nbsp</td>';
print '<td align="center">';
if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS))
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&value=0">';
print img_picto($langs->trans("Activated"),'switch_on');
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&value=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
}
print '</a></td>';
print '</tr>';
/*print '<tr class="oddeven">'; /*print '<tr class="oddeven">';
print '<td width="80%">'.$langs->trans("OnSearchAndListGoOnCustomerOrSupplierCard").'</td>'; print '<td width="80%">'.$langs->trans("OnSearchAndListGoOnCustomerOrSupplierCard").'</td>';
print '<td>&nbsp</td>'; print '<td>&nbsp</td>';