2
0
forked from Wavyzz/dolibarr

Merge remote-tracking branch 'upstream/3.9' into 4.0

Conflicts:
	htdocs/fourn/class/fournisseur.commande.class.php
This commit is contained in:
Juanjo Menent
2016-09-09 16:34:02 +02:00
2 changed files with 36 additions and 45 deletions

View File

@@ -3,7 +3,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
@@ -699,7 +699,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$i=0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'price' || preg_match('/^amount/i',$value) || preg_match('/^localtax/i',$value) || $value == 'taux') {
if ($value == 'price' || preg_match('/^amount/i',$value) || $value == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
}
else if ($value == 'entity') {
@@ -747,7 +747,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$i = 0;
foreach ($listfieldmodify as $field)
{
if ($field == 'price' || preg_match('/^amount/i',$field) || preg_match('/^localtax/i',$field) || $field == 'taux') {
if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
}
else if ($field == 'entity') {
@@ -1383,23 +1383,12 @@ if ($id)
$valuetoshow = '';
$align="center";
}
else if ($fieldlist[$field]=='localtax1') {
else if ($fieldlist[$field]=='taux') {
$valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
if ($obj->localtax1 == 0)
$valuetoshow = '';
$align="right";
}
else if ($fieldlist[$field]=='localtax2') {
$valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
if ($obj->localtax2 == 0)
$valuetoshow = '';
$align="right";
}
else if (in_array($fieldlist[$field],array('taux','localtax1','localtax2')))
{
$valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
$align="right";
}
else if (in_array($fieldlist[$field],array('recuperableonly')))
{
$align="center";

View File

@@ -65,7 +65,7 @@ class CommandeFournisseur extends CommonOrder
// -> 9=Refused -> (reopen) 1=Validated
// Note: billed or not is on another field "billed"
var $statuts; // List of status
var $socid;
var $fourn_id;
var $date;
@@ -126,7 +126,7 @@ class CommandeFournisseur extends CommonOrder
var $multicurrency_total_ht;
var $multicurrency_total_tva;
var $multicurrency_total_ttc;
/**
* Constructor
*
@@ -255,7 +255,7 @@ class CommandeFournisseur extends CommonOrder
$this->multicurrency_total_ht = $obj->multicurrency_total_ht;
$this->multicurrency_total_tva = $obj->multicurrency_total_tva;
$this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
$this->extraparams = (array) json_decode($obj->extraparams, true);
$this->db->free($resql);
@@ -271,6 +271,8 @@ class CommandeFournisseur extends CommonOrder
$this->fetchObjectLinked();
$this->lines=array();
$sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description,";
$sql.= " l.qty,";
$sql.= " l.tva_tx, l.remise_percent, l.subprice,";
@@ -330,7 +332,7 @@ class CommandeFournisseur extends CommonOrder
$line->date_start = $this->db->jdate($objp->date_start);
$line->date_end = $this->db->jdate($objp->date_end);
$line->fk_unit = $objp->fk_unit;
// Multicurrency
$line->fk_multicurrency = $objp->fk_multicurrency;
$line->multicurrency_code = $objp->multicurrency_code;
@@ -338,7 +340,7 @@ class CommandeFournisseur extends CommonOrder
$line->multicurrency_total_ht = $objp->multicurrency_total_ht;
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$this->special_code = $objp->special_code;
$this->fk_parent_line = $objp->fk_parent_line;
@@ -513,7 +515,7 @@ class CommandeFournisseur extends CommonOrder
$billedtext='';
//if ($statut==5 && $this->billed == 1) $statut = 8;
if ($billed == 1) $billedtext=$langs->trans("Billed");
// List of language codes for status
$statutshort[0] = 'StatusOrderDraftShort';
$statutshort[1] = 'StatusOrderValidatedShort';
@@ -617,7 +619,7 @@ class CommandeFournisseur extends CommonOrder
* Returns the following order reference not used depending on the numbering model activated
* defined within COMMANDE_SUPPLIER_ADDON_NUMBER
*
* @param Societe $soc company object
* @param Company $soc company object
* @return string free reference for the invoice
*/
function getNextNumRef($soc)
@@ -677,7 +679,7 @@ class CommandeFournisseur extends CommonOrder
function classifyBilled(User $user)
{
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ';
if ($this->db->query($sql))
@@ -689,11 +691,11 @@ class CommandeFournisseur extends CommonOrder
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->billed=1;
$this->db->commit();
return 1;
}
@@ -706,7 +708,7 @@ class CommandeFournisseur extends CommonOrder
else
{
dol_print_error($this->db);
$this->db->rollback();
return -1;
}
@@ -1006,7 +1008,7 @@ class CommandeFournisseur extends CommonOrder
$this->statut = 3;
$this->methode_commande_id = $methode;
$this->date_commande = $this->db->idate($date);
// Call trigger
$result=$this->call_trigger('ORDER_SUPPLIER_SUBMIT',$user);
if ($result < 0) $error++;
@@ -1018,7 +1020,7 @@ class CommandeFournisseur extends CommonOrder
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
}
if (! $error)
{
$this->db->commit();
@@ -1067,7 +1069,7 @@ class CommandeFournisseur extends CommonOrder
$this->fk_multicurrency = 0;
$this->multicurrency_tx = 1;
}
// We set order into draft status
$this->brouillon = 1;
@@ -1100,7 +1102,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", '".$this->db->escape($this->note_public)."'";
$sql.= ", ".$conf->entity;
$sql.= ", ".$this->socid;
$sql.= ", ".($this->fk_project > 0 ? $this->fk_project : "null");
$sql.= ", ".($this->fk_project > 0 ? $this->fk_project : "null");
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
$sql.= ", ".$user->id;
@@ -1416,7 +1418,7 @@ class CommandeFournisseur extends CommonOrder
$multicurrency_total_ht = $tabprice[16];
$multicurrency_total_tva = $tabprice[17];
$multicurrency_total_ttc = $tabprice[18];
$localtax1_type=$localtaxes_type[0];
$localtax2_type=$localtaxes_type[2];
@@ -1944,7 +1946,7 @@ class CommandeFournisseur extends CommonOrder
$result=$this->call_trigger('ORDER_SUPPLIER_RECEIVE',$user);
if ($result < 0) $error++;
// End call triggers
if (! $error)
{
$this->db->commit();
@@ -2198,7 +2200,7 @@ class CommandeFournisseur extends CommonOrder
$multicurrency_total_ht = $tabprice[16];
$multicurrency_total_tva = $tabprice[17];
$multicurrency_total_ttc = $tabprice[18];
$localtax1_type=$localtaxes_type[0];
$localtax2_type=$localtaxes_type[2];
@@ -2226,13 +2228,13 @@ class CommandeFournisseur extends CommonOrder
$sql.= ",total_ttc='".price2num($total_ttc)."'";
$sql.= ",product_type=".$type;
$sql.= ($fk_unit ? ",fk_unit='".$this->db->escape($fk_unit)."'":", fk_unit=null");
// Multicurrency
$sql.= " , multicurrency_subprice=".price2num($subprice * $this->multicurrency_tx)."";
$sql.= " , multicurrency_total_ht=".price2num($multicurrency_total_ht)."";
$sql.= " , multicurrency_total_tva=".price2num($multicurrency_total_tva)."";
$sql.= " , multicurrency_total_ttc=".price2num($multicurrency_total_ttc)."";
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
@@ -2401,7 +2403,7 @@ class CommandeFournisseur extends CommonOrder
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author) $this->user_creation_id = $obj->fk_user_author;
if ($obj->fk_user_author) $this->user_creation_id = $obj->fk_user_author;
if ($obj->fk_user_valid) $this->user_validation_id = $obj->fk_user_valid;
if ($obj->fk_user_modif) $this->user_modification_id =$obj->fk_user_modif;
if ($obj->fk_user_approve) $this->user_approve_id = $obj->fk_user_approve;
@@ -2420,7 +2422,7 @@ class CommandeFournisseur extends CommonOrder
dol_print_error($this->db);
}
}
/**
* Charge indicateurs this->nb de tableau de bord
*
@@ -2656,15 +2658,15 @@ class CommandeFournisseur extends CommonOrder
public function hasDelay()
{
global $conf;
if (empty($this->date_delivery) && ! empty($this->date_livraison)) $this->date_delivery = $this->date_livraison; // For backward compatibility
$now = dol_now();
$date_to_test = empty($this->date_delivery) ? $this->date_commande : $this->date_delivery;
return ($this->statut > 0 && $this->statut < 4) && $date_to_test && $date_to_test < ($now - $conf->commande->fournisseur->warning_delay);
}
/**
* Show the customer delayed info
*
@@ -2673,15 +2675,15 @@ class CommandeFournisseur extends CommonOrder
public function showDelay()
{
global $conf, $langs;
if (empty($this->date_delivery) && ! empty($this->date_livraison)) $this->date_delivery = $this->date_livraison; // For backward compatibility
if (empty($this->date_delivery)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day');
else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_delivery, 'day');
$text.=' '.($conf->commande->fournisseur->warning_delay>0?'+':'-').' '.round(abs($conf->commande->fournisseur->warning_delay)/3600/24,1).' '.$langs->trans("days").' < '.$langs->trans("Today");
return $text;
}
}
}