Merge pull request #1834 from Cubexed/develop
Enables the fetching and saving of start and end dates in supplier order lines.
This commit is contained in:
commit
229cbc2342
@ -210,7 +210,8 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
$sql.= " l.tva_tx, l.remise_percent, l.subprice,";
|
$sql.= " l.tva_tx, l.remise_percent, l.subprice,";
|
||||||
$sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,";
|
$sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,";
|
||||||
$sql.= " l.total_ht, l.total_tva, l.total_ttc,";
|
$sql.= " l.total_ht, l.total_tva, l.total_ttc,";
|
||||||
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc";
|
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,";
|
||||||
|
$sql.= " l.date_start, l.date_end";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||||
$sql.= " WHERE l.fk_commande = ".$this->id;
|
$sql.= " WHERE l.fk_commande = ".$this->id;
|
||||||
@ -258,6 +259,9 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
$line->ref_fourn = $objp->ref_supplier; // TODO deprecated
|
$line->ref_fourn = $objp->ref_supplier; // TODO deprecated
|
||||||
$line->ref_supplier = $objp->ref_supplier; // Reference supplier
|
$line->ref_supplier = $objp->ref_supplier; // Reference supplier
|
||||||
|
|
||||||
|
$line->date_start = $this->db->jdate($objp->date_start);
|
||||||
|
$line->date_end = $this->db->jdate($objp->date_end);
|
||||||
|
|
||||||
$this->lines[$i] = $line;
|
$this->lines[$i] = $line;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -1721,9 +1725,11 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
* @param int $info_bits Miscellaneous informations
|
* @param int $info_bits Miscellaneous informations
|
||||||
* @param int $type Type of line (0=product, 1=service)
|
* @param int $type Type of line (0=product, 1=service)
|
||||||
* @param int $notrigger Disable triggers
|
* @param int $notrigger Disable triggers
|
||||||
|
* @param timestamp $date_start Date start of service
|
||||||
|
* @param timestamp $date_end Date end of service
|
||||||
* @return int < 0 if error, > 0 if ok
|
* @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)
|
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='')
|
||||||
{
|
{
|
||||||
global $mysoc;
|
global $mysoc;
|
||||||
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
|
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
|
||||||
@ -1784,10 +1790,8 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
$sql.= ",localtax1_type='".$localtax1_type."'";
|
$sql.= ",localtax1_type='".$localtax1_type."'";
|
||||||
$sql.= ",localtax2_type='".$localtax2_type."'";
|
$sql.= ",localtax2_type='".$localtax2_type."'";
|
||||||
$sql.= ",qty='".price2num($qty)."'";
|
$sql.= ",qty='".price2num($qty)."'";
|
||||||
/*if ($date_end) { $sql.= ",date_start='$date_end'"; }
|
$sql.= ",date_start=".(! empty($date_start)?"'".$this->db->idate($date_start)."'":"null");
|
||||||
else { $sql.=',date_start=null'; }
|
$sql.= ",date_end=".(! empty($date_end)?"'".$this->db->idate($date_end)."'":"null");
|
||||||
if ($date_end) { $sql.= ",date_end='$date_end'"; }
|
|
||||||
else { $sql.=',date_end=null'; }*/
|
|
||||||
$sql.= ",info_bits='".$info_bits."'";
|
$sql.= ",info_bits='".$info_bits."'";
|
||||||
$sql.= ",total_ht='".price2num($total_ht)."'";
|
$sql.= ",total_ht='".price2num($total_ht)."'";
|
||||||
$sql.= ",total_tva='".price2num($total_tva)."'";
|
$sql.= ",total_tva='".price2num($total_tva)."'";
|
||||||
@ -2008,7 +2012,7 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
/**
|
/**
|
||||||
* Classe de gestion des lignes de commande
|
* Classe de gestion des lignes de commande
|
||||||
*/
|
*/
|
||||||
class CommandeFournisseurLigne
|
class CommandeFournisseurLigne extends CommonOrderLine
|
||||||
{
|
{
|
||||||
// From llx_commandedet
|
// From llx_commandedet
|
||||||
var $qty;
|
var $qty;
|
||||||
@ -2029,6 +2033,8 @@ class CommandeFournisseurLigne
|
|||||||
var $total_ttc;
|
var $total_ttc;
|
||||||
var $info_bits;
|
var $info_bits;
|
||||||
var $special_code;
|
var $special_code;
|
||||||
|
var $date_start;
|
||||||
|
var $date_end;
|
||||||
|
|
||||||
// From llx_product
|
// From llx_product
|
||||||
var $libelle; // Label produit
|
var $libelle; // Label produit
|
||||||
@ -2061,7 +2067,8 @@ class CommandeFournisseurLigne
|
|||||||
$sql.= ' cd.remise, cd.remise_percent, cd.subprice,';
|
$sql.= ' cd.remise, cd.remise_percent, cd.subprice,';
|
||||||
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
|
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
|
||||||
$sql.= ' cd.total_localtax1, cd.total_localtax2,';
|
$sql.= ' cd.total_localtax1, cd.total_localtax2,';
|
||||||
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
|
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
|
||||||
|
$sql.= ' cd.date_start, cd.date_end';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
|
||||||
$sql.= ' WHERE cd.rowid = '.$rowid;
|
$sql.= ' WHERE cd.rowid = '.$rowid;
|
||||||
@ -2092,6 +2099,9 @@ class CommandeFournisseurLigne
|
|||||||
$this->product_libelle = $objp->product_libelle;
|
$this->product_libelle = $objp->product_libelle;
|
||||||
$this->product_desc = $objp->product_desc;
|
$this->product_desc = $objp->product_desc;
|
||||||
|
|
||||||
|
$this->date_start = $this->db->jdate($objp->date_start);
|
||||||
|
$this->date_end = $this->db->jdate($objp->date_end);
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,9 @@ $extrafields = new ExtraFields($db);
|
|||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
|
//Date prefix
|
||||||
|
$date_pf = '';
|
||||||
|
|
||||||
// Load object
|
// Load object
|
||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
@ -191,6 +194,8 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
|||||||
// Set if we used free entry or predefined product
|
// Set if we used free entry or predefined product
|
||||||
$predef='';
|
$predef='';
|
||||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||||
|
$date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year'));
|
||||||
|
$date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year'));
|
||||||
if (GETPOST('prod_entry_mode') == 'free')
|
if (GETPOST('prod_entry_mode') == 'free')
|
||||||
{
|
{
|
||||||
$idprod=0;
|
$idprod=0;
|
||||||
@ -276,7 +281,12 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
|||||||
$productsupplier->fourn_ref,
|
$productsupplier->fourn_ref,
|
||||||
$remise_percent,
|
$remise_percent,
|
||||||
'HT',
|
'HT',
|
||||||
$type
|
$pu_ttc,
|
||||||
|
$type,
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
$date_start,
|
||||||
|
$date_end
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($idprod == -2 || $idprod == 0)
|
if ($idprod == -2 || $idprod == 0)
|
||||||
@ -314,14 +324,14 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
|||||||
{
|
{
|
||||||
$price_base_type = 'HT';
|
$price_base_type = 'HT';
|
||||||
$ht = price2num($_POST['price_ht']);
|
$ht = price2num($_POST['price_ht']);
|
||||||
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type);
|
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$ttc = price2num($_POST['price_ttc']);
|
$ttc = price2num($_POST['price_ttc']);
|
||||||
$ht = $ttc / (1 + ($tauxtva / 100));
|
$ht = $ttc / (1 + ($tauxtva / 100));
|
||||||
$price_base_type = 'HT';
|
$price_base_type = 'HT';
|
||||||
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type);
|
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,6 +403,9 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer
|
|||||||
if (!$res) dol_print_error($db);
|
if (!$res) dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year'));
|
||||||
|
$date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year'));
|
||||||
|
|
||||||
$localtax1_tx=get_localtax($_POST['tva_tx'],1,$mysoc,$object->thirdparty);
|
$localtax1_tx=get_localtax($_POST['tva_tx'],1,$mysoc,$object->thirdparty);
|
||||||
$localtax2_tx=get_localtax($_POST['tva_tx'],2,$mysoc,$object->thirdparty);
|
$localtax2_tx=get_localtax($_POST['tva_tx'],2,$mysoc,$object->thirdparty);
|
||||||
|
|
||||||
@ -407,7 +420,10 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer
|
|||||||
$localtax2_tx,
|
$localtax2_tx,
|
||||||
'HT',
|
'HT',
|
||||||
0,
|
0,
|
||||||
isset($_POST["type"])?$_POST["type"]:$line->product_type
|
isset($_POST["type"])?$_POST["type"]:$line->product_type,
|
||||||
|
false,
|
||||||
|
$date_start,
|
||||||
|
$date_end
|
||||||
);
|
);
|
||||||
unset($_POST['qty']);
|
unset($_POST['qty']);
|
||||||
unset($_POST['type']);
|
unset($_POST['type']);
|
||||||
@ -417,6 +433,8 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer
|
|||||||
unset($_POST['np_desc']);
|
unset($_POST['np_desc']);
|
||||||
unset($_POST['pu']);
|
unset($_POST['pu']);
|
||||||
unset($_POST['tva_tx']);
|
unset($_POST['tva_tx']);
|
||||||
|
unset($_POST['date_start']);
|
||||||
|
unset($_POST['date_end']);
|
||||||
unset($localtax1_tx);
|
unset($localtax1_tx);
|
||||||
unset($localtax2_tx);
|
unset($localtax2_tx);
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
@ -1745,6 +1763,12 @@ elseif (! empty($object->id))
|
|||||||
$doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
|
$doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
|
||||||
$doleditor->Create();
|
$doleditor->Create();
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
|
||||||
|
print $form->select_date($date_start,'date_start'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'');
|
||||||
|
print ' '.$langs->trans('to').' ';
|
||||||
|
print $form->select_date($date_end,'date_end'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'');
|
||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc);
|
print $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user