Skip to content

Commit

Permalink
Merge pull request #1834 from Cubexed/develop
Browse files Browse the repository at this point in the history
Enables the fetching and saving of start and end dates in supplier order lines.
  • Loading branch information
eldy committed Sep 2, 2014
2 parents a87314f + 00856eb commit 229cbc2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
26 changes: 18 additions & 8 deletions htdocs/fourn/class/fournisseur.commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ function fetch($id,$ref='')
$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;
Expand Down Expand Up @@ -258,6 +259,9 @@ function fetch($id,$ref='')
$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++;
Expand Down Expand Up @@ -1721,9 +1725,11 @@ function setStatus($user,$status)
* @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");
Expand Down Expand Up @@ -1784,10 +1790,8 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocalt
$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)."'";
Expand Down Expand Up @@ -2008,7 +2012,7 @@ function getInputMethod()
/**
* Classe de gestion des lignes de commande
*/
class CommandeFournisseurLigne
class CommandeFournisseurLigne extends CommonOrderLine
{
// From llx_commandedet
var $qty;
Expand All @@ -2029,6 +2033,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
Expand Down Expand Up @@ -2061,7 +2067,8 @@ function fetch($rowid)
$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;
Expand Down Expand Up @@ -2092,6 +2099,9 @@ function fetch($rowid)
$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;
}
Expand Down
32 changes: 28 additions & 4 deletions htdocs/fourn/commande/fiche.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
// 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))
{
Expand Down Expand Up @@ -191,6 +194,8 @@
// 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;
Expand Down Expand Up @@ -276,7 +281,12 @@
$productsupplier->fourn_ref,
$remise_percent,
'HT',
$type
$pu_ttc,
$type,
'',
'',
$date_start,
$date_end
);
}
if ($idprod == -2 || $idprod == 0)
Expand Down Expand Up @@ -314,14 +324,14 @@
{
$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);
}
}

Expand Down Expand Up @@ -393,6 +403,9 @@
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);

Expand All @@ -407,7 +420,10 @@
$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']);
Expand All @@ -417,6 +433,8 @@
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)
Expand Down Expand Up @@ -1745,6 +1763,12 @@
$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);
Expand Down

0 comments on commit 229cbc2

Please sign in to comment.