Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
6fdc279fd3
112
htdocs/api/class/api_dictionaryextrafields.class.php
Normal file
112
htdocs/api/class/api_dictionaryextrafields.class.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
//require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
||||
|
||||
/**
|
||||
* API class for extra fields (content of the extrafields)
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class DictionaryExtraFields extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
global $db;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of extra fields.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...)
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')"
|
||||
* @return List of events types
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function index($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
if ($type == 'thirdparty') $type='societe';
|
||||
if ($type == 'contact') $type='socpeople';
|
||||
|
||||
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.ishidden, t.fielddefault, t.fieldcomputed";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t";
|
||||
$sql.= " WHERE t.entity IN (".getEntity('extrafields').")";
|
||||
if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'";
|
||||
// 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);
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
while ($tab = $this->db->fetch_object($resql))
|
||||
{
|
||||
// New usage
|
||||
$list[$tab->elementtype][$tab->name]['type']=$tab->type;
|
||||
$list[$tab->elementtype][$tab->name]['label']=$tab->label;
|
||||
$list[$tab->elementtype][$tab->name]['size']=$tab->size;
|
||||
$list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype;
|
||||
$list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault;
|
||||
$list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed;
|
||||
$list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique;
|
||||
$list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired;
|
||||
$list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : '');
|
||||
$list[$tab->elementtype][$tab->name]['pos']=$tab->pos;
|
||||
$list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable;
|
||||
$list[$tab->elementtype][$tab->name]['perms']=$tab->perms;
|
||||
$list[$tab->elementtype][$tab->name]['list']=$tab->list;
|
||||
$list[$tab->elementtype][$tab->name]['ishidden']=$tab->ishidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
if (! count($list))
|
||||
{
|
||||
throw new RestException(404, 'No extrafield found');
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
@ -325,9 +325,9 @@ class Conf
|
||||
// Exception: Some dir are not the name of module. So we keep exception here for backward compatibility.
|
||||
|
||||
// Sous module bons d'expedition
|
||||
$this->expedition_bon->enabled=$this->global->MAIN_SUBMODULE_EXPEDITION?$this->global->MAIN_SUBMODULE_EXPEDITION:0;
|
||||
$this->expedition_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_EXPEDITION)?$this->global->MAIN_SUBMODULE_EXPEDITION:0);
|
||||
// Sous module bons de livraison
|
||||
$this->livraison_bon->enabled=$this->global->MAIN_SUBMODULE_LIVRAISON?$this->global->MAIN_SUBMODULE_LIVRAISON:0;
|
||||
$this->livraison_bon->enabled=(! empty($this->global->MAIN_SUBMODULE_LIVRAISON)?$this->global->MAIN_SUBMODULE_LIVRAISON:0);
|
||||
|
||||
// Module fournisseur
|
||||
if (! empty($this->fournisseur))
|
||||
|
||||
@ -416,7 +416,7 @@ class modSociete extends DolibarrModules
|
||||
$this->import_tables_array[$r]=array('sr'=>MAIN_DB_PREFIX.'societe_rib');
|
||||
$this->import_fields_array[$r]=array('sr.fk_soc'=>"ThirdPartyName*",'sr.bank'=>"Bank",
|
||||
'sr.code_banque'=>"BankCode*",'sr.code_guichet'=>"DeskCode*",'sr.number'=>"BankAccountNumber*",
|
||||
'sr.cle_rib'=>"BankAccountNumberKey*",'sr.bic'=>"BIC",'sr.iban_prefix'=>"IBAN"
|
||||
'sr.cle_rib'=>"BankAccountNumberKey*",'sr.bic'=>"BIC",'sr.iban_prefix'=>"IBAN", 'sr.domiciliation'=>"BankAccountDomiciliation",'sr.proprio' => "BankAccountOwner", 'sr.owner_address' => "BankAccountOwnerAddress", 'sr.default_rib' => 'Default'
|
||||
);
|
||||
|
||||
$this->import_convertvalue_array[$r]=array(
|
||||
@ -424,7 +424,7 @@ class modSociete extends DolibarrModules
|
||||
);
|
||||
$this->import_examplevalues_array[$r]=array('sr.fk_soc'=>"MyBigCompany",'sr.bank'=>"ING",
|
||||
'sr.code_banque'=>"0000", 'sr.code_guichet'=>"1111",'sr.number'=>"3333333333",
|
||||
'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333"
|
||||
'sr.cle_rib'=>"22",'sr.bic'=>"USHINGMMXXX",'sr.iban_prefix'=>"US00 0000 1111 22 3333 3333",'sr.domiciliation'=>"PARIS",'sr.proprio' => "Name of owner", 'sr.owner_address' => "15 paris street 75000 Paris", 'sr.default_rib' => '1 or 0'
|
||||
);
|
||||
|
||||
// Import Company Salesman
|
||||
|
||||
Loading…
Reference in New Issue
Block a user