First clean of code after devcamp

This commit is contained in:
Laurent Destailleur 2015-04-21 15:49:58 +02:00
parent 1c8e1638c7
commit 96a33bbe8a
25 changed files with 100 additions and 136 deletions

View File

@ -128,9 +128,9 @@ script:
- php upgrade.php 3.6.0 3.7.0 ignoredbversion > upgrade360370.log
- php upgrade2.php 3.6.0 3.7.0 ignoredbversion > upgrade360370-2.log
- php upgrade.php 3.7.0 3.8.0 ignoredbversion > upgrade370380.log
- cat upgrade370380.log
# - cat upgrade370380.log
- php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log
- cat upgrade370380-2.log
# - cat upgrade370380-2.log
- cd ../..
- date
- phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php

View File

@ -846,11 +846,7 @@ if (empty($reshook))
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit = GETPOST('units', 'int');
if ($fk_unit <= 0) {
$fk_unit = null;
}
$fk_unit = GETPOST('units', 'alpha');
}
// Margin

View File

@ -399,12 +399,12 @@ class Propal extends CommonObject
* @param int $date_start Start date of the line
* @param int $date_end End date of the line
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int >0 if OK, <0 if KO
*
* @see add_product
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit = null)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null)
{
global $mysoc;
@ -583,10 +583,10 @@ class Propal extends CommonObject
* @param int $date_start Start date of the line
* @param int $date_end End date of the line
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int 0 if OK, <0 if KO
*/
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit=null)
{
global $mysoc;
@ -1923,7 +1923,7 @@ class Propal extends CommonObject
if ( ! $error )
{
$this->statut = $statut;
$this->db->commit();
return 1;
}

View File

@ -723,11 +723,7 @@ if (empty($reshook))
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit=GETPOST('units', 'int');
if ($fk_unit <= 0) {
$fk_unit = null;
}
$fk_unit=GETPOST('units', 'alpha');
}
// Margin

View File

@ -1169,7 +1169,7 @@ class Commande extends CommonOrder
* @param int $pa_ht Buying price (without tax)
* @param string $label Label
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int >0 if OK, <0 if KO
*
* @see add_product
@ -1179,7 +1179,7 @@ class Commande extends CommonOrder
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit = null)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null)
{
global $mysoc, $conf, $langs;
@ -2429,10 +2429,10 @@ class Commande extends CommonOrder
* @param string $label Label
* @param int $special_code Special code (also used by externals modules!)
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit = null)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null)
{
global $conf, $mysoc;

View File

@ -1376,11 +1376,7 @@ if (empty($reshook))
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit= GETPOST('units', 'int');
if ($fk_unit <= 0) {
$fk_unit = null;
}
$fk_unit= GETPOST('units', 'alpha');
}
// Margin

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
@ -98,7 +98,7 @@ class FactureRec extends Facture
// Clean parameters
$this->titre=trim($this->titre);
$this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice;
$this->db->begin();
// Charge facture modele
@ -415,9 +415,10 @@ class FactureRec extends Facture
* @param int $rang Position of line
* @param int $special_code Special code
* @param string $label Label of the line
* @param string $fk_unit Unit
* @return int <0 if KO, Id of line if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit= null)
function addline($desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $label='', $fk_unit=null)
{
$facid=$this->id;
@ -499,7 +500,7 @@ class FactureRec extends Facture
$sql.= ", '".price2num($total_ttc)."'";
$sql.= ", ".$rang;
$sql.= ", ".$special_code;
$sql.= ", ".$fk_unit.")";
$sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null").")";
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
if ($this->db->query($sql))
@ -579,7 +580,7 @@ class FactureRec extends Facture
return $result;
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.

View File

@ -2100,7 +2100,7 @@ class Facture extends CommonInvoice
* @param array $array_options extrafields array
* @param int $situation_percent Situation advance percentage
* @param int $fk_prev_id Previous situation line id reference
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <0 if KO, Id of line if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=self::TYPE_STANDARD, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='', $array_options=0, $situation_percent=100, $fk_prev_id='', $fk_unit = null)
@ -2283,8 +2283,8 @@ class Facture extends CommonInvoice
* @param string $label Label of the line (deprecated, do not use)
* @param int $special_code Special code (also used by externals modules!)
* @param array $array_options extrafields array
* @param int $situation_percent Situation advance percentage
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param int $situation_percent Situation advance percentage
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null)

View File

@ -306,7 +306,7 @@ if ($action == 'create')
print '<td align="center">'.$objp->qty.'</td>';
if ($conf->global->PRODUCT_USE_UNITS) {
print '<td align="left">'.$product_static->get_unit_label().'</td>';
print '<td align="left">'.$product_static->getLabelOfUnit().'</td>';
}
// Percent
@ -528,7 +528,7 @@ else
print '<td align="center">'.$object->lines[$i]->remise_percent.' %</td>';
print '<td align="center">'.$object->lines[$i]->qty.'</td>';
if ($conf->global->PRODUCT_USE_UNITS) {
print "<td align=\"left\">".$object->lines[$i]->get_unit_label()."</td>";
print "<td align=\"left\">".$object->lines[$i]->getLabelOfUnit()."</td>";
}
print "</tr>\n";
$i++;

View File

@ -505,11 +505,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
$tva_tx=GETPOST('tva_tx')?str_replace('*','',GETPOST('tva_tx')):0; // tva_tx field may be disabled, so we use vat rate 0
$tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0;
$desc=$product_desc;
$fk_unit= GETPOST('units', 'int');
if ($fk_unit <= 0) {
$fk_unit = null;
}
$fk_unit= GETPOST('units', 'alpha');
}
$localtax1_tx=get_localtax($tva_tx,1,$object->thirdparty);
@ -631,7 +627,7 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
else
$pa_ht = null;
$fk_unit = GETPOST('unit', 'int');
$fk_unit = GETPOST('unit', 'alpha');
$objectline->description=GETPOST('product_desc');
$objectline->price_ht=GETPOST('elprice');
@ -650,7 +646,7 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST(
$objectline->pa_ht=$pa_ht;
if ($fk_unit > 0) {
$objectline->fk_unit = $_POST['unit'];
$objectline->fk_unit = GETPOST('unit');
} else {
$objectline->fk_unit = null;
}
@ -977,7 +973,7 @@ if ($action == 'create')
print '<input type="hidden" name="remise_percent" value="0">';
dol_fiche_head();
print '<table class="border" width="100%">';
// Ref
@ -1087,7 +1083,7 @@ if ($action == 'create')
print '<br>'.$langs->trans("Note").': '.$langs->trans("OnlyLinesWithTypeServiceAreUsed");
}
}
print "</form>\n";
}
else
@ -1291,7 +1287,7 @@ else
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
$var=false;
// Title line for service
$cursorline=1;
while ($cursorline <= $nbofservices)
@ -1327,7 +1323,7 @@ else
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>';
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>';
if($conf->global->PRODUCT_USE_UNITS) print '<td width="30" align="left">'.$langs->trans("Unit").'</td>';
if ($conf->global->PRODUCT_USE_UNITS) print '<td width="30" align="left">'.$langs->trans("Unit").'</td>';
print '<td width="50" align="right">'.$langs->trans("ReductionShort").'</td>';
if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) print '<td width="50" align="right">'.$langs->trans("BuyingPrice").'</td>';
print '<td width="30">&nbsp;</td>';
@ -1368,8 +1364,8 @@ else
print '<td align="right">'.($objp->subprice != '' ? price($objp->subprice) : '')."</td>\n";
// Quantite
print '<td align="center">'.$objp->qty.'</td>';
//Unit
if($conf->global->PRODUCT_USE_UNITS) print '<td align="left">'.$langs->trans($object->lines[$cursorline-1]->get_unit_label()).'</td>';
// Unit
if($conf->global->PRODUCT_USE_UNITS) print '<td align="left">'.$langs->trans($object->lines[$cursorline-1]->getLabelOfUnit()).'</td>';
// Remise
if ($objp->remise_percent > 0)
{
@ -1494,12 +1490,12 @@ else
print '</td>';
print '<td align="right"><input size="5" type="text" name="elprice" value="'.price($objp->subprice).'"></td>';
print '<td align="center"><input size="2" type="text" name="elqty" value="'.$objp->qty.'"></td>';
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">';
$form->select_units($objp->fk_unit, "unit");
print '</td>';
}
if ($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">';
print $form->selectUnits($objp->fk_unit, "unit");
print '</td>';
}
print '<td align="right" class="nowrap"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
if (! empty($usemargins))
{

View File

@ -1236,7 +1236,7 @@ class Contrat extends CommonObject
* @param int $fk_fournprice Fourn price id
* @param int $pa_ht Buying price HT
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <0 si erreur, >0 si ok
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0, $fk_unit = null)
@ -1339,7 +1339,7 @@ class Contrat extends CommonObject
else $sql.= ' null';
if ($date_start > 0) { $sql.= ",'".$this->db->idate($date_start)."'"; }
if ($date_end > 0) { $sql.= ",'".$this->db->idate($date_end)."'"; }
$sql.= ", ".$fk_unit;
$sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null");
$sql.= ")";
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
@ -1418,7 +1418,7 @@ class Contrat extends CommonObject
* @param int $fk_fournprice Fourn price id
* @param int $pa_ht Buying price HT
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 si erreur, > 0 si ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx=0.0, $localtax2tx=0.0, $date_debut_reel='', $date_fin_reel='', $price_base_type='HT', $info_bits=0, $fk_fournprice=null, $pa_ht = 0,$array_options=0, $fk_unit = null)
@ -1512,7 +1512,7 @@ class Contrat extends CommonObject
else { $sql.=",date_ouverture=null"; }
if ($date_fin_reel > 0) { $sql.= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; }
else { $sql.=",date_cloture=null"; }
$sql .= ", fk_unit=".$fk_unit;
$sql .= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null");
$sql .= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
@ -2474,7 +2474,7 @@ class ContratLigne extends CommonObjectLine
if (empty($this->total_ht)) $this->total_ht = 0;
if (empty($this->total_tva)) $this->total_tva = 0;
if (empty($this->total_ttc)) $this->total_ttc = 0;
// Check parameters
// Put here code to add control on parameters values

View File

@ -3063,7 +3063,7 @@ abstract class CommonObject
$this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
$this->tpl['price'] = price($line->subprice);
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : '&nbsp;';
if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->get_unit_label('long');
if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long');
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;';
// Output template part (modules that overwrite templates must declare this into descriptor)

View File

@ -38,7 +38,7 @@ abstract class CommonObjectLine extends CommonObject
/**
* Id of the line
* @var int
* @deprecated Try to use id property as possible
* @deprecated Try to use id property as possible (even if field into database is still rowid)
*/
public $rowid;
@ -46,11 +46,11 @@ abstract class CommonObjectLine extends CommonObject
public $db;
/**
* Product/service unit
* @var int
* Product/service unit code ('km', 'm', 'p', ...)
* @var string
*/
public $fk_unit;
// TODO
/**
* Returns the text label from units dictionnary
@ -58,7 +58,7 @@ abstract class CommonObjectLine extends CommonObject
* @param string $type Label type (long or short)
* @return string|int <0 if ko, label if ok
*/
public function get_unit_label($type='long')
public function getLabelOfUnit($type='long')
{
global $langs;
@ -89,7 +89,7 @@ abstract class CommonObjectLine extends CommonObject
else
{
$this->error=$this->db->error().' sql='.$sql;
dol_syslog(get_class($this)."::get_unit_label Error ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
return -1;
}
}

View File

@ -2823,46 +2823,36 @@ class Form
}
/**
* Prints units selector
* Creates HTML units selector (code => label)
*
* @param string $selected Preselected ID
* @param string $htmlname Select name
* @return void
* @param string $selected Preselected code ('km', 'm', 'l', 'p', ...)
* @param string $htmlname Select name
* @param int $showempty Add a nempty line
* @return string HTML select
*/
function select_units($selected = '', $htmlname = 'units')
{
print $this->load_units($selected, $htmlname);
}
/**
* Creates HTML units selector
*
* @param string $selected Preselected ID
* @param string $htmlname Select name
* @return string HTML select
*/
function load_units($selected = '', $htmlname = 'units')
function selectUnits($selected = '', $htmlname = 'units', $showempty=0)
{
global $langs;
$langs->load('products');
$return= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
$sql = 'select rowid, label from '.MAIN_DB_PREFIX.'c_units where active=1';
$resql = $this->db->query($sql);
if($resql && $this->db->num_rows($resql) > 0)
{
$return .= '<option value=""></option>';
if ($showempty) $return .= '<option value="none"></option>';
while($res = $this->db->fetch_array($resql))
while($res = $this->db->fetch_object($resql))
{
if ($selected == $res[0])
{
$return.='<option value="'.$res[0].'" selected="selected">'.$langs->trans($res[1]).'</option>';
$return.='<option value="'.$res->code.'" selected="selected">'.$langs->trans($res->label).'</option>';
}
else
{
$return.='<option value="'.$res[0].'">'.$langs->trans($res[1]).'</option>';
$return.='<option value="'.$res->code.'">'.$langs->trans($res->label).'</option>';
}
}
$return.='</select>';
@ -3009,7 +2999,7 @@ class Form
$add = '';
}
$output.= '<option '.$add.'value="'.$cate_arbo[$key]['id'].'">'.dol_trunc($cate_arbo[$key]['fulllabel'],$maxlength,'middle').'</option>';
$outarray[$cate_arbo[$key]['id']] = $cate_arbo[$key]['fulllabel'];
}
}

View File

@ -1463,7 +1463,7 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag
$action); // Note that $action and $object may have been modified by some hooks
} else {
if (empty($hidedetails) || $hidedetails > 1) {
return $langs->transnoentitiesnoconv($object->lines[$i]->get_unit_label('short'));
return $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
}
}
}

View File

@ -233,7 +233,7 @@ else {
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">';
print $form->select_units($line->fk_unit, "units");
print $form->selectUnits($line->fk_unit, "units");
print '</td>';
}
?>

View File

@ -147,7 +147,7 @@ $coldisplay=-1; // We remove first td
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left">';
$form->select_units($line->fk_unit, "units");
print $form->selectUnits($line->fk_unit, "units");
print '</td>';
}
?>

View File

@ -149,7 +149,7 @@ if (empty($usemargins)) $usemargins=0;
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td align="left" nowrap="nowrap">';
$label = $line->get_unit_label('short');
$label = $line->getLabelOfUnit('short');
if ($label !== '') {
print $langs->trans($label);
}

View File

@ -1198,10 +1198,10 @@ class CommandeFournisseur extends CommonOrder
* @param int $date_start Date start of service
* @param int $date_end Date end of service
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <=0 if KO, >0 if OK
*/
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit = null)
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null)
{
global $langs,$mysoc;
@ -1327,7 +1327,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= "'".price2num($total_localtax1)."',";
$sql.= "'".price2num($total_localtax2)."',";
$sql.= "'".price2num($total_ttc)."',";
$sql.= (!$fk_unit ? 'NULL' : $fk_unit);
$sql.= ($fk_unit ? "'".$this->db->escape($fk_unit)."'":"null");
$sql.= ")";
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
@ -1992,11 +1992,11 @@ class CommandeFournisseur extends CommonOrder
* @param int $notrigger Disable triggers
* @param timestamp $date_start Date start of service
* @param timestamp $date_end Date end of service
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param array $array_options Extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 if error, > 0 if ok
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit=null)
{
global $mysoc;
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit");
@ -2066,7 +2066,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ",total_localtax2='".price2num($total_localtax2)."'";
$sql.= ",total_ttc='".price2num($total_ttc)."'";
$sql.= ",product_type=".$type;
$sql.= ",fk_unit=".(!$fk_unit ? 'NULL' : $fk_unit);
$sql.= ($fk_unit ? "'".$this->db->escape($fk_unit)."'":"null");
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);

View File

@ -1118,12 +1118,12 @@ class FactureFournisseur extends CommonInvoice
* @param int $rang Position of line
* @param int $notrigger Disable triggers
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int >0 if OK, <0 if KO
*
* FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order.
*/
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit = null)
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null)
{
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -1215,7 +1215,7 @@ class FactureFournisseur extends CommonInvoice
* @param timestamp $date_start Date start of service
* @param timestamp $date_end Date end of service
* @param array $array_options extrafields array
* @param int $fk_unit Id of the unit to use. Null to use the default one
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int <0 if KO, >0 if OK
*/
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
@ -1291,7 +1291,7 @@ class FactureFournisseur extends CommonInvoice
else $sql.= ", fk_product = null";
$sql.= ", product_type = ".$product_type;
$sql.= ", info_bits = ".$info_bits;
$sql .= ", fk_unit=".(!$fk_unit ? 'NULL' : $fk_unit);
$sql.= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'":"null");
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);

View File

@ -376,11 +376,7 @@ if (empty($reshook))
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit= GETPOST('units', 'int');
if ($fk_unit <= 0) {
$fk_unit = null;
}
$fk_unit= GETPOST('units', 'alpha');
$tva_tx = price2num($tva_tx); // When vat is text input field

View File

@ -732,11 +732,7 @@ if (empty($reshook))
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit= GETPOST('units', 'int');
if ($fk_unit <= 0) {
$fk_unit = null;
}
$fk_unit= GETPOST('units', 'alpha');
$tva_tx = price2num($tva_tx); // When vat is text input field

View File

@ -1,6 +1,6 @@
-- ========================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
-- 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

View File

@ -225,14 +225,14 @@ if (empty($reshook))
$object->barcode_type_label = $stdobject->barcode_type_label;
$object->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url');
$object->url = GETPOST('url');
$object->note = dol_htmlcleanlastbr(GETPOST('note'));
$object->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id');
$object->customcode = GETPOST('customcode');
$object->country_id = GETPOST('country_id');
$object->duration_value = GETPOST('duration_value');
$object->duration_unit = GETPOST('duration_unit');
$object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0;
$object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0;
$object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0;
$object->canvas = GETPOST('canvas');
$object->weight = GETPOST('weight');
$object->weight_units = GETPOST('weight_units');
@ -245,9 +245,6 @@ if (empty($reshook))
$object->finished = GETPOST('finished');
$object->hidden = GETPOST('hidden')=='yes'?1:0;
$object->fk_unit = GETPOST('units');
if ($fk_unit > 0) {
$object->fk_unit = $fk_unit;
}
$object->accountancy_code_sell = GETPOST('accountancy_code_sell');
$object->accountancy_code_buy = GETPOST('accountancy_code_buy');
@ -288,7 +285,7 @@ if (empty($reshook))
$cat->add_type($object, 'product');
}
}
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
@ -380,18 +377,18 @@ if (empty($reshook))
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product";
$sql .= " WHERE fk_product = ".$object->id;
$db->query($sql);
// Then we add the associated categories
$categories = GETPOST('categories');
if(!empty($categories)) {
$cat = new Categorie($db);
foreach($categories as $id_category) {
$cat->fetch($id_category);
$cat->add_type($object, 'product');
}
}
$action = 'view';
}
else
@ -1095,7 +1092,7 @@ else
{
print '<tr><td>'.$langs->trans('Unit').'</td>';
print '<td colspan="3">';
$form->select_units("units");
print $form->selectUnits("units");
print '</td></tr>';
}
@ -1379,13 +1376,13 @@ else
}
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, 250);
print "</td></tr>";
// Units
if($conf->global->PRODUCT_USE_UNITS)
{
print '<tr><td>'.$langs->trans('Unit').'</td>';
print '<td colspan="3">';
$form->select_units($object->fk_unit);
print $form->selectUnits($object->fk_unit);
print '</td></tr>';
}
@ -1659,7 +1656,7 @@ else
// Unit
if($conf->global->PRODUCT_USE_UNITS)
{
$unit = $object->get_unit_label();
$unit = $object->getLabelOfUnit();
print '<tr><td>'.$langs->trans('Unit').'</td><td>';
if ($unit !== '') {
@ -1695,7 +1692,7 @@ else
$cat = new Categorie($db);
$categories = $cat->containing($object->id,0);
$catarray = $form->select_all_categories(0, '', 'parent', 64, 0, 1);
$toprint = array();
foreach($categories as $c) {
$toprint[] = $catarray[$c->id];

View File

@ -177,8 +177,8 @@ class Product extends CommonObject
var $fk_price_expression;
/**
* Unit
* @var int
* Unit code ('km', 'm', 'l', 'p', ...)
* @var string
*/
public $fk_unit;
@ -3820,7 +3820,7 @@ class Product extends CommonObject
* @param string $type Label type (long or short)
* @return string|int <0 if ko, label if ok
*/
function get_unit_label($type='long')
function getLabelOfUnit($type='long')
{
global $langs;
@ -3851,7 +3851,7 @@ class Product extends CommonObject
else
{
$this->error=$this->db->error().' sql='.$sql;
dol_syslog(get_class($this)."::get_unit_label Error ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR);
return -1;
}
}