Skip to content

Commit

Permalink
Merge branch 'develop' into patch-110
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 14, 2019
2 parents 7d5ea4f + 749c7d9 commit 5a0d4c4
Show file tree
Hide file tree
Showing 57 changed files with 1,577 additions and 349 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -60,7 +60,6 @@ matrix:
fast_finish: true
allow_failures:
- php: nightly
- php: '7.3'
# We exclude some combinations not usefull to save Travis CPU
exclude:
- php: '5.5'
Expand All @@ -71,6 +70,8 @@ matrix:
env: DB=mariadb
- php: '7.1'
env: DB=mariadb
- php: '7.2'
env: DB=mariadb
- php: '5.5'
env: DB=postgresql
- php: '5.6'
Expand All @@ -79,7 +80,7 @@ matrix:
env: DB=postgresql
- php: '7.1'
env: DB=postgresql
- php: '7.3'
- php: '7.2'
env: DB=postgresql
- php: nightly
env: DB=postgresql
Expand Down
19 changes: 18 additions & 1 deletion htdocs/admin/dict.php
Expand Up @@ -88,7 +88,7 @@
// Put here declaration of dictionaries properties

// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,25,0);
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,37,0,25,0);

// Name of SQL tables of dictionaries
$tabname=array();
Expand Down Expand Up @@ -128,6 +128,7 @@
$tabname[34]= MAIN_DB_PREFIX."c_hrm_function";
$tabname[35]= MAIN_DB_PREFIX."c_exp_tax_cat";
$tabname[36]= MAIN_DB_PREFIX."c_exp_tax_range";
$tabname[37]= MAIN_DB_PREFIX."c_measuring_units";

// Dictionary labels
$tablib=array();
Expand Down Expand Up @@ -167,6 +168,7 @@
$tablib[34]= "DictionaryFunction";
$tablib[35]= "DictionaryExpenseTaxCat";
$tablib[36]= "DictionaryExpenseTaxRange";
$tablib[37]= "DictionaryMeasuringUnits";

// Requests to extract data
$tabsql=array();
Expand Down Expand Up @@ -206,6 +208,7 @@
$tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function";
$tabsql[35]= "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c";
$tabsql[36]= "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r";
$tabsql[37]= "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.active FROM ".MAIN_DB_PREFIX."c_measuring_units r";

// Criteria to sort dictionaries
$tabsqlsort=array();
Expand Down Expand Up @@ -245,6 +248,7 @@
$tabsqlsort[34]="code ASC";
$tabsqlsort[35]="c.label ASC";
$tabsqlsort[36]="r.fk_c_exp_tax_cat ASC, r.range_ik ASC";
$tabsqlsort[37]="r.unit_type ASC, r.code ASC";

// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
Expand Down Expand Up @@ -284,6 +288,7 @@
$tabfield[34]= "code,label";
$tabfield[35]= "label";
$tabfield[36]= "range_ik,fk_c_exp_tax_cat";
$tabfield[37]= "code,label,short_label,unit_type";

// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
Expand Down Expand Up @@ -323,6 +328,7 @@
$tabfieldvalue[34]= "code,label";
$tabfieldvalue[35]= "label";
$tabfieldvalue[36]= "range_ik,fk_c_exp_tax_cat";
$tabfieldvalue[37]= "code,label,short_label,unit_type";

// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
Expand Down Expand Up @@ -362,6 +368,7 @@
$tabfieldinsert[34]= "code,label";
$tabfieldinsert[35]= "label";
$tabfieldinsert[36]= "range_ik,fk_c_exp_tax_cat";
$tabfieldinsert[37]= "code,label,short_label,unit_type";

// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
Expand Down Expand Up @@ -403,6 +410,7 @@
$tabrowid[34]= "rowid";
$tabrowid[35]= "";
$tabrowid[36]= "";
$tabrowid[37]= "";

// Condition to show dictionary in setup page
$tabcond=array();
Expand Down Expand Up @@ -442,6 +450,7 @@
$tabcond[34]= ! empty($conf->hrm->enabled);
$tabcond[35]= ! empty($conf->expensereport->enabled);
$tabcond[36]= ! empty($conf->expensereport->enabled);
$tabcond[37]= ! empty($conf->product->enabled);

// List of help for fields
$tabhelp=array();
Expand Down Expand Up @@ -481,6 +490,7 @@
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[35]= array();
$tabhelp[36]= array('range_ik'=>$langs->trans('PrevRangeToThisRange'));
$tabhelp[37]= array('short_label'=>$langs->trans("EnterAnyCode"));

// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
Expand Down Expand Up @@ -520,6 +530,7 @@
$tabfieldcheck[34] = array();
$tabfieldcheck[35]= array();
$tabfieldcheck[36]= array();
$tabfieldcheck[37]= array();

// Complete all arrays with entries found into modules
complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
Expand Down Expand Up @@ -1583,6 +1594,12 @@
{
$valuetoshow = $langs->trans($valuetoshow);
}
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_measuring_units')
{
$langs->load('other');
$key = $langs->trans($obj->label);
$valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]});
}

$class='tddict';
if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200';
Expand Down
8 changes: 4 additions & 4 deletions htdocs/admin/menus/edit.php
Expand Up @@ -144,9 +144,9 @@
}

$leftmenu=''; $mainmenu='';
if (GETPOST('menuId', 'int') && ! is_numeric(GETPOST('menuId', 'int')))
if (GETPOST('menuId', 'alpha') && ! is_numeric(GETPOST('menuId', 'alpha')))
{
$tmp=explode('&', GETPOST('menuId', 'int'));
$tmp=explode('&', GETPOST('menuId', 'alpha'));
foreach($tmp as $s)
{
if (preg_match('/fk_mainmenu=/', $s))
Expand Down Expand Up @@ -214,9 +214,9 @@
$menu->target=GETPOST('target', 'alpha');
$menu->user=GETPOST('user', 'alpha');
$menu->mainmenu=GETPOST('propertymainmenu', 'alpha');
if (is_numeric(GETPOST('menuId', 'int')))
if (is_numeric(GETPOST('menuId', 'alpha')))
{
$menu->fk_menu=GETPOST('menuId', 'int');
$menu->fk_menu=GETPOST('menuId', 'alpha');
}
else
{
Expand Down
11 changes: 6 additions & 5 deletions htdocs/comm/action/class/ical.class.php
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019 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
Expand Down Expand Up @@ -96,7 +97,7 @@ function get_todo_count()
* Translate Calendar
*
* @param string $uri Url
* @return array
* @return array|string
*/
function parse($uri)
{
Expand Down Expand Up @@ -363,9 +364,9 @@ function ical_dt_date($key, $value)

// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return sorted eventlist as array or false if calenar is empty
* Return sorted eventlist as array or false if calendar is empty
*
* @return array
* @return array|false
*/
function get_sort_event_list()
{
Expand Down Expand Up @@ -398,7 +399,7 @@ function ical_dtstart_compare($a, $b)

// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return eventlist array (not sort eventlist array)
* Return eventlist array (not sorted eventlist array)
*
* @return array
*/
Expand All @@ -422,7 +423,7 @@ function get_freebusy_list()

// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return to do array (not sort to do array)
* Return to do array (not sorted todo array)
*
* @return array
*/
Expand Down
90 changes: 85 additions & 5 deletions htdocs/comm/propal/class/api_proposals.class.php
Expand Up @@ -57,12 +57,13 @@ function __construct()
*
* Return an array with commercial proposal informations
*
* @param int $id ID of commercial proposal
* @param int $id ID of commercial proposal
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @throws RestException
*/
function get($id)
function get($id, $contact_list = 1)
{
if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
Expand All @@ -77,9 +78,8 @@ function get($id)
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}

// Add external contacts ids
$this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', 1);

// Add external contacts ids.
$this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', $contact_list);
$this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal);
}
Expand Down Expand Up @@ -409,6 +409,86 @@ function deleteLine($id, $lineid)
}
}

/**
* Add a contact type of given commercial proposal
*
* @param int $id Id of commercial proposal to update
* @param int $contactid Id of contact to add
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER)
*
* @url POST {id}/contact/{contactid}/{type}
*
* @return int
* @throws 401
* @throws 404
*/
function postContact($id, $contactid, $type)
{
if(!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}

$result = $this->propal->fetch($id);

if(!$result) {
throw new RestException(404, 'Proposal not found');
}

if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) {
throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER');
}

if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}

$result = $this->propal->add_contact($contactid, $type, 'external');

if (!$result) {
throw new RestException(500, 'Error when added the contact');
}

return $this->propal;
}

/**
* Delete a contact type of given commercial proposal
*
* @param int $id Id of commercial proposal to update
* @param int $rowid Row key of the contact in the array contact_ids.
*
* @url DELETE {id}/contact/{lineid}
*
* @return int
* @throws 401
* @throws 404
* @throws 500
*/
function deleteContact($id, $rowid)
{
if(!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}

$result = $this->propal->fetch($id);

if(!$result) {
throw new RestException(404, 'Proposal not found');
}

if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}

$result = $this->propal->delete_contact($rowid);

if (!$result) {
throw new RestException(500, 'Error when deleted the contact');
}

return $this->propal;
}

/**
* Update commercial proposal general fields (won't touch lines of commercial proposal)
*
Expand Down
7 changes: 4 additions & 3 deletions htdocs/commande/class/api_orders.class.php
Expand Up @@ -56,12 +56,13 @@ function __construct()
*
* Return an array with order informations
*
* @param int $id ID of order
* @param int $id ID of order
* @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id
* @return array|mixed data without useless information
*
* @throws RestException
*/
function get($id)
function get($id, $contact_list = 1)
{
if(! DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
Expand All @@ -77,7 +78,7 @@ function get($id)
}

// Add external contacts ids
$this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', 1);
$this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list);
$this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande);
}
Expand Down

0 comments on commit 5a0d4c4

Please sign in to comment.