Merge branch 'develop' into patch-21

This commit is contained in:
Laurent Destailleur 2019-02-14 13:27:46 +01:00 committed by GitHub
commit 67c8ab47ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 283 additions and 636 deletions

View File

@ -227,7 +227,7 @@ class AccountingJournal extends CommonObject
if (! empty($this->code))
$label .= '<br><b>'.$langs->trans('Code') . ':</b> ' . $this->code;
if (! empty($this->label))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $this->label;
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $langs->transnoentities($this->label);
if ($moretitle) $label.=' - '.$moretitle;
$linkclose='';
@ -254,7 +254,7 @@ class AccountingJournal extends CommonObject
}
$label_link = $this->code;
if ($withlabel) $label_link .= ' - ' . $this->label;
if ($withlabel) $label_link .= ' - ' . $langs->transnoentities($this->label);
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);

View File

@ -117,7 +117,7 @@ $tabname[22]= MAIN_DB_PREFIX."c_input_reason";
$tabname[23]= MAIN_DB_PREFIX."c_revenuestamp";
$tabname[24]= MAIN_DB_PREFIX."c_type_resource";
$tabname[25]= MAIN_DB_PREFIX."c_type_container";
$tabname[26]= MAIN_DB_PREFIX."c_units";
//$tabname[26]= MAIN_DB_PREFIX."c_units";
$tabname[27]= MAIN_DB_PREFIX."c_stcomm";
$tabname[28]= MAIN_DB_PREFIX."c_holiday_types";
$tabname[29]= MAIN_DB_PREFIX."c_lead_status";
@ -128,7 +128,7 @@ $tabname[33]= MAIN_DB_PREFIX."c_hrm_department";
$tabname[34]= MAIN_DB_PREFIX."c_hrm_function";
$tabname[35]= MAIN_DB_PREFIX."c_exp_tax_cat";
$tabname[36]= MAIN_DB_PREFIX."c_exp_tax_range";
$tabname[37]= MAIN_DB_PREFIX."c_measuring_units";
$tabname[37]= MAIN_DB_PREFIX."c_units";
// Dictionary labels
$tablib=array();
@ -157,7 +157,7 @@ $tablib[22]= "DictionarySource";
$tablib[23]= "DictionaryRevenueStamp";
$tablib[24]= "DictionaryResourceType";
$tablib[25]= "DictionaryTypeOfContainer";
$tablib[26]= "DictionaryUnits";
//$tablib[26]= "DictionaryUnits";
$tablib[27]= "DictionaryProspectStatus";
$tablib[28]= "DictionaryHolidayTypes";
$tablib[29]= "DictionaryOpportunityStatus";
@ -197,7 +197,7 @@ $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX
$tabsql[23]= "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
$tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
$tabsql[25]= "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")";
$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
//$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
$tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm";
$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
$tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
@ -208,7 +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[35]= "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c";
$tabsql[36]= "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r";
$tabsql[37]= "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.active FROM ".MAIN_DB_PREFIX."c_measuring_units r";
$tabsql[37]= "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r";
// Criteria to sort dictionaries
$tabsqlsort=array();
@ -237,7 +237,7 @@ $tabsqlsort[22]="code ASC, label ASC";
$tabsqlsort[23]="country ASC, taux ASC";
$tabsqlsort[24]="code ASC, label ASC";
$tabsqlsort[25]="t.module ASC, t.code ASC, t.label ASC";
$tabsqlsort[26]="code ASC";
//$tabsqlsort[26]="code ASC";
$tabsqlsort[27]="code ASC";
$tabsqlsort[28]="country ASC, code ASC";
$tabsqlsort[29]="position ASC";
@ -248,7 +248,7 @@ $tabsqlsort[33]="code ASC";
$tabsqlsort[34]="code ASC";
$tabsqlsort[35]="c.label ASC";
$tabsqlsort[36]="r.fk_c_exp_tax_cat ASC, r.range_ik ASC";
$tabsqlsort[37]="r.unit_type ASC, r.code ASC";
$tabsqlsort[37]="r.unit_type ASC, r.scale ASC, r.code ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@ -277,7 +277,7 @@ $tabfield[22]= "code,label";
$tabfield[23]= "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[24]= "code,label";
$tabfield[25]= "code,label";
$tabfield[26]= "code,label,short_label";
//$tabfield[26]= "code,label,short_label";
$tabfield[27]= "code,libelle";
$tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country";
$tabfield[29]= "code,label,percent,position";
@ -288,7 +288,7 @@ $tabfield[33]= "code,label";
$tabfield[34]= "code,label";
$tabfield[35]= "label";
$tabfield[36]= "range_ik,fk_c_exp_tax_cat";
$tabfield[37]= "code,label,short_label,unit_type";
$tabfield[37]= "code,label,short_label,unit_type,scale";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
@ -317,7 +317,7 @@ $tabfieldvalue[22]= "code,label";
$tabfieldvalue[23]= "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[24]= "code,label";
$tabfieldvalue[25]= "code,label";
$tabfieldvalue[26]= "code,label,short_label";
//$tabfieldvalue[26]= "code,label,short_label";
$tabfieldvalue[27]= "code,libelle";
$tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country";
$tabfieldvalue[29]= "code,label,percent,position";
@ -328,7 +328,7 @@ $tabfieldvalue[33]= "code,label";
$tabfieldvalue[34]= "code,label";
$tabfieldvalue[35]= "label";
$tabfieldvalue[36]= "range_ik,fk_c_exp_tax_cat";
$tabfieldvalue[37]= "code,label,short_label,unit_type";
$tabfieldvalue[37]= "code,label,short_label,unit_type,scale";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
@ -357,7 +357,7 @@ $tabfieldinsert[22]= "code,label";
$tabfieldinsert[23]= "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldinsert[24]= "code,label";
$tabfieldinsert[25]= "code,label";
$tabfieldinsert[26]= "code,label,short_label";
//$tabfieldinsert[26]= "code,label,short_label";
$tabfieldinsert[27]= "code,libelle";
$tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country";
$tabfieldinsert[29]= "code,label,percent,position";
@ -368,7 +368,7 @@ $tabfieldinsert[33]= "code,label";
$tabfieldinsert[34]= "code,label";
$tabfieldinsert[35]= "label";
$tabfieldinsert[36]= "range_ik,fk_c_exp_tax_cat";
$tabfieldinsert[37]= "code,label,short_label,unit_type";
$tabfieldinsert[37]= "code,label,short_label,unit_type,scale";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
@ -399,7 +399,7 @@ $tabrowid[22]= "rowid";
$tabrowid[23]= "";
$tabrowid[24]= "";
$tabrowid[25]= "";
$tabrowid[26]= "";
//$tabrowid[26]= "";
$tabrowid[27]= "id";
$tabrowid[28]= "";
$tabrowid[29]= "";
@ -439,7 +439,7 @@ $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabl
$tabcond[23]= true;
$tabcond[24]= ! empty($conf->resource->enabled);
$tabcond[25]= ! empty($conf->website->enabled);
$tabcond[26]= ! empty($conf->product->enabled);
//$tabcond[26]= ! empty($conf->product->enabled);
$tabcond[27]= ! empty($conf->societe->enabled);
$tabcond[28]= ! empty($conf->holiday->enabled);
$tabcond[29]= ! empty($conf->projet->enabled);
@ -479,7 +479,7 @@ $tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[23] = array('revenuestamp_type'=>'FixedOfPercent');
$tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode'));
$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
//$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically"));
$tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
@ -490,7 +490,7 @@ $tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[35]= array();
$tabhelp[36]= array('range_ik'=>$langs->trans('PrevRangeToThisRange'));
$tabhelp[37]= array('short_label'=>$langs->trans("EnterAnyCode"));
$tabhelp[37]= array('code'=>$langs->trans("EnterAnyCode"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
@ -519,7 +519,7 @@ $tabfieldcheck[22] = array();
$tabfieldcheck[23] = array();
$tabfieldcheck[24] = array();
$tabfieldcheck[25] = array();
$tabfieldcheck[26] = array();
//$tabfieldcheck[26] = array();
$tabfieldcheck[27] = array();
$tabfieldcheck[28] = array();
$tabfieldcheck[29] = array();
@ -1594,7 +1594,7 @@ if ($id)
{
$valuetoshow = $langs->trans($valuetoshow);
}
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_measuring_units')
elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_units')
{
$langs->load('other');
$key = $langs->trans($obj->label);

View File

@ -1,432 +0,0 @@
<?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

@ -41,6 +41,7 @@ class CUnits // extends CommonObject
* @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
@ -53,6 +54,8 @@ class CUnits // extends CommonObject
public $code;
public $label;
public $short_label;
public $unit_type;
public $scale;
public $active;
@ -87,6 +90,7 @@ class CUnits // extends CommonObject
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);
@ -100,7 +104,8 @@ class CUnits // extends CommonObject
$sql.= "rowid,";
$sql.= "code,";
$sql.= "label,";
$sql.= "short_label";
$sql.= "short_label,";
$sql.= "unit_type";
$sql.= ") VALUES (";
@ -108,7 +113,8 @@ class CUnits // extends CommonObject
$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->escape($this->short_label)."'");
$sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->escape($this->short_label)."'").",";
$sql.= " ".(! isset($this->unit_type)?'NULL':"'".$this->db->escape($this->unit_type)."'");
$sql.= ")";
@ -160,22 +166,31 @@ class CUnits // extends CommonObject
*
* @param int $id Id object
* @param string $code Code
* @param string $short_label Label
* @return int <0 if KO, >0 if OK
* @param string $short_label Short Label
* @param string $unit_type unit type
* @return int <0 if KO, >0 if OK
*/
function fetch($id, $code = '', $short_label = '')
function fetch($id, $code = '', $short_label = '', $unit_type = '')
{
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_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)."'";
$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)
@ -188,6 +203,7 @@ class CUnits // extends CommonObject
$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);
@ -202,6 +218,91 @@ class CUnits // extends CommonObject
}
/**
* 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_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
*
@ -218,6 +319,7 @@ class CUnits // extends CommonObject
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);
@ -229,6 +331,7 @@ class CUnits // extends CommonObject
$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;

View File

@ -367,6 +367,7 @@ class FormAccounting extends Form
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE entity IN (" . getEntity('societe') . ")";
$sql .= " ORDER BY code_compta";
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
@ -377,7 +378,7 @@ class FormAccounting extends Form
}
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
return -1;
}
$this->db->free($resql);
@ -397,11 +398,31 @@ class FormAccounting extends Form
}
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
return -1;
}
$this->db->free($resql);
// Auxiliary user account
$sql = "SELECT DISTINCT accountancy_code, lastname, firstname ";
$sql .= " FROM ".MAIN_DB_PREFIX."user";
$sql .= " WHERE entity IN (" . getEntity('user') . ")";
$sql .= " ORDER BY accountancy_code";
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->accountancy_code)) {
$aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')';
}
}
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
return -1;
}
$this->db->free($resql);
// Build select
$out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);

View File

@ -106,7 +106,7 @@ function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png")
*
* @param string $code Code
* @param string $encoding Encoding
* @return array array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
* @return array|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
*/
function barcode_encode($code, $encoding)
{
@ -236,7 +236,7 @@ function barcode_encode_ean($ean, $encoding = "EAN-13")
*
* @param string $code Code
* @param string $encoding Encoding
* @return array array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
* @return array|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
*/
function barcode_encode_genbarcode($code, $encoding)
{

View File

@ -488,7 +488,7 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '',
* '1'=Add region name/code/id as needed to output,
* @param Translate $outputlangs Langs object for output translation, not fully implemented yet
* @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output
* @return mixed String with state code or state name or Array('id','code','label')/Array('id','code','label','region_code','region')
* @return string|array String with state code or state name or Array('id','code','label')/Array('id','code','label','region_code','region')
*/
function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlangs = '', $entconv = 1)
{
@ -715,7 +715,7 @@ function isInEEC($object)
* @param string $backtopage Url to go once contact is created
* @param int $nocreatelink 1=Hide create project link
* @param string $morehtmlright More html on right of title
* @return void
* @return int
*/
function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatelink = 0, $morehtmlright = '')
{
@ -843,7 +843,7 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
* @param DoliDB $db Database handler
* @param Societe $object Third party object
* @param string $backtopage Url to go once contact is created
* @return void
* @return int
*/
function show_contacts($conf, $langs, $db, $object, $backtopage = '')
{
@ -856,8 +856,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST('page', 'int');
$search_status = GETPOST("search_status", 'int');
if ($search_status=='') $search_status=1; // always display activ customer first
$search_status = GETPOST("search_status", 'int');
if ($search_status=='') $search_status=1; // always display active customer first
$search_name = GETPOST("search_name", 'alpha');
$search_addressphone = GETPOST("search_addressphone", 'alpha');
@ -1174,7 +1174,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
* @param DoliDB $db Database handler
* @param Societe $object Third party object
* @param string $backtopage Url to go once address is created
* @return void
* @return int
*/
function show_addresses($conf, $langs, $db, $object, $backtopage = '')
{
@ -1261,14 +1261,14 @@ function show_addresses($conf, $langs, $db, $object, $backtopage = '')
/**
* Show html area with actions to do
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Object db
* @param Adherent|Societe $filterobj Object third party or member
* @param Contact $objcon Object contact
* @param int $noprint Return string but does not output it
* @param int $actioncode Filter on actioncode
* @return mixed Return html part or void if noprint is 1
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Object db
* @param Adherent|Societe $filterobj Object thirdparty or member
* @param Contact $objcon Object contact
* @param int $noprint Return string but does not output it
* @param int $actioncode Filter on actioncode
* @return string|void Return html part or void if noprint is 1
*/
function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '')
{
@ -1294,7 +1294,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
* @param array $filters Filter on other fields
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @return mixed Return html part or void if noprint is 1
* @return string|void Return html part or void if noprint is 1
*/
function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC')
{
@ -1761,7 +1761,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
* @param Translate $langs Object langs
* @param DoliDB $db Database handler
* @param Societe $object Third party object
* @return void
* @return int
*/
function show_subsidiaries($conf, $langs, $db, $object)
{

View File

@ -391,7 +391,9 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t
if ($nature)
{
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/', $leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, dol_trunc($objp->label, 25), 2, $user->rights->accounting->comptarapport->lire);
$langs->load('accountancy');
$journallabel=$langs->transnoentities($objp->label); // Labels in this table are set by loading llx_accounting_abc.sql. Label can be 'ACCOUNTING_SELL_JOURNAL', 'InventoryJournal', ...
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/', $leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $journallabel, 2, $user->rights->accounting->comptarapport->lire);
}
$i++;
}

View File

@ -431,8 +431,8 @@ class modProduct extends DolibarrModules
'p.recuperableonly' => '^[0|1]$',
'p.finished' => '^[0|1]$'
);
// 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.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'),
@ -455,17 +455,17 @@ class modProduct extends DolibarrModules
'p.accountancy_code_sell' => "",
'p.accountancy_code_buy' => "",
'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.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_units',
'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.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_units',
'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.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_units',
'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.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_units',
'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.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_units',
'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.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_units',
'p.finished' => '0 (raw material) / 1 (finished goods)'
);
//clauses copied from import_fields_array

View File

@ -1,51 +0,0 @@
-- ========================================================================
-- 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

@ -1,7 +1,7 @@
-- ========================================================================
-- 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>
-- 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
@ -17,15 +17,46 @@
--
-- ========================================================================
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('P','piece','p', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('SET','set','se', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('S','second','s', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('H','hour','h', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('D','day','d', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('KG','kilogram','kg', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('G','gram','g', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M','meter','m', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('LM','linear meter','lm', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M2','square meter','m2', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('M3','cubic meter','m3', 1);
INSERT INTO llx_c_units ( code, label, short_label, active) VALUES ('L','liter','l', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('T', '3','WeightUnitton','T', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('KG', '0','WeightUnitkg','Kg', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('G', '-3','WeightUnitg','g', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MG','-6','WeightUnitmg','mg', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('OZ','98','WeightUnitounce','Oz', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('LB','99','WeightUnitpound','lb', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('M', '0','SizeUnitm','m', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM','-1','SizeUnitdm','dm', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM','-2','SizeUnitcm','cm', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM','-3','SizeUnitmm','mm', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT','98','SizeUnitfoot','ft', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN','99','SizeUnitinch','in', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('M2', '0','SurfaceUnitm2','m2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM2','-2','SurfaceUnitdm2','dm2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM2','-4','SurfaceUnitcm2','cm2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM2','-6','SurfaceUnitmm2','mm2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT2','98','SurfaceUnitfoot2','ft2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN2','99','SurfaceUnitinch2','in2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('M3', '0','VolumeUnitm3','m3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM3','-3','VolumeUnitdm3','dm3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM3','-6','VolumeUnitcm3','cm3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM3','-9','VolumeUnitmm3','mm3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT3','88','VolumeUnitfoot3','ft3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN3','89','VolumeUnitinch3','in3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('OZ3','97','VolumeUnitounce','Oz', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('L', '98','VolumeUnitlitre','L', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('P', '0','Piece','p', 'qty', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('SET', '0','Set','set', 'qty', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('S', '0','second','s', 'time', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MI', '60','minute','m', 'time', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('H', '3600','hour','h', 'time', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('D','12960000','day','d', 'time', 1);

View File

@ -96,44 +96,64 @@ ALTER TABLE llx_don ADD COLUMN fk_soc integer NULL;
ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32);
CREATE TABLE llx_c_measuring_units(
-- Fix if table exists
ALTER TABLE llx_c_units DROP INDEX uk_c_units_code;
ALTER TABLE llx_c_units ADD COLUMN scale integer;
ALTER TABLE llx_c_units ADD COLUMN unit_type varchar(10);
-- Create if table dos not exists
CREATE TABLE llx_c_units(
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(3),
scale integer,
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);
ALTER TABLE llx_c_units ADD UNIQUE uk_c_units_code(code);
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_units (code, scale, label, short_label, unit_type, active) VALUES ('T', '3','WeightUnitton','T', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('KG', '0','WeightUnitkg','Kg', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('G', '-3','WeightUnitg','g', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MG','-6','WeightUnitmg','mg', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('OZ','98','WeightUnitounce','Oz', 'weight', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('LB','99','WeightUnitpound','lb', 'weight', 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_units (code, scale, label, short_label, unit_type, active) VALUES ('M', '0','SizeUnitm','m', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM','-1','SizeUnitdm','dm', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM','-2','SizeUnitcm','cm', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM','-3','SizeUnitmm','mm', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT','98','SizeUnitfoot','ft', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN','99','SizeUnitinch','in', 'size', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('M2', '0','SurfaceUnitm2','m2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM2','-2','SurfaceUnitdm2','dm2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM2','-4','SurfaceUnitcm2','cm2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM2','-6','SurfaceUnitmm2','mm2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT2','98','SurfaceUnitfoot2','ft2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN2','99','SurfaceUnitinch2','in2', 'surface', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('M3', '0','VolumeUnitm3','m3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('DM3','-3','VolumeUnitdm3','dm3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('CM3','-6','VolumeUnitcm3','cm3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MM3','-9','VolumeUnitmm3','mm3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('FT3','88','VolumeUnitfoot3','ft3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('IN3','89','VolumeUnitinch3','in3', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('OZ3','97','VolumeUnitounce','Oz', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('L', '98','VolumeUnitlitre','L', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('GAL','99','VolumeUnitgallon','gal', 'volume', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('P', '0','Piece','p', 'qty', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('SET', '0','Set','set', 'qty', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('S', '0','second','s', 'time', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('MI', '60','minute','m', 'time', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('H', '3600','hour','h', 'time', 1);
INSERT INTO llx_c_units (code, scale, label, short_label, unit_type, active) VALUES ('D','12960000','day','d', 'time', 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

@ -1,21 +0,0 @@
-- ========================================================================
-- 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

@ -1,28 +0,0 @@
-- ========================================================================
-- 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

@ -21,7 +21,9 @@
create table llx_c_units(
rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(3),
scale integer,
label varchar(50),
short_label varchar(5),
unit_type varchar(10),
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
) ENGINE=innodb;

View File

@ -147,7 +147,7 @@ function LoadProducts(position, issubcat=false){
idata=0; //product data counter
$.getJSON('./ajax.php?action=getProducts&category='+currentcat, function(data) {
while (idata < 30) {
while (idata < 30 && ishow < 30) {
if (typeof (data[idata]) == "undefined") {
$("#prodesc"+ishow).text("");
$("#proimg"+ishow).attr("src","");
@ -186,7 +186,7 @@ function MoreProducts(moreorless){
}
idata=30*pageproducts; //product data counter
ishow=0; //product to show counter
while (idata < 30) {
while (idata < (30*pageproducts)+30) {
if (typeof (data[idata]) == "undefined") {
$("#prodesc"+ishow).text("");
$("#proimg"+ishow).attr("src","");
@ -268,7 +268,7 @@ function Search2(){
$("#prodesc"+i).text(data[parseInt(i)]['label']);
$("#proimg"+i).attr("src","genimg/?query=pro&w=55&h=50&id="+data[i]['rowid']);
$("#prodiv"+i).data("rowid",data[i]['rowid']);
$("#prodiv"+ishow).data("iscat",0);
$("#prodiv"+i).data("iscat",0);
}
});
}