Enables the fetching and saving of start and end dates in supplier order lines.
This commit is contained in:
parent
6ab41766c8
commit
ecd90ddbff
@ -210,7 +210,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= " l.tva_tx, l.remise_percent, l.subprice,";
|
||||
$sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,";
|
||||
$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.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$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_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;
|
||||
|
||||
$i++;
|
||||
@ -1720,9 +1724,11 @@ class CommandeFournisseur extends CommonOrder
|
||||
* @param int $info_bits Miscellaneous informations
|
||||
* @param int $type Type of line (0=product, 1=service)
|
||||
* @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
|
||||
*/
|
||||
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;
|
||||
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
|
||||
@ -1783,10 +1789,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= ",localtax1_type='".$localtax1_type."'";
|
||||
$sql.= ",localtax2_type='".$localtax2_type."'";
|
||||
$sql.= ",qty='".price2num($qty)."'";
|
||||
/*if ($date_end) { $sql.= ",date_start='$date_end'"; }
|
||||
else { $sql.=',date_start=null'; }
|
||||
if ($date_end) { $sql.= ",date_end='$date_end'"; }
|
||||
else { $sql.=',date_end=null'; }*/
|
||||
$sql.= ",date_start=".(! empty($date_start)?"'".$this->db->idate($date_start)."'":"null");
|
||||
$sql.= ",date_end=".(! empty($date_end)?"'".$this->db->idate($date_end)."'":"null");
|
||||
$sql.= ",info_bits='".$info_bits."'";
|
||||
$sql.= ",total_ht='".price2num($total_ht)."'";
|
||||
$sql.= ",total_tva='".price2num($total_tva)."'";
|
||||
@ -2007,7 +2011,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
/**
|
||||
* Classe de gestion des lignes de commande
|
||||
*/
|
||||
class CommandeFournisseurLigne
|
||||
class CommandeFournisseurLigne extends CommonOrderLine
|
||||
{
|
||||
// From llx_commandedet
|
||||
var $qty;
|
||||
@ -2028,6 +2032,8 @@ class CommandeFournisseurLigne
|
||||
var $total_ttc;
|
||||
var $info_bits;
|
||||
var $special_code;
|
||||
var $date_start;
|
||||
var $date_end;
|
||||
|
||||
// From llx_product
|
||||
var $libelle; // Label produit
|
||||
@ -2060,7 +2066,8 @@ class CommandeFournisseurLigne
|
||||
$sql.= ' cd.remise, cd.remise_percent, cd.subprice,';
|
||||
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
|
||||
$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.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
|
||||
$sql.= ' WHERE cd.rowid = '.$rowid;
|
||||
@ -2091,6 +2098,9 @@ class CommandeFournisseurLigne
|
||||
$this->product_libelle = $objp->product_libelle;
|
||||
$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);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -80,6 +80,9 @@ $extrafields = new ExtraFields($db);
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
//Date prefix
|
||||
$date_pf = '';
|
||||
|
||||
// Load object
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
@ -190,6 +193,8 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
||||
// Set if we used free entry or predefined product
|
||||
$predef='';
|
||||
$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')
|
||||
{
|
||||
$idprod=0;
|
||||
@ -275,7 +280,12 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
||||
$productsupplier->fourn_ref,
|
||||
$remise_percent,
|
||||
'HT',
|
||||
$type
|
||||
$pu_ttc,
|
||||
$type,
|
||||
'',
|
||||
'',
|
||||
$date_start,
|
||||
$date_end
|
||||
);
|
||||
}
|
||||
if ($idprod == -2 || $idprod == 0)
|
||||
@ -313,14 +323,14 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
$price_base_type = '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
|
||||
{
|
||||
$ttc = price2num($_POST['price_ttc']);
|
||||
$ht = $ttc / (1 + ($tauxtva / 100));
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,6 +402,9 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer
|
||||
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);
|
||||
$localtax2_tx=get_localtax($_POST['tva_tx'],2,$mysoc,$object->thirdparty);
|
||||
|
||||
@ -406,7 +419,10 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer
|
||||
$localtax2_tx,
|
||||
'HT',
|
||||
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['type']);
|
||||
@ -416,6 +432,8 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer
|
||||
unset($_POST['np_desc']);
|
||||
unset($_POST['pu']);
|
||||
unset($_POST['tva_tx']);
|
||||
unset($_POST['date_start']);
|
||||
unset($_POST['date_end']);
|
||||
unset($localtax1_tx);
|
||||
unset($localtax2_tx);
|
||||
if ($result >= 0)
|
||||
@ -1744,6 +1762,12 @@ elseif (! empty($object->id))
|
||||
$doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
|
||||
$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 $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user