Merge branch 'develop' into patch-110

This commit is contained in:
Laurent Destailleur 2019-02-14 10:32:05 +01:00 committed by GitHub
commit 5a0d4c4cdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 1569 additions and 341 deletions

View File

@ -60,7 +60,6 @@ matrix:
fast_finish: true fast_finish: true
allow_failures: allow_failures:
- php: nightly - php: nightly
- php: '7.3'
# We exclude some combinations not usefull to save Travis CPU # We exclude some combinations not usefull to save Travis CPU
exclude: exclude:
- php: '5.5' - php: '5.5'
@ -71,6 +70,8 @@ matrix:
env: DB=mariadb env: DB=mariadb
- php: '7.1' - php: '7.1'
env: DB=mariadb env: DB=mariadb
- php: '7.2'
env: DB=mariadb
- php: '5.5' - php: '5.5'
env: DB=postgresql env: DB=postgresql
- php: '5.6' - php: '5.6'
@ -79,7 +80,7 @@ matrix:
env: DB=postgresql env: DB=postgresql
- php: '7.1' - php: '7.1'
env: DB=postgresql env: DB=postgresql
- php: '7.3' - php: '7.2'
env: DB=postgresql env: DB=postgresql
- php: nightly - php: nightly
env: DB=postgresql env: DB=postgresql

View File

@ -88,7 +88,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties // 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. // 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 // Name of SQL tables of dictionaries
$tabname=array(); $tabname=array();
@ -128,6 +128,7 @@ $tabname[33]= MAIN_DB_PREFIX."c_hrm_department";
$tabname[34]= MAIN_DB_PREFIX."c_hrm_function"; $tabname[34]= MAIN_DB_PREFIX."c_hrm_function";
$tabname[35]= MAIN_DB_PREFIX."c_exp_tax_cat"; $tabname[35]= MAIN_DB_PREFIX."c_exp_tax_cat";
$tabname[36]= MAIN_DB_PREFIX."c_exp_tax_range"; $tabname[36]= MAIN_DB_PREFIX."c_exp_tax_range";
$tabname[37]= MAIN_DB_PREFIX."c_measuring_units";
// Dictionary labels // Dictionary labels
$tablib=array(); $tablib=array();
@ -167,6 +168,7 @@ $tablib[33]= "DictionaryDepartment";
$tablib[34]= "DictionaryFunction"; $tablib[34]= "DictionaryFunction";
$tablib[35]= "DictionaryExpenseTaxCat"; $tablib[35]= "DictionaryExpenseTaxCat";
$tablib[36]= "DictionaryExpenseTaxRange"; $tablib[36]= "DictionaryExpenseTaxRange";
$tablib[37]= "DictionaryMeasuringUnits";
// Requests to extract data // Requests to extract data
$tabsql=array(); $tabsql=array();
@ -206,6 +208,7 @@ $tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hr
$tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; $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[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[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 // Criteria to sort dictionaries
$tabsqlsort=array(); $tabsqlsort=array();
@ -245,6 +248,7 @@ $tabsqlsort[33]="code ASC";
$tabsqlsort[34]="code ASC"; $tabsqlsort[34]="code ASC";
$tabsqlsort[35]="c.label ASC"; $tabsqlsort[35]="c.label ASC";
$tabsqlsort[36]="r.fk_c_exp_tax_cat ASC, r.range_ik 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 // Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array(); $tabfield=array();
@ -284,6 +288,7 @@ $tabfield[33]= "code,label";
$tabfield[34]= "code,label"; $tabfield[34]= "code,label";
$tabfield[35]= "label"; $tabfield[35]= "label";
$tabfield[36]= "range_ik,fk_c_exp_tax_cat"; $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 // Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array(); $tabfieldvalue=array();
@ -323,6 +328,7 @@ $tabfieldvalue[33]= "code,label";
$tabfieldvalue[34]= "code,label"; $tabfieldvalue[34]= "code,label";
$tabfieldvalue[35]= "label"; $tabfieldvalue[35]= "label";
$tabfieldvalue[36]= "range_ik,fk_c_exp_tax_cat"; $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 // Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array(); $tabfieldinsert=array();
@ -362,6 +368,7 @@ $tabfieldinsert[33]= "code,label";
$tabfieldinsert[34]= "code,label"; $tabfieldinsert[34]= "code,label";
$tabfieldinsert[35]= "label"; $tabfieldinsert[35]= "label";
$tabfieldinsert[36]= "range_ik,fk_c_exp_tax_cat"; $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 // Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on // Example: "" if id field is "rowid" and has autoincrement on
@ -403,6 +410,7 @@ $tabrowid[33]= "rowid";
$tabrowid[34]= "rowid"; $tabrowid[34]= "rowid";
$tabrowid[35]= ""; $tabrowid[35]= "";
$tabrowid[36]= ""; $tabrowid[36]= "";
$tabrowid[37]= "";
// Condition to show dictionary in setup page // Condition to show dictionary in setup page
$tabcond=array(); $tabcond=array();
@ -442,6 +450,7 @@ $tabcond[33]= ! empty($conf->hrm->enabled);
$tabcond[34]= ! empty($conf->hrm->enabled); $tabcond[34]= ! empty($conf->hrm->enabled);
$tabcond[35]= ! empty($conf->expensereport->enabled); $tabcond[35]= ! empty($conf->expensereport->enabled);
$tabcond[36]= ! empty($conf->expensereport->enabled); $tabcond[36]= ! empty($conf->expensereport->enabled);
$tabcond[37]= ! empty($conf->product->enabled);
// List of help for fields // List of help for fields
$tabhelp=array(); $tabhelp=array();
@ -481,6 +490,7 @@ $tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[35]= array(); $tabhelp[35]= array();
$tabhelp[36]= array('range_ik'=>$langs->trans('PrevRangeToThisRange')); $tabhelp[36]= array('range_ik'=>$langs->trans('PrevRangeToThisRange'));
$tabhelp[37]= array('short_label'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET) // List of check for fields (NOT USED YET)
$tabfieldcheck=array(); $tabfieldcheck=array();
@ -520,6 +530,7 @@ $tabfieldcheck[33] = array();
$tabfieldcheck[34] = array(); $tabfieldcheck[34] = array();
$tabfieldcheck[35]= array(); $tabfieldcheck[35]= array();
$tabfieldcheck[36]= array(); $tabfieldcheck[36]= array();
$tabfieldcheck[37]= array();
// Complete all arrays with entries found into modules // Complete all arrays with entries found into modules
complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck); complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
@ -1583,6 +1594,12 @@ if ($id)
{ {
$valuetoshow = $langs->trans($valuetoshow); $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'; $class='tddict';
if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200';

View File

@ -144,9 +144,9 @@ if ($action == 'add')
} }
$leftmenu=''; $mainmenu=''; $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) foreach($tmp as $s)
{ {
if (preg_match('/fk_mainmenu=/', $s)) if (preg_match('/fk_mainmenu=/', $s))
@ -214,9 +214,9 @@ if ($action == 'add')
$menu->target=GETPOST('target', 'alpha'); $menu->target=GETPOST('target', 'alpha');
$menu->user=GETPOST('user', 'alpha'); $menu->user=GETPOST('user', 'alpha');
$menu->mainmenu=GETPOST('propertymainmenu', '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 else
{ {

View File

@ -3,6 +3,7 @@
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com> * 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 * 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
@ -96,7 +97,7 @@ class ICal
* Translate Calendar * Translate Calendar
* *
* @param string $uri Url * @param string $uri Url
* @return array * @return array|string
*/ */
function parse($uri) function parse($uri)
{ {
@ -363,9 +364,9 @@ class ICal
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // 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() function get_sort_event_list()
{ {
@ -398,7 +399,7 @@ class ICal
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Return eventlist array (not sort eventlist array) * Return eventlist array (not sorted eventlist array)
* *
* @return array * @return array
*/ */
@ -422,7 +423,7 @@ class ICal
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // 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 * @return array
*/ */

View File

@ -58,11 +58,12 @@ class Proposals extends DolibarrApi
* Return an array with commercial proposal informations * 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 * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id, $contact_list = 1)
{ {
if(! DolibarrApiAccess::$user->rights->propal->lire) { if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401); throw new RestException(401);
@ -77,9 +78,8 @@ class Proposals extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
// Add external contacts ids // Add external contacts ids.
$this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', 1); $this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', $contact_list);
$this->propal->fetchObjectLinked(); $this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal); return $this->_cleanObjectDatas($this->propal);
} }
@ -409,6 +409,86 @@ class Proposals extends DolibarrApi
} }
} }
/**
* 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) * Update commercial proposal general fields (won't touch lines of commercial proposal)
* *

View File

@ -57,11 +57,12 @@ class Orders extends DolibarrApi
* Return an array with order informations * 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 * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id, $contact_list = 1)
{ {
if(! DolibarrApiAccess::$user->rights->commande->lire) { if(! DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401); throw new RestException(401);
@ -77,7 +78,7 @@ class Orders extends DolibarrApi
} }
// Add external contacts ids // 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(); $this->commande->fetchObjectLinked();
return $this->_cleanObjectDatas($this->commande); return $this->_cleanObjectDatas($this->commande);
} }

View File

@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
$langs->loadLangs(array("accountancy","bills")); $langs->loadLangs(array("accountancy","bills"));
@ -59,7 +60,7 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortfield) $sortfield="f.datef,f.rowid"; // Set here default search field if (! $sortfield) $sortfield="date,item"; // Set here default search field
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
@ -69,7 +70,7 @@ $arrayfields=array(
); );
// Security check // Security check
if (empty($conf->compta->enabled) && empty($conf->accounting->enabled)) { if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if ($user->societe_id > 0) if ($user->societe_id > 0)
@ -94,26 +95,34 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){
$sql="SELECT rowid as id, ref as ref,paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; $sql="SELECT rowid as id, ref as ref,paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture";
$sql.=" WHERE datef between ".$wheretail; $sql.=" WHERE datef between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT;
$sql.=" UNION ALL"; $sql.=" UNION ALL";
$sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'InvoiceSupplier' as item FROM ".MAIN_DB_PREFIX."facture_fourn"; $sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'SupplierInvoice' as item FROM ".MAIN_DB_PREFIX."facture_fourn";
$sql.=" WHERE datef between ".$wheretail; $sql.=" WHERE datef between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND fk_statut <> ".FactureFournisseur::STATUS_DRAFT;
$sql.=" UNION ALL"; $sql.=" UNION ALL";
$sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport"; $sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport";
$sql.=" WHERE date_fin between ".$wheretail; $sql.=" WHERE date_fin between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND fk_statut <> ".ExpenseReport::STATUS_DRAFT;
$sql.=" UNION ALL"; $sql.=" UNION ALL";
$sql.=" SELECT rowid as id, ref,paid,amount as total_ttc, '0' as fk_soc, datedon as date, 'Donation' as item FROM ".MAIN_DB_PREFIX."don"; $sql.=" SELECT rowid as id, ref,paid,amount as total_ttc, '0' as fk_soc, datedon as date, 'Donation' as item FROM ".MAIN_DB_PREFIX."don";
$sql.=" WHERE datedon between ".$wheretail; $sql.=" WHERE datedon between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
$sql.=" AND fk_statut <> ".Don::STATUS_DRAFT;
$sql.=" UNION ALL"; $sql.=" UNION ALL";
$sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date, 'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary"; $sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date, 'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary";
$sql.=" WHERE datep between ".$wheretail; $sql.=" WHERE datep between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
//$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT;
$sql.=" UNION ALL"; $sql.=" UNION ALL";
$sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales"; $sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales";
$sql.=" WHERE date_creation between ".$wheretail; $sql.=" WHERE date_creation between ".$wheretail;
$sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')';
//$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT;
$sql.= $db->order($sortfield, $sortorder);
$resd = $db->query($sql); $resd = $db->query($sql);
$files=array(); $files=array();
$link=''; $link='';
@ -139,18 +148,18 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){
$upload_dir = $conf->facture->dir_output.'/'.$subdir; $upload_dir = $conf->facture->dir_output.'/'.$subdir;
$link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; $link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F';
break; break;
case "InvoiceSupplier": case "SupplierInvoice":
$tmpinvoicesupplier->fetch($objd->id); $tmpinvoicesupplier->fetch($objd->id);
$subdir=get_exdir(0, 0, 0, 1, $tmpinvoicesupplier, 'invoice_supplier').'/'.dol_sanitizeFileName($objd->ref); $subdir=get_exdir($tmpinvoicesupplier->id, 2, 0, 0, $tmpinvoicesupplier, 'invoice_supplier').'/'.dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir;
$link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; $link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F';
break; break;
case "Expense": case "ExpenseReport":
$subdir=dol_sanitizeFileName($objd->ref); $subdir=dol_sanitizeFileName($objd->ref);
$upload_dir = $conf->expensereport->dir_output.'/'.$subdir; $upload_dir = $conf->expensereport->dir_output.'/'.$subdir;
$link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; $link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F';
break; break;
case "Salary": case "SalaryPayment":
$subdir=dol_sanitizeFileName($objd->id); $subdir=dol_sanitizeFileName($objd->id);
$upload_dir = $conf->salaries->dir_output.'/'.$subdir; $upload_dir = $conf->salaries->dir_output.'/'.$subdir;
$link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; $link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F';
@ -177,7 +186,9 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){
{ {
$result=true; $result=true;
$files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1);
if (count($files)<1) { //var_dump($upload_dir);
if (count($files) < 1)
{
$nofile['date']=$db->idate($objd->date); $nofile['date']=$db->idate($objd->date);
$nofile['paid']=$objd->paid; $nofile['paid']=$objd->paid;
$nofile['amount']=$objd->total_ttc; $nofile['amount']=$objd->total_ttc;
@ -225,10 +236,14 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){
if ($result && $action == "dl") if ($result && $action == "dl")
{ {
dol_delete_file($zip); $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp);
dol_mkdir($dirfortmpfile);
$log='date,type,ref,total,paid,filename,item_id'."\n"; $log='date,type,ref,total,paid,filename,item_id'."\n";
$zipname = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp).'/'.($date_start)."-".($date_stop).'_export.zip'; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip';
dol_delete_file(name);
$zip = new ZipArchive; $zip = new ZipArchive;
$res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE);
@ -237,7 +252,7 @@ if ($result && $action == "dl")
foreach ($filesarray as $key=> $file) foreach ($filesarray as $key=> $file)
{ {
if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); // if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); //
$log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; $log.=dol_print_date($file['date'], 'dayrfc').','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n";
} }
$zip->addFromString('transactions.csv', $log); $zip->addFromString('transactions.csv', $log);
$zip->close(); $zip->close();
@ -259,23 +274,27 @@ if ($result && $action == "dl")
* View * View
*/ */
$form = new Form($db);
$userstatic=new User($db);
$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List");
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
$h=0; $h=0;
$head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
$head[$h][1] = $langs->trans("AccountantFiles"); $head[$h][1] = $langs->trans("AccountancyFiles");
$head[$h][2] = 'AccountantFiles'; $head[$h][2] = 'AccountancyFiles';
dol_fiche_head($head, 'AccountancyFiles');
dol_fiche_head($head, 'AccountantFiles');
$form = new Form($db);
$userstatic=new User($db);
$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List");
print '<form name="searchfiles" action="?action=searchfiles'.$tail.'" method="POST" >'."\n"; print '<form name="searchfiles" action="?action=searchfiles'.$tail.'" method="POST" >'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0);
print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n</a>"; print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n</a>";
// Multicompany // Multicompany
if (! empty($conf->multicompany->enabled) && is_object($mc)) /*if (! empty($conf->multicompany->enabled) && is_object($mc))
{ {
print '<br>'; print '<br>';
// This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
@ -293,7 +312,7 @@ if (! empty($conf->multicompany->enabled) && is_object($mc))
} }
} }
/*$object = new stdClass(); $object = new stdClass();
// Other attributes // Other attributes
$parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"'); $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
@ -301,8 +320,17 @@ if (! empty($conf->multicompany->enabled) && is_object($mc))
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
}*/
} }
}*/
if (! empty($conf->multicompany->enabled) && is_object($mc))
{
print ' &nbsp; - &nbsp; '.$langs->trans("Entity").' : ';
$mc->dao->getEntities();
$mc->dao->fetch($conf->entity);
print $mc->dao->label;
print "<br>\n";
}
print '<input class="button" type="submit" value="'.$langs->trans("Refresh").'" /></form>'."\n"; print '<input class="button" type="submit" value="'.$langs->trans("Refresh").'" /></form>'."\n";
dol_fiche_end(); dol_fiche_end();
@ -318,6 +346,7 @@ if (!empty($date_start) && !empty($date_stop))
$param.='&date_stopyear='.GETPOST('date_stopyear', 'int'); $param.='&date_stopyear='.GETPOST('date_stopyear', 'int');
print '<form name="dl" action="?action=dl" method="POST" >'."\n"; print '<form name="dl" action="?action=dl" method="POST" >'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day');
@ -352,10 +381,14 @@ if (!empty($date_start) && !empty($date_stop))
if ($result) if ($result)
{ {
$TData = dol_sort_array($filesarray, 'date', 'ASC'); $TData = dol_sort_array($filesarray, 'date', 'ASC');
if(empty($TData)) {
if (empty($TData))
{
print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td></tr>'; print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoItem").'</td></tr>';
} else { }
// Sort array by date ASC to calucalte balance else
{
// Sort array by date ASC to calculate balance
$totalDebit = 0; $totalDebit = 0;
$totalCredit = 0; $totalCredit = 0;
@ -371,8 +404,10 @@ if (!empty($date_start) && !empty($date_stop))
$balance += $data1['amount']; $balance += $data1['amount'];
$data1['balance'] = $balance; $data1['balance'] = $balance;
} }
// Display array // Display array
foreach($TData as $data) { foreach($TData as $data)
{
$html_class = ''; $html_class = '';
//if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture'];
//elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
@ -380,7 +415,7 @@ if (!empty($date_start) && !empty($date_stop))
print "<td align=\"center\">"; print "<td align=\"center\">";
print dol_print_date($data['date'], 'day'); print dol_print_date($data['date'], 'day');
print "</td>\n"; print "</td>\n";
print '<td aling="left">'.$data['item'].'</td>'; print '<td aling="left">'.$langs->trans($data['item']).'</td>';
print '<td aling="left">'.$data['ref'].'</td>'; print '<td aling="left">'.$data['ref'].'</td>';
// File link // File link
@ -395,6 +430,7 @@ if (!empty($date_start) && !empty($date_stop))
print '<td align="right">'.price($data['balance'])."</td>\n"; print '<td align="right">'.price($data['balance'])."</td>\n";
print "</tr>\n"; print "</tr>\n";
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td colspan="5">&nbsp;</td>'; print '<td colspan="5">&nbsp;</td>';
print '<td align="right">'.price($totalDebit).'</td>'; print '<td align="right">'.price($totalDebit).'</td>';
@ -407,6 +443,5 @@ if (!empty($date_start) && !empty($date_stop))
print '</div>'; print '</div>';
} }
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -56,11 +56,12 @@ class Invoices extends DolibarrApi
* Return an array with invoice informations * Return an array with invoice informations
* *
* @param int $id ID of invoice * @param int $id ID of invoice
* @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
function get($id) function get($id, $contact_list = 1)
{ {
if(! DolibarrApiAccess::$user->rights->facture->lire) { if(! DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401); throw new RestException(401);
@ -82,7 +83,7 @@ class Invoices extends DolibarrApi
} }
// Add external contacts ids // Add external contacts ids
$this->invoice->contacts_ids = $this->invoice->liste_contact(-1, 'external', 1); $this->invoice->contacts_ids = $this->invoice->liste_contact(-1, 'external', $contact_list);
$this->invoice->fetchObjectLinked(); $this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice); return $this->_cleanObjectDatas($this->invoice);

View File

@ -960,7 +960,7 @@ class FactureRec extends CommonInvoice
/** /**
* Return the next date of * Return the next date of
* *
* @return timestamp false if KO, timestamp if OK * @return int|false false if KO, timestamp if OK
*/ */
function getNextDate() function getNextDate()
{ {

View File

@ -488,7 +488,8 @@ if ($sql_select)
$description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description));
} }
if (($objp->info_bits & 2) == 2) { if (($objp->info_bits & 2) == 2)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'">'; print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'">';
$txt=''; $txt='';
print img_object($langs->trans("ShowReduc"), 'reduc').' '; print img_object($langs->trans("ShowReduc"), 'reduc').' ';

View File

@ -0,0 +1,432 @@
<?php
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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/>.
*/
/**
* \file htdocs/core/class/cmeasuringunits.class.php
* \ingroup core
* \brief This file is CRUD class file (Create/Read/Update/Delete) for c_measuring_units dictionary
*/
/**
* Class of dictionary type of thirdparty (used by imports)
*/
class CMeasuringUnits // extends CommonObject
{
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
public $records = array();
//var $element='ctypent'; //!< Id that identify managed objects
//var $table_element='ctypent'; //!< Name of table without prefix where object is stored
/**
* @var int ID
*/
public $id;
public $code;
public $label;
public $short_label;
public $unit_type;
public $active;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
function __construct($db)
{
$this->db = $db;
}
/**
* Create object into database
*
* @param User $user User that create
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK
*/
function create($user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->id)) $this->id=trim($this->id);
if (isset($this->code)) $this->code=trim($this->code);
if (isset($this->label)) $this->libelle=trim($this->label);
if (isset($this->short_label)) $this->libelle=trim($this->short_label);
if (isset($this->unit_type)) $this->active=trim($this->unit_type);
if (isset($this->active)) $this->active=trim($this->active);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_measuring_units(";
$sql.= "rowid,";
$sql.= "code,";
$sql.= "label,";
$sql.= "short_label,";
$sql.= "unit_type";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").",";
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
$sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->active($this->short_label)."'").",";
$sql.= " ".(! isset($this->unit_type)?'NULL':"'".$this->db->active($this->unit_type)."'");
$sql.= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_measuring_units");
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return $this->id;
}
}
/**
* Load object in memory from database
*
* @param int $id Id object
* @param string $unit_type unit type
* @param string $code Code
* @param string $short_label Short Label
* @return int <0 if KO, >0 if OK
*/
function fetch($id, $unit_type = '', $code = '', $short_label = '')
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.code,";
$sql.= " t.label,";
$sql.= " t.short_label,";
$sql.= " t.unit_type,";
$sql.= " t.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_measuring_units as t";
$sql_where=array();
if ($id) $sql_where[]= " t.id = ".$id;
if ($unit_type) $sql_where[]= " t.unit_type = '".$this->db->escape($unit_type)."'";
if ($code) $sql_where[]= " t.code = '".$this->db->escape($code)."'";
if ($short_label) $sql_where[]= " t.short_label = '".$this->db->escape($short_label)."'";
if (count($sql_where)>0) {
$sql.=' WHERE '. implode(' AND ', $sql_where);
}
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->code = $obj->code;
$this->label = $obj->label;
$this->short_label = $obj->short_label;
$this->unit_type = $obj->unit_type;
$this->active = $obj->active;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
return -1;
}
}
/**
* Load list of objects in memory from the database.
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit limit
* @param int $offset Offset
* @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
* @param string $filtermode Filter mode (AND or OR)
* @return array|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$records=array();
$sql = 'SELECT';
$sql.= " t.rowid,";
$sql.= " t.code,";
$sql.= " t.label,";
$sql.= " t.short_label,";
$sql.= " t.unit_type,";
$sql.= " t.active";
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_measuring_units as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key=='t.rowid' || $key=='t.active') {
$sqlwhere[] = $key . '='. $value;
}
elseif (strpos($key, 'date') !== false) {
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
}
elseif ($key=='t.unit_type' || $key=='t.code' || $key=='t.short_label') {
$sqlwhere[] = $key.' = \''.$this->db->escape($value).'\'';
}
else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE (' . implode(' '.$filtermode.' ', $sqlwhere).')';
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$resql = $this->db->query($sql);
if ($resql) {
$this->records=array();
$num = $this->db->num_rows($resql);
if ($num>0) {
while ($obj = $this->db->fetch_object($resql))
{
$record = new self($this->db);
$record->id = $obj->rowid;
$record->code = $obj->code;
$record->label = $obj->label;
$record->short_label = $obj->short_label;
$record->unit_type = $obj->unit_type;
$record->active = $obj->active;
$this->records[$record->id] = $record;
}
}
$this->db->free($resql);
return $this->records;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return -1;
}
}
/**
* Update object into database
*
* @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user = null, $notrigger = 0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->code)) $this->code=trim($this->code);
if (isset($this->label)) $this->libelle=trim($this->label);
if (isset($this->short_label)) $this->libelle=trim($this->short_label);
if (isset($this->unit_type)) $this->libelle=trim($this->unit_type);
if (isset($this->active)) $this->active=trim($this->active);
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."c_measuring_units SET";
$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " short_label=".(isset($this->short_label)?"'".$this->db->escape($this->short_label)."'":"null").",";
$sql.= " unit_type=".(isset($this->unit_type)?"'".$this->db->escape($this->unit_type)."'":"null").",";
$sql.= " active=".(isset($this->active)?$this->active:"null");
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_measuring_units";
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
}

View File

@ -585,7 +585,7 @@ abstract class CommonDocGenerator
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true); $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true);
$line->fetch_optionals(); $line->fetch_optionals();
$resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key=$array_key, $outputlangs); $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs);
// Load product data optional fields to the line -> enables to use "line_options_{extrafield}" // Load product data optional fields to the line -> enables to use "line_options_{extrafield}"
if (isset($line->fk_product) && $line->fk_product > 0) if (isset($line->fk_product) && $line->fk_product > 0)

View File

@ -0,0 +1,330 @@
<?php
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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/>.
*/
/**
* \file htdocs/core/class/cunits.class.php
* \ingroup core
* \brief This file is CRUD class file (Create/Read/Update/Delete) for c_units dictionary
*/
/**
* Class of dictionary type of thirdparty (used by imports)
*/
class CUnits // extends CommonObject
{
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string[] Error codes (or messages)
*/
public $errors = array();
//var $element='ctypent'; //!< Id that identify managed objects
//var $table_element='ctypent'; //!< Name of table without prefix where object is stored
/**
* @var int ID
*/
public $id;
public $code;
public $label;
public $short_label;
public $active;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
function __construct($db)
{
$this->db = $db;
}
/**
* Create object into database
*
* @param User $user User that create
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK
*/
function create($user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->id)) $this->id=trim($this->id);
if (isset($this->code)) $this->code=trim($this->code);
if (isset($this->label)) $this->libelle=trim($this->label);
if (isset($this->short_label)) $this->libelle=trim($this->short_label);
if (isset($this->active)) $this->active=trim($this->active);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units(";
$sql.= "rowid,";
$sql.= "code,";
$sql.= "label,";
$sql.= "short_label";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").",";
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
$sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->active($this->short_label)."'");
$sql.= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units");
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return $this->id;
}
}
/**
* Load object in memory from database
*
* @param int $id Id object
* @param string $code Code
* @param string $short_label Label
* @return int <0 if KO, >0 if OK
*/
function fetch($id, $code = '', $short_label = '')
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.code,";
$sql.= " t.label,";
$sql.= " t.short_label,";
$sql.= " t.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_units as t";
if ($id) $sql.= " WHERE t.rowid = ".$id;
elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
elseif ($short_label) $sql.= " WHERE t.short_label = '".$this->db->escape($short_label)."'";
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->code = $obj->code;
$this->label = $obj->label;
$this->short_label = $obj->short_label;
$this->active = $obj->active;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
return -1;
}
}
/**
* Update object into database
*
* @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user = null, $notrigger = 0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->code)) $this->code=trim($this->code);
if (isset($this->label)) $this->libelle=trim($this->label);
if (isset($this->short_label)) $this->libelle=trim($this->short_label);
if (isset($this->active)) $this->active=trim($this->active);
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET";
$sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").",";
$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " short_label=".(isset($this->short_label)?"'".$this->db->escape($this->short_label)."'":"null").",";
$sql.= " active=".(isset($this->active)?$this->active:"null");
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0)
{
global $conf, $langs;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."c_units";
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
}

View File

@ -50,8 +50,8 @@ class RssParser
private $_rssarray=array(); private $_rssarray=array();
// For parsing with xmlparser // For parsing with xmlparser
var $stack = array(); // parser stack public $stack = array(); // parser stack
var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright'); private $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
/** /**
@ -246,7 +246,7 @@ class RssParser
$str = file_get_contents($this->_urlRSS, false, $context); $str = file_get_contents($this->_urlRSS, false, $context);
} }
catch (Exception $e) { catch (Exception $e) {
print 'Error retrieving URL '.$this->urlRSS.' - '.$e->getMessage(); print 'Error retrieving URL '.$this->_urlRSS.' - '.$e->getMessage();
} }
} }

View File

@ -104,7 +104,7 @@ function dol_getImageSize($file, $url = false)
* @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio) * @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio)
* @param int $src_x Position of croping image in source image (not use if mode=0) * @param int $src_x Position of croping image in source image (not use if mode=0)
* @param int $src_y Position of croping image in source image (not use if mode=0) * @param int $src_y Position of croping image in source image (not use if mode=0)
* @return int File name if OK, error message if KO * @return string File name if OK, error message if KO
*/ */
function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0) function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0)
{ {

View File

@ -461,7 +461,6 @@ function show_stats_for_company($product, $socid)
return $nblines++; return $nblines++;
} }
/** /**
* Return translation label of a unit key * Return translation label of a unit key
* *
@ -472,50 +471,24 @@ function show_stats_for_company($product, $socid)
*/ */
function measuring_units_string($unit, $measuring_style = '') function measuring_units_string($unit, $measuring_style = '')
{ {
global $langs; global $langs, $db;
require_once DOL_DOCUMENT_ROOT.'/core/class/cmeasuringunits.class.php';
$measuringUnits= new CMeasuringUnits($db);
$result = $measuringUnits->fetchAll('', '', 0, 0, array(
't.code' => $unit,
't.unit_type' => $measuring_style,
't.active' => 1
));
$measuring_units=array(); if ($result<0) {
if ($measuring_style == 'weight') return -1;
{ } else {
$measuring_units[3] = $langs->transnoentitiesnoconv("WeightUnitton"); if (is_array($measuringUnits->records) && count($measuringUnits->records)>0) {
$measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); return $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label);
$measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); } else {
$measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); return '';
$measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce");
$measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound");
} }
elseif ($measuring_style == 'size')
{
$measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm");
$measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm");
$measuring_units[-2] = $langs->transnoentitiesnoconv("SizeUnitcm");
$measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm");
$measuring_units[98] = $langs->transnoentitiesnoconv("SizeUnitfoot");
$measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch");
} }
elseif ($measuring_style == 'surface')
{
$measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2");
$measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2");
$measuring_units[-4] = $langs->transnoentitiesnoconv("SurfaceUnitcm2");
$measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2");
$measuring_units[98] = $langs->transnoentitiesnoconv("SurfaceUnitfoot2");
$measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2");
}
elseif ($measuring_style == 'volume')
{
$measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3");
$measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3");
$measuring_units[-6] = $langs->transnoentitiesnoconv("VolumeUnitcm3");
$measuring_units[-9] = $langs->transnoentitiesnoconv("VolumeUnitmm3");
$measuring_units[88] = $langs->transnoentitiesnoconv("VolumeUnitfoot3");
$measuring_units[89] = $langs->transnoentitiesnoconv("VolumeUnitinch3");
$measuring_units[97] = $langs->transnoentitiesnoconv("VolumeUnitounce");
$measuring_units[98] = $langs->transnoentitiesnoconv("VolumeUnitlitre");
$measuring_units[99] = $langs->transnoentitiesnoconv("VolumeUnitgallon");
}
return $measuring_units[$unit];
} }
/** /**

View File

@ -86,7 +86,7 @@ function tax_prepare_head(ChargeSociales $object)
* @param string $direction 'sell' or 'buy' * @param string $direction 'sell' or 'buy'
* @param int $m Month * @param int $m Month
* @param int $q Quarter * @param int $q Quarter
* @return array Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error * @return array|int Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error
*/ */
function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m = 0, $q = 0) function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m = 0, $q = 0)
{ {
@ -111,7 +111,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
$paymentfacturetable='paiement_facture'; $paymentfacturetable='paiement_facture';
$invoicefieldref='ref'; $invoicefieldref='ref';
} }
if ($direction == 'buy') elseif ($direction == 'buy')
{ {
$invoicetable='facture_fourn'; $invoicetable='facture_fourn';
$invoicedettable='facture_fourn_det'; $invoicedettable='facture_fourn_det';
@ -554,7 +554,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
* @param int $modetax Not used * @param int $modetax Not used
* @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices)
* @param int $m Month * @param int $m Month
* @return array Array with details of VATs (per rate), -1 if no accountancy module, -2 if not yet developped, -3 if error * @return array|int Array with details of VATs (per rate), -1 if no accountancy module, -2 if not yet developped, -3 if error
*/ */
function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m = 0) function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m = 0)
{ {

View File

@ -115,7 +115,7 @@ function tree_showpad(&$fulltree, $key, $silent = 0)
*/ */
function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoresetalreadyloaded = 0, $showfk = 0) function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoresetalreadyloaded = 0, $showfk = 0)
{ {
global $tree_recur_alreadyadded; global $tree_recur_alreadyadded, $menu_handler_to_search;
if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array();
@ -203,7 +203,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset
if ($showfk) if ($showfk)
{ {
print '<table class="nobordernopadding centpercent"><tr><td>'; print '<table class="nobordernopadding centpercent"><tr><td>';
print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'; print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$tab[$x]['rowid'].'">';
print $tab[$x]['title']; print $tab[$x]['title'];
print '</a></strong>'; print '</a></strong>';
print '&nbsp; (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; print '&nbsp; (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';

View File

@ -471,6 +471,43 @@ class ImportCsv extends ModeleImports
{ {
if (empty($newval)) $newval='0'; if (empty($newval)) $newval='0';
} }
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits')
{
$file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']);
$class=$objimport->array_import_convertvalue[0][$val]['class'];
$method=$objimport->array_import_convertvalue[0][$val]['method'];
$units=$objimport->array_import_convertvalue[0][$val]['units'];
if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] != '')
{
$newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval];
}
else
{
$resultload = dol_include_once($file);
if (empty($resultload))
{
dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units);
break;
}
$classinstance=new $class($this->db);
// Try the fetch from code or ref
call_user_func_array(array($classinstance, $method), array('', $units, $newval));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code;
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. ';
if ($classinstance->code != '') // id may be 0, it is a found value
{
$newval=$classinstance->code;
}
else
{
if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
else $this->errors[$error]['lib']='ErrorFieldValueNotIn';
$this->errors[$error]['type']='FOREIGNKEY';
$errorforthistable++;
$error++;
}
}
}
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto')
{ {
if (strtolower($newval) == 'auto') if (strtolower($newval) == 'auto')

View File

@ -498,6 +498,43 @@ class ImportXlsx extends ModeleImports
{ {
if (empty($newval)) $newval='0'; if (empty($newval)) $newval='0';
} }
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits')
{
$file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']);
$class=$objimport->array_import_convertvalue[0][$val]['class'];
$method=$objimport->array_import_convertvalue[0][$val]['method'];
$units=$objimport->array_import_convertvalue[0][$val]['units'];
if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] != '')
{
$newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval];
}
else
{
$resultload = dol_include_once($file);
if (empty($resultload))
{
dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units);
break;
}
$classinstance=new $class($this->db);
// Try the fetch from code or ref
call_user_func_array(array($classinstance, $method), array('', $units, '', $newval));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code;
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. ';
if ($classinstance->code != '') // id may be 0, it is a found value
{
$newval=$classinstance->code;
}
else
{
if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict']));
else $this->errors[$error]['lib']='ErrorFieldValueNotIn';
$this->errors[$error]['type']='FOREIGNKEY';
$errorforthistable++;
$error++;
}
}
}
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto')
{ {
if (strtolower($newval) == 'auto') if (strtolower($newval) == 'auto')

View File

@ -313,8 +313,11 @@ class modProduct extends DolibarrModules
'p.note' => "PrivateNote",//private note 'p.note' => "PrivateNote",//private note
'p.customcode' => 'CustomCode', 'p.customcode' => 'CustomCode',
'p.price' => "SellingPriceHT",//without tax 'p.price' => "SellingPriceHT",//without tax
'p.price_min' => "MinPrice",
'p.price_ttc' => "SellingPriceTTC",//with tax 'p.price_ttc' => "SellingPriceTTC",//with tax
'p.price_min_ttc' => "SellingMinPriceTTC",
'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card
'p.cost_price' => "CostPrice",
'p.tva_tx' => 'VATRate', 'p.tva_tx' => 'VATRate',
'p.tosell' => "OnSell*", 'p.tosell' => "OnSell*",
'p.tobuy' => "OnBuy*", 'p.tobuy' => "OnBuy*",
@ -324,12 +327,18 @@ class modProduct extends DolibarrModules
'p.accountancy_code_sell' => "ProductAccountancySellCode", 'p.accountancy_code_sell' => "ProductAccountancySellCode",
'p.accountancy_code_buy' => "ProductAccountancyBuyCode", 'p.accountancy_code_buy' => "ProductAccountancyBuyCode",
'p.weight' => "Weight", 'p.weight' => "Weight",
'p.weight_units' => "WeightUnits",
'p.length' => "Length", 'p.length' => "Length",
'p.length_units' => "LengthUnit",
'p.width' => "Width", 'p.width' => "Width",
'p.width_units' => "VolumeUnits",
'p.height' => "Height", 'p.height' => "Height",
'p.height_units' => "HeightUnit",
'p.surface' => "Surface", 'p.surface' => "Surface",
'p.surface_units' => "SurfaceUnit",
'p.volume' => "Volume", 'p.volume' => "Volume",
'p.finished' => 'Nature' 'p.volume_units' => "VolumeUnits",
'p.finished' => 'Nature',
); );
if (!empty($conf->stock->enabled)) {//if Stock module enabled if (!empty($conf->stock->enabled)) {//if Stock module enabled
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
@ -338,6 +347,58 @@ class modProduct extends DolibarrModules
'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
)); ));
} }
$this->import_convertvalue_array[$r] = array(
'p.weight_units' => array(
'rule' => 'fetchidfromcodeunits',
'classfile' => '/core/class/cmeasuringunits.class.php',
'class' => 'CMeasuringUnits',
'method' => 'fetch',
'units' => 'weight',
'dict' => 'DictionaryMeasuringUnits'
),
'p.length_units' => array(
'rule' => 'fetchidfromcodeunits',
'classfile' => '/core/class/cmeasuringunits.class.php',
'class' => 'CMeasuringUnits',
'method' => 'fetch',
'units' => 'size',
'dict' => 'DictionaryMeasuringUnits'
),
'p.width_units' => array(
'rule' => 'fetchidfromcodeunits',
'classfile' => '/core/class/cmeasuringunits.class.php',
'class' => 'CMeasuringUnits',
'method' => 'fetch',
'units' => 'size',
'dict' => 'DictionaryMeasuringUnits'
),
'p.height_units' => array(
'rule' => 'fetchidfromcodeunits',
'classfile' => '/core/class/cmeasuringunits.class.php',
'class' => 'CMeasuringUnits',
'method' => 'fetch',
'units' => 'size',
'dict' => 'DictionaryMeasuringUnits'
),
'p.surface_units' => array(
'rule' => 'fetchidfromcodeunits',
'classfile' => '/core/class/cmeasuringunits.class.php',
'class' => 'CMeasuringUnits',
'method' => 'fetch',
'units' => 'surface',
'dict' => 'DictionaryMeasuringUnits'
),
'p.volume_units' => array(
'rule' => 'fetchidfromcodeunits',
'classfile' => '/core/class/cmeasuringunits.class.php',
'class' => 'CMeasuringUnits',
'method' => 'fetch',
'units' => 'volume',
'dict' => 'DictionaryMeasuringUnits'
)
);
if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type'));
@ -371,7 +432,8 @@ class modProduct extends DolibarrModules
'p.finished' => '^[0|1]$' 'p.finished' => '^[0|1]$'
); );
$import_sample = array(//field order as per structure of table llx_product // field order as per structure of table llx_product
$import_sample = array(
'p.ref' => "PREF123456", 'p.ref' => "PREF123456",
'p.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'), 'p.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
'p.label' => "Product name in default language", 'p.label' => "Product name in default language",
@ -380,7 +442,9 @@ class modProduct extends DolibarrModules
'p.note' => "a private note (free text)", 'p.note' => "a private note (free text)",
'p.customcode' => 'customs code', 'p.customcode' => 'customs code',
'p.price' => "price ex-vat eg. 100", 'p.price' => "price ex-vat eg. 100",
'p.price_min' => "price ex-vat eg. 100",
'p.price_ttc' => "price inc-vat eg. 110", 'p.price_ttc' => "price inc-vat eg. 110",
'p.price_min_ttc' => "price inc-vat eg. 110",
'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
'p.tva_tx' => 'tax rate eg: 10. Must match numerically one of the tax rates defined for your country', 'p.tva_tx' => 'tax rate eg: 10. Must match numerically one of the tax rates defined for your country',
'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",
@ -391,11 +455,17 @@ class modProduct extends DolibarrModules
'p.accountancy_code_sell' => "", 'p.accountancy_code_sell' => "",
'p.accountancy_code_buy' => "", 'p.accountancy_code_buy' => "",
'p.weight' => "", 'p.weight' => "",
'p.weight_units' => 'use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short Label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_measuring_units',
'p.length' => "", 'p.length' => "",
'p.length_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short Label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_measuring_units',
'p.width' => "", 'p.width' => "",
'p.width_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short Label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_measuring_units',
'p.height' => "", 'p.height' => "",
'p.height_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short Label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_measuring_units',
'p.surface' => "", 'p.surface' => "",
'p.surface_units' => 'use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short Label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_measuring_units',
'p.volume' => "", 'p.volume' => "",
'p.volume_units' => 'use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short Label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_measuring_units',
'p.finished' => '0 (raw material) / 1 (finished goods)' 'p.finished' => '0 (raw material) / 1 (finished goods)'
); );
//clauses copied from import_fields_array //clauses copied from import_fields_array
@ -409,8 +479,21 @@ class modProduct extends DolibarrModules
if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>''));
if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));
if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>''));
if (! empty($conf->global->PRODUCT_USE_UNITS)) $import_sample=array_merge($import_sample, array('p.fk_unit'=>'use a unit of measure from the dictionary. 1/2/3 etc....matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_units"')); if (! empty($conf->global->PRODUCT_USE_UNITS)) {
$import_sample = array_merge($import_sample, array(
'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"'
));
$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
'p.fk_unit' => array(
'rule' => 'fetchidfromcodeorlabel',
'classfile' => '/core/class/cunits.class.php',
'class' => 'CUnits',
'method' => 'fetch',
'dict' => 'DictionaryUnits'
)
));
}
$this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');
if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled

View File

@ -92,6 +92,11 @@ class Don extends CommonObject
public $labelstatut; public $labelstatut;
public $labelstatutshort; public $labelstatutshort;
/**
* Draft
*/
const STATUS_DRAFT = 0;
/** /**
* Constructor * Constructor

View File

@ -274,4 +274,5 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (24
INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (244,'ME','MNE','Monténégro',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (244,'ME','MNE','Monténégro',1,0);
INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (245,'BL','BLM','Saint-Barthélemy',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (245,'BL','BLM','Saint-Barthélemy',1,0);
INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (246,'MF','MAF','Saint-Martin',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (246,'MF','MAF','Saint-Martin',1,0);
INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (247,'XK','XKX','Kosovo',1,0);

View File

@ -0,0 +1,51 @@
-- ========================================================================
-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2019 Florian Henry <florian.henry@atm-consulitng.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
-- the Free Software Foundation; either version 2 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/>.
--
-- ========================================================================
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('3','WeightUnitton','T', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','WeightUnitkg','Kg', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','WeightUnitg','g', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','WeightUnitmg','g', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','WeightUnitounce','Oz', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','WeightUnitpound','lb', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','SizeUnitm','m', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-1','SizeUnitdm','dm', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-2','SizeUnitcm','cm', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','SizeUnitmm','mm', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','SizeUnitfoot','ft', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','SizeUnitinch','in', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','SurfaceUnitm2','m2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-2','SurfaceUnitdm2','dm2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-4','SurfaceUnitcm2','cm2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','SurfaceUnitmm2','mm2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','SurfaceUnitfoot2','ft2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','SurfaceUnitinch2','in2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','VolumeUnitm3','m3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','VolumeUnitdm3','dm3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','VolumeUnitcm3','cm3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-9','VolumeUnitmm3','mm3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('88','VolumeUnitfoot3','ft3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('89','VolumeUnitinch3','in3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('97','VolumeUnitounce','Oz', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','VolumeUnitlitre','L', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','VolumeUnitgallon','gal', 'volume', 1);

View File

@ -262,6 +262,7 @@ CREATE TABLE llx_pos_cash_fence(
-- VMYSQL4.3 ALTER TABLE llx_accounting_account MODIFY COLUMN account_number varchar(32) NOT NULL; -- VMYSQL4.3 ALTER TABLE llx_accounting_account MODIFY COLUMN account_number varchar(32) NOT NULL;
-- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_number SET NOT NULL; -- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_number SET NOT NULL;
-- Withdrawals / Prelevements -- Withdrawals / Prelevements
UPDATE llx_const set name = 'PRELEVEMENT_END_TO_END' where name = 'END_TO_END'; UPDATE llx_const set name = 'PRELEVEMENT_END_TO_END' where name = 'END_TO_END';
UPDATE llx_const set name = 'PRELEVEMENT_USTRD' where name = 'USTRD'; UPDATE llx_const set name = 'PRELEVEMENT_USTRD' where name = 'USTRD';

View File

@ -94,8 +94,52 @@ ALTER TABLE llx_don ADD COLUMN fk_soc integer NULL;
ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32);
ALTER TABLE llx_prelevement_facture_demande ADD COLUMN entity integer(11); ALTER TABLE llx_prelevement_facture_demande ADD COLUMN entity integer(11);
ALTER TABLE llx_prelevement_facture_demande ADD COLUMN sourcetype varchar(32); ALTER TABLE llx_prelevement_facture_demande ADD COLUMN sourcetype varchar(32);
ALTER TABLE llx_prelevement_facture_demande ADD COLUMN fk_soc integer(11); ALTER TABLE llx_prelevement_facture_demande ADD COLUMN fk_soc integer(11);
ALTER TABLE llx_prelevement_facture_demande ADD COLUMN ext_payment_id varchar(128) NULL; ALTER TABLE llx_prelevement_facture_demande ADD COLUMN ext_payment_id varchar(128) NULL;
ALTER TABLE llx_prelevement_facture_demande ADD COLUMN ext_payment_site varchar(128) NULL; ALTER TABLE llx_prelevement_facture_demande ADD COLUMN ext_payment_site varchar(128) NULL;
CREATE TABLE llx_c_measuring_units(
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(3),
label varchar(50),
short_label varchar(5),
unit_type varchar(10),
active tinyint DEFAULT 1 NOT NULL
) ENGINE=innodb;
ALTER TABLE llx_c_measuring_units ADD UNIQUE uk_c_measuring_units_code(code,unit_type);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('3','WeightUnitton','T', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','WeightUnitkg','Kg', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','WeightUnitg','g', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','WeightUnitmg','g', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','WeightUnitounce','Oz', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','WeightUnitpound','lb', 'weight', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','SizeUnitm','m', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-1','SizeUnitdm','dm', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-2','SizeUnitcm','cm', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','SizeUnitmm','mm', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','SizeUnitfoot','ft', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','SizeUnitinch','in', 'size', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','SurfaceUnitm2','m2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-2','SurfaceUnitdm2','dm2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-4','SurfaceUnitcm2','cm2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','SurfaceUnitmm2','mm2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','SurfaceUnitfoot2','ft2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','SurfaceUnitinch2','in2', 'surface', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','VolumeUnitm3','m3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','VolumeUnitdm3','dm3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','VolumeUnitcm3','cm3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-9','VolumeUnitmm3','mm3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('88','VolumeUnitfoot3','ft3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('89','VolumeUnitinch3','in3', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('97','VolumeUnitounce','Oz', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','VolumeUnitlitre','L', 'volume', 1);
INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','VolumeUnitgallon','gal', 'volume', 1);

View File

@ -0,0 +1,21 @@
-- ========================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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
-- the Free Software Foundation; either version 2 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/>.
--
-- ========================================================================
ALTER TABLE llx_c_measuring_units ADD UNIQUE uk_c_measuring_units_code(code,unit_type);

View File

@ -0,0 +1,28 @@
-- ========================================================================
-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.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
-- the Free Software Foundation; either version 2 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/>.
--
-- ========================================================================
create table llx_c_measuring_units(
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(3),
label varchar(50),
short_label varchar(5),
unit_type varchar(10),
active tinyint DEFAULT 1 NOT NULL
) ENGINE=innodb;

View File

@ -919,6 +919,7 @@ DictionaryAccountancysystem=Models for chart of accounts
DictionaryAccountancyJournal=Accounting journals DictionaryAccountancyJournal=Accounting journals
DictionaryEMailTemplates=Email Templates DictionaryEMailTemplates=Email Templates
DictionaryUnits=Units DictionaryUnits=Units
DictionaryMeasuringUnits=Measuring Units
DictionaryProspectStatus=Prospect status DictionaryProspectStatus=Prospect status
DictionaryHolidayTypes=Types of leave DictionaryHolidayTypes=Types of leave
DictionaryOpportunityStatus=Lead status for project/lead DictionaryOpportunityStatus=Lead status for project/lead

View File

@ -64,6 +64,7 @@ AppliedPricesFrom=Applied from
SellingPrice=Selling price SellingPrice=Selling price
SellingPriceHT=Selling price (excl. tax) SellingPriceHT=Selling price (excl. tax)
SellingPriceTTC=Selling price (inc. tax) SellingPriceTTC=Selling price (inc. tax)
SellingMinPriceTTC=Minimum Selling price (inc. tax)
CostPriceDescription=This price field (excl. tax) can be used to store the average amount this product costs to your company. It may be any price you calculate yourself, for example from the average buying price plus average production and distribution cost. CostPriceDescription=This price field (excl. tax) can be used to store the average amount this product costs to your company. It may be any price you calculate yourself, for example from the average buying price plus average production and distribution cost.
CostPriceUsage=This value could be used for margin calculation. CostPriceUsage=This value could be used for margin calculation.
SoldAmount=Sold amount SoldAmount=Sold amount

View File

@ -421,6 +421,20 @@ if (! empty($_SESSION["disablemodules"]))
} }
} }
// Set current modulepart
$modulepart = explode("/", $_SERVER["PHP_SELF"]);
if(is_array($modulepart) && count($modulepart)>0)
{
foreach($conf->modules as $module)
{
if(in_array($module, $modulepart))
{
$conf->modulepart = $module;
break;
}
}
}
/* /*
* Phase authentication / login * Phase authentication / login
*/ */

View File

@ -225,8 +225,6 @@ if ($result)
if ($num > 0) if ($num > 0)
{ {
$var=true;
$group_list = array(); $group_list = array();
while ($objp = $db->fetch_object($result)) { while ($objp = $db->fetch_object($result)) {
if ($agentid > 0) { if ($agentid > 0) {

View File

@ -311,31 +311,38 @@ class FormProduct
function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0)
{ {
//phpcs:enable //phpcs:enable
global $langs,$conf,$mysoc; global $langs, $conf, $mysoc, $db;
$langs->load("other"); $langs->load("other");
$return = ''; $return = '';
$measuring_units = array(); $measuring_units = array();
if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,98=>1,99=>1);
elseif ($measuring_style == 'size') $measuring_units=array(-3=>1,-2=>1,-1=>1,0=>1,98=>1,99=>1);
elseif ($measuring_style == 'surface') $measuring_units=array(-6=>1,-4=>1,-2=>1,0=>1,98=>1,99=>1);
elseif ($measuring_style == 'volume') $measuring_units=array(-9=>1,-6=>1,-3=>1,0=>1,88=>1,89=>1,97=>1,99=>1,/* 98=>1 */); // Liter is not used as already available with dm3
require_once DOL_DOCUMENT_ROOT . '/core/class/cmeasuringunits.class.php';
$measuringUnits = new CMeasuringUnits($db);
$result = $measuringUnits->fetchAll('', '', 0, 0, array(
't.unit_type' => $measuring_style,
't.active' => 1
));
if ($result < 0) {
dol_print_error($db);
return - 1;
} else {
$return .= '<select class="flat" name="' . $name . '">'; $return .= '<select class="flat" name="' . $name . '">';
if ($adddefault) $return.= '<option value="0">'.$langs->trans("Default").'</option>'; if ($adddefault)
$return .= '<option value="0">' . $langs->trans("Default") . '</option>';
foreach ($measuring_units as $key => $value) foreach ($measuringUnits->records as $lines)
{
$return.= '<option value="'.$key.'"';
if ($key == $default)
{ {
$return .= '<option value="' . $lines->code . '"';
if ($key == $default) {
$return .= ' selected'; $return .= ' selected';
} }
// $return.= '>'.$value.'</option>'; // $return.= '>'.$value.'</option>';
$return.= '>'.measuring_units_string($key, $measuring_style).'</option>'; $return .= '>' . $langs->transnoentitiesnoconv($lines->label) . '</option>';
} }
$return .= '</select>'; $return .= '</select>';
}
return $return; return $return;
} }

View File

@ -52,23 +52,23 @@ $result=restrictedArea($user,'stock');
$id=GETPOST('id', 'int'); $id=GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$msid=GETPOST('msid', 'int'); $msid=GETPOST('msid', 'int');
$product_id=GETPOST("product_id"); $product_id=GETPOST("product_id", 'int');
$action=GETPOST('action', 'aZ09'); $action=GETPOST('action', 'aZ09');
$cancel=GETPOST('cancel', 'alpha'); $cancel=GETPOST('cancel', 'alpha');
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist';
$idproduct = GETPOST('idproduct', 'int'); $idproduct = GETPOST('idproduct', 'int');
$year = GETPOST("year"); $year = GETPOST("year", 'int');
$month = GETPOST("month"); $month = GETPOST("month", 'int');
$search_ref = GETPOST('search_ref', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha');
$search_movement = GETPOST("search_movement"); $search_movement = GETPOST("search_movement", 'alpha');
$search_product_ref = trim(GETPOST("search_product_ref")); $search_product_ref = trim(GETPOST("search_product_ref", 'alpha'));
$search_product = trim(GETPOST("search_product")); $search_product = trim(GETPOST("search_product", 'alpha'));
$search_warehouse = trim(GETPOST("search_warehouse")); $search_warehouse = trim(GETPOST("search_warehouse", 'alpha'));
$search_inventorycode = trim(GETPOST("search_inventorycode")); $search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha'));
$search_user = trim(GETPOST("search_user")); $search_user = trim(GETPOST("search_user", 'alpha'));
$search_batch = trim(GETPOST("search_batch")); $search_batch = trim(GETPOST("search_batch", 'alpha'));
$search_qty = trim(GETPOST("search_qty")); $search_qty = trim(GETPOST("search_qty", 'alpha'));
$search_type_mouvement=GETPOST('search_type_mouvement', 'int'); $search_type_mouvement=GETPOST('search_type_mouvement', 'int');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
@ -185,22 +185,24 @@ if ($action == "correct_stock")
if ($product->hasbatch()) if ($product->hasbatch())
{ {
$batch=GETPOST('batch_number'); $batch=GETPOST('batch_number', 'alpha');
//$eatby=GETPOST('eatby'); //$eatby=GETPOST('eatby');
//$sellby=GETPOST('sellby'); //$sellby=GETPOST('sellby');
$eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); $eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int'));
$sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); $sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int'));
$result=$product->correct_stock_batch( $result=$product->correct_stock_batch(
$user, $user,
$id, $id,
GETPOST("nbpiece", 'int'), GETPOST("nbpiece", 'int'),
GETPOST("mouvement"), GETPOST("mouvement", 'int'),
GETPOST("label", 'san_alpha'), GETPOST("label", 'san_alpha'),
GETPOST('unitprice'), GETPOST('unitprice', 'alpha'),
$eatby,$sellby,$batch, $eatby,
GETPOST('inventorycode'), $sellby,
$batch,
GETPOST('inventorycode', 'alpha'),
$origin_element, $origin_element,
$origin_id $origin_id
); // We do not change value of stock for a correction ); // We do not change value of stock for a correction
@ -211,10 +213,10 @@ if ($action == "correct_stock")
$user, $user,
$id, $id,
GETPOST("nbpiece", 'int'), GETPOST("nbpiece", 'int'),
GETPOST("mouvement"), GETPOST("mouvement", 'alpha'),
GETPOST("label", 'san_alpha'), GETPOST("label", 'san_alpha'),
GETPOST('unitprice'), GETPOST('unitprice', 'alpha'),
GETPOST('inventorycode'), GETPOST('inventorycode', 'alpha'),
$origin_element, $origin_element,
$origin_id $origin_id
); // We do not change value of stock for a correction ); // We do not change value of stock for a correction
@ -272,7 +274,7 @@ if ($action == "transfert_stock" && ! $cancel)
$product = new Product($db); $product = new Product($db);
$result=$product->fetch($product_id); $result=$product->fetch($product_id);
if ($product->hasbatch() && ! GETPOST("batch_number")) if ($product->hasbatch() && ! GETPOST("batch_number", 'alpha'))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors');
$error++; $error++;
@ -319,7 +321,7 @@ if ($action == "transfert_stock" && ! $cancel)
else else
{ {
$srcwarehouseid=$id; $srcwarehouseid=$id;
$batch=GETPOST('batch_number'); $batch=GETPOST('batch_number', 'alpha');
$eatby=$d_eatby; $eatby=$d_eatby;
$sellby=$d_sellby; $sellby=$d_sellby;
} }
@ -334,8 +336,10 @@ if ($action == "transfert_stock" && ! $cancel)
1, 1,
GETPOST("label", 'san_alpha'), GETPOST("label", 'san_alpha'),
$pricesrc, $pricesrc,
$eatby,$sellby,$batch, $eatby,
GETPOST('inventorycode') $sellby,
$batch,
GETPOST('inventorycode', 'alpha')
); );
// Add stock // Add stock
$result2=$product->correct_stock_batch( $result2=$product->correct_stock_batch(
@ -345,8 +349,10 @@ if ($action == "transfert_stock" && ! $cancel)
0, 0,
GETPOST("label", 'san_alpha'), GETPOST("label", 'san_alpha'),
$pricedest, $pricedest,
$eatby,$sellby,$batch, $eatby,
GETPOST('inventorycode') $sellby,
$batch,
GETPOST('inventorycode', 'alpha')
); );
} }
} }
@ -356,22 +362,22 @@ if ($action == "transfert_stock" && ! $cancel)
$result1=$product->correct_stock( $result1=$product->correct_stock(
$user, $user,
$id, $id,
GETPOST("nbpiece"), GETPOST("nbpiece", 'int'),
1, 1,
GETPOST("label"), GETPOST("label", 'alpha'),
$pricesrc, $pricesrc,
GETPOST('inventorycode') GETPOST('inventorycode', 'alpha')
); );
// Add stock // Add stock
$result2=$product->correct_stock( $result2=$product->correct_stock(
$user, $user,
GETPOST("id_entrepot_destination"), GETPOST("id_entrepot_destination"),
GETPOST("nbpiece"), GETPOST("nbpiece", 'int'),
0, 0,
GETPOST("label"), GETPOST("label", 'alpha'),
$pricedest, $pricedest,
GETPOST('inventorycode') GETPOST('inventorycode', 'alpha')
); );
} }
if (! $error && $result1 >= 0 && $result2 >= 0) if (! $error && $result1 >= 0 && $result2 >= 0)
@ -615,7 +621,7 @@ if ($resql)
// Last movement // Last movement
$sql = "SELECT MAX(m.datem) as datem"; $sql = "SELECT MAX(m.datem) as datem";
$sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
$sql .= " WHERE m.fk_entrepot = '".$object->id."'"; $sql .= " WHERE m.fk_entrepot = ".(int) $object->id;
$resqlbis = $db->query($sql); $resqlbis = $db->query($sql);
if ($resqlbis) if ($resqlbis)
{ {
@ -693,9 +699,9 @@ if ($resql)
} }
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($id > 0) $param.='&id='.$id; if ($id > 0) $param.='&id='.urlencode($id);
if ($search_movement) $param.='&search_movement='.urlencode($search_movement); if ($search_movement) $param.='&search_movement='.urlencode($search_movement);
if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode); if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode);
if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement); if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement);
@ -706,7 +712,7 @@ if ($resql)
if (!empty($sref)) $param.='&sref='.urlencode($sref); // FIXME $sref is not defined if (!empty($sref)) $param.='&sref='.urlencode($sref); // FIXME $sref is not defined
if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined
if ($search_user) $param.='&search_user='.urlencode($search_user); if ($search_user) $param.='&search_user='.urlencode($search_user);
if ($idproduct > 0) $param.='&idproduct='.$idproduct; if ($idproduct > 0) $param.='&idproduct='.urlencode($idproduct);
// Add $param from extra fields // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -905,21 +911,36 @@ if ($resql)
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'],$_SERVER["PHP_SELF"],'m.rowid','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['m.rowid']['checked']))
if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'],$_SERVER["PHP_SELF"],'m.datem','',$param,'',$sortfield,$sortorder); print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['m.datem']['checked']))
if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'],$_SERVER["PHP_SELF"],'p.label','',$param,'',$sortfield,$sortorder); print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.ref']['checked']))
if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.label']['checked']))
if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'],$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.batch']['checked']))
if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['pl.eatby']['checked']))
if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'],$_SERVER["PHP_SELF"], "m.type_mouvement","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['pl.sellby']['checked']))
if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['e.ref']['checked']))
print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); // We are on a specific warehouse card, no filter on other should be possible
if (! empty($arrayfields['m.fk_user_author']['checked']))
print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['m.inventorycode']['checked']))
print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['m.label']['checked']))
print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['m.type_mouvement']['checked']))
print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['origin']['checked']))
print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['m.value']['checked']))
print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, 'align="right"', $sortfield, $sortorder);
if (! empty($arrayfields['m.price']['checked']))
print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, 'align="right"', $sortfield, $sortorder);
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';

View File

@ -1045,8 +1045,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$contactsofproject=$projectstatic->getListContactId('internal'); $contactsofproject=$projectstatic->getListContactId('internal');
if (count($contactsofproject)>0) if (count($contactsofproject)>0)
{ {
if (in_array($user->id, $userid=$contactsofproject)) $userid = $user->id; if (in_array($user->id, $contactsofproject)) $userid = $user->id;
else $userid = $contactsofproject[0]; else $userid = $contactsofproject[0];
if ($projectstatic->public) $contactsofproject = array(); if ($projectstatic->public) $contactsofproject = array();
print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200');
} }

View File

@ -85,7 +85,7 @@ class FormResource
$resourcestat = new Dolresource($this->db); $resourcestat = new Dolresource($this->db);
$resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter=''); $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter);
if ($outputmode != 2) if ($outputmode != 2)
{ {

View File

@ -13,6 +13,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2016 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) 2019 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
@ -1814,7 +1815,7 @@ class SupplierProposal extends CommonObject
* Upate ProductFournisseur * Upate ProductFournisseur
* *
* @param int $idProductFournPrice id of llx_product_fournisseur_price * @param int $idProductFournPrice id of llx_product_fournisseur_price
* @param int $product contain informations to update * @param Product $product contain informations to update
* @param User $user Object user * @param User $user Object user
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */

View File

@ -1104,8 +1104,7 @@ if ($action == 'create' || $action == 'adduserldap')
{ {
print '<tr><td>' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . '</td><td colspan="3">'; print '<tr><td>' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . '</td><td colspan="3">';
$cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1);
print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, null, '90%');
null, '90%' );
print "</td></tr>"; print "</td></tr>";
} }

View File

@ -190,6 +190,8 @@ function getCategory($authentication, $id)
{ {
global $db,$conf,$langs; global $db,$conf,$langs;
$nbmax = 10;
dol_syslog("Function: getCategory login=".$authentication['login']." id=".$id); dol_syslog("Function: getCategory login=".$authentication['login']." id=".$id);
if ($authentication['entity']) $conf->entity=$authentication['entity']; if ($authentication['entity']) $conf->entity=$authentication['entity'];
@ -209,6 +211,7 @@ function getCategory($authentication, $id)
{ {
$fuser->getrights(); $fuser->getrights();
$nbmax = 10;
if ($fuser->rights->categorie->lire) if ($fuser->rights->categorie->lire)
{ {
$categorie=new Categorie($db); $categorie=new Categorie($db);
@ -228,7 +231,7 @@ function getCategory($authentication, $id)
//'visible'=>$categorie->visible, //'visible'=>$categorie->visible,
'type' => $categorie->type, 'type' => $categorie->type,
'dir' => $pdir, 'dir' => $pdir,
'photos' => $categorie->liste_photos($dir, $nbmax=10) 'photos' => $categorie->liste_photos($dir, $nbmax)
); );
$cats = $categorie->get_filles(); $cats = $categorie->get_filles();
@ -248,7 +251,7 @@ function getCategory($authentication, $id)
//'visible'=>$fille->visible, //'visible'=>$fille->visible,
'type'=>$fille->type, 'type'=>$fille->type,
'dir' => $pdir, 'dir' => $pdir,
'photos' => $fille->liste_photos($dir, $nbmax=10) 'photos' => $fille->liste_photos($dir, $nbmax)
); );
} }
} }

View File

@ -364,6 +364,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
$fuser->getrights(); $fuser->getrights();
$nbmax = 10;
if ($fuser->rights->produit->lire || $fuser->rights->service->lire) if ($fuser->rights->produit->lire || $fuser->rights->service->lire)
{ {
$product=new Product($db); $product=new Product($db);
@ -417,7 +418,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
'pmp' => $product->pmp, 'pmp' => $product->pmp,
'import_key' => $product->import_key, 'import_key' => $product->import_key,
'dir' => $pdir, 'dir' => $pdir,
'images' => $product->liste_photos($dir, $nbmax=10) 'images' => $product->liste_photos($dir, $nbmax)
); );
//Retreive all extrafield for thirdsparty //Retreive all extrafield for thirdsparty
@ -1029,6 +1030,7 @@ function getProductsForCategory($authentication, $id, $lang = '')
$fuser->getrights(); $fuser->getrights();
$nbmax = 10;
if ($fuser->rights->produit->lire) if ($fuser->rights->produit->lire)
{ {
$categorie=new Categorie($db); $categorie=new Categorie($db);
@ -1086,7 +1088,7 @@ function getProductsForCategory($authentication, $id, $lang = '')
'pmp' => $obj->pmp, 'pmp' => $obj->pmp,
'import_key' => $obj->import_key, 'import_key' => $obj->import_key,
'dir' => $pdir, 'dir' => $pdir,
'images' => $obj->liste_photos($dir, $nbmax=10) 'images' => $obj->liste_photos($dir, $nbmax)
); );
//Retreive all extrafield for thirdsparty //Retreive all extrafield for thirdsparty