Les priodes de date de services sont propages la facture quand on cre depuis un contrat
This commit is contained in:
parent
7e7c3b4f47
commit
d383897c4e
@ -240,13 +240,21 @@ if ($_POST["action"] == 'add')
|
||||
{
|
||||
$liblignefac=($contrat->lignes[$i]->desc?$contrat->lignes[$i]->desc:$contrat->lignes[$i]->libelle);
|
||||
|
||||
// Plage de dates
|
||||
$date_start=$contrat->lignes[$i]->date_debut_prevue;
|
||||
if ($contrat->lignes[$i]->date_debut_reel) $date_start=$contrat->lignes[$i]->date_debut_reel;
|
||||
$date_end=$contrat->lignes[$i]->date_fin_prevue;
|
||||
if ($contrat->lignes[$i]->date_fin_reel) $date_end=$contrat->lignes[$i]->date_fin_reel;
|
||||
|
||||
$result = $facture->addline($facid,
|
||||
addslashes($liblignefac),
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->product_id,
|
||||
$lines[$i]->remise_percent);
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -539,6 +547,33 @@ if ($_GET["action"] == 'pdf')
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Fonctions internes
|
||||
*
|
||||
**********************************************************************/
|
||||
function print_date_range($date_start,$date_end)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if ($date_start && $date_end)
|
||||
{
|
||||
print ' ('.$langs->trans("DateFromTo",dolibarr_print_date($date_start),dolibarr_print_date($date_end)).')';
|
||||
}
|
||||
if ($date_start && ! $date_end)
|
||||
{
|
||||
print ' ('.$langs->trans("DateFrom",dolibarr_print_date($date_start)).')';
|
||||
}
|
||||
if (! $date_start && $date_end)
|
||||
{
|
||||
print ' ('.$langs->trans("DateUntil",dolibarr_print_date($date_end)).')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
llxHeader('',$langs->trans("Bill"),'Facture');
|
||||
|
||||
$html = new Form($db);
|
||||
@ -939,7 +974,10 @@ if ($_GET["action"] == 'create')
|
||||
print '<td align="right">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Discount").'</td></tr>';
|
||||
|
||||
// Lignes de contrat produits prédéfinis
|
||||
$sql = "SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description,";
|
||||
$sql.= " pt.date_ouverture_prevue as date_debut_prevue, pt.date_ouverture as date_debut_reel,";
|
||||
$sql.= " pt.date_fin_validite as date_fin_prevue, pt.date_cloture as date_fin_reel,";
|
||||
$sql.= " p.label as product, p.ref, p.rowid as prodid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as pt, ".MAIN_DB_PREFIX."product as p";
|
||||
$sql.= " WHERE pt.fk_product = p.rowid AND pt.fk_contrat = ".$contrat->id;
|
||||
@ -957,6 +995,13 @@ if ($_GET["action"] == 'create')
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(""),"service")." ".$objp->ref."</a>";
|
||||
print $objp->product?' - '.$objp->product:'';
|
||||
// Plage de dates
|
||||
$date_start=$objp->date_debut_prevue;
|
||||
if ($objp->date_debut_reel) $date_start=$objp->date_debut_reel;
|
||||
$date_end=$objp->date_fin_prevue;
|
||||
if ($objp->date_fin_reel) $date_end=$objp->date_fin_reel;
|
||||
print_date_range($date_start,$date_end);
|
||||
|
||||
print "</td>\n";
|
||||
print '<td>';
|
||||
print dolibarr_trunc($objp->description,60);
|
||||
@ -974,11 +1019,13 @@ if ($_GET["action"] == 'create')
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
// Lignes de contrat non produits prédéfinis
|
||||
$sql = "SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.subprice, pt.qty, pt.remise_percent";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as pt";
|
||||
$sql .= " WHERE pt.fk_contrat = ".$contrat->id;
|
||||
$sql .= " AND (pt.fk_product = 0 or pt.fk_product is null)";
|
||||
$sql .= " ORDER BY pt.rowid ASC";
|
||||
$sql = "SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.subprice, pt.qty, pt.remise_percent,";
|
||||
$sql.= " pt.date_ouverture_prevue as date_debut_prevue, pt.date_ouverture as date_debut_reel,";
|
||||
$sql.= " pt.date_fin_validite as date_fin_prevue, pt.date_cloture as date_fin_reel";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as pt";
|
||||
$sql.= " WHERE pt.fk_contrat = ".$contrat->id;
|
||||
$sql.= " AND (pt.fk_product = 0 or pt.fk_product is null)";
|
||||
$sql.= " ORDER BY pt.rowid ASC";
|
||||
|
||||
$result=$db->query($sql);
|
||||
if ($result)
|
||||
@ -1306,36 +1353,14 @@ else
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a>';
|
||||
print ' - '.nl2br(stripslashes($objp->product));
|
||||
if ($objp->date_start && $objp->date_end)
|
||||
{
|
||||
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
|
||||
}
|
||||
if ($objp->date_start && ! $objp->date_end)
|
||||
{
|
||||
print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
|
||||
}
|
||||
if (! $objp->date_start && $objp->date_end)
|
||||
{
|
||||
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
|
||||
}
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.$objp->description:'';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>'.stripslashes(nl2br($objp->description));
|
||||
if ($objp->date_start && $objp->date_end)
|
||||
{
|
||||
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
|
||||
}
|
||||
if ($objp->date_start && ! $objp->date_end)
|
||||
{
|
||||
print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
|
||||
}
|
||||
if (! $objp->date_start && $objp->date_end)
|
||||
{
|
||||
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
|
||||
}
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print "</td>\n";
|
||||
}
|
||||
print '<td align="right">'.$objp->tva_taux.'%</td>';
|
||||
|
||||
@ -279,8 +279,10 @@ class Contrat
|
||||
/*
|
||||
* Lignes contrats liées à un produit
|
||||
*/
|
||||
$sql = "SELECT d.description, p.rowid, p.label, p.description as product_desc, p.ref,";
|
||||
$sql.= " d.price_ht, d.tva_tx, d.qty, d.remise_percent, d.subprice";
|
||||
$sql = "SELECT p.rowid, p.label, p.description as product_desc, p.ref,";
|
||||
$sql.= " d.description, d.price_ht, d.tva_tx, d.qty, d.remise_percent, d.subprice,";
|
||||
$sql.= " d.date_ouverture_prevue, d.date_ouverture,";
|
||||
$sql.= " d.date_fin_validite, d.date_cloture";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."product as p";
|
||||
$sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = p.rowid";
|
||||
$sql.= " ORDER by d.rowid ASC";
|
||||
@ -296,6 +298,7 @@ class Contrat
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$ligne = new ContratLigne();
|
||||
$ligne->id = $objp->rowid;
|
||||
$ligne->desc = stripslashes($objp->description); // Description ligne
|
||||
$ligne->libelle = stripslashes($objp->label); // Label produit
|
||||
$ligne->product_desc = stripslashes($objp->product_desc); // Description produit
|
||||
@ -306,6 +309,11 @@ class Contrat
|
||||
$ligne->remise_percent = $objp->remise_percent;
|
||||
$ligne->price = $objp->price;
|
||||
$ligne->product_id = $objp->rowid;
|
||||
|
||||
$ligne->date_debut_prevue = $objp->date_ouverture_prevue;
|
||||
$ligne->date_debut_reel = $objp->date_ouverture;
|
||||
$ligne->date_fin_prevue = $objp->date_fin_validite;
|
||||
$ligne->date_fin_reel = $objp->date_cloture;
|
||||
|
||||
$this->lignes[$i] = $ligne;
|
||||
//dolibarr_syslog("1 ".$ligne->desc);
|
||||
@ -323,9 +331,11 @@ class Contrat
|
||||
/*
|
||||
* Lignes contrat liées à aucun produit
|
||||
*/
|
||||
$sql = "SELECT d.qty, d.description, d.price_ht, d.subprice, d.tva_tx, d.rowid, d.remise_percent";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d";
|
||||
$sql .= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = 0";
|
||||
$sql = "SELECT d.qty, d.description, d.price_ht, d.subprice, d.tva_tx, d.rowid, d.remise_percent,";
|
||||
$sql.= " d.date_ouverture_prevue, d.date_ouverture,";
|
||||
$sql.= " d.date_fin_validite, d.date_cloture";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d";
|
||||
$sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = 0";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
@ -347,6 +357,11 @@ class Contrat
|
||||
$ligne->price = $objp->price;
|
||||
$ligne->product_id = 0;
|
||||
|
||||
$ligne->date_debut_prevue = $objp->date_ouverture_prevue;
|
||||
$ligne->date_debut_reel = $objp->date_ouverture;
|
||||
$ligne->date_fin_prevue = $objp->date_fin_validite;
|
||||
$ligne->date_fin_reel = $objp->date_cloture;
|
||||
|
||||
$this->lignes[$i] = $ligne;
|
||||
$i++;
|
||||
$j++;
|
||||
@ -1072,6 +1087,23 @@ class Contrat
|
||||
|
||||
class ContratLigne
|
||||
{
|
||||
var $id;
|
||||
var $desc;
|
||||
var $libelle;
|
||||
var $product_desc;
|
||||
var $qty;
|
||||
var $ref;
|
||||
var $tva_tx;
|
||||
var $subprice;
|
||||
var $remise_percent;
|
||||
var $price;
|
||||
var $product_id;
|
||||
|
||||
var $date_debut_prevue;
|
||||
var $date_debut_reel;
|
||||
var $date_fin_prevue;
|
||||
var $date_fin_reel;
|
||||
|
||||
function ContratLigne()
|
||||
{
|
||||
}
|
||||
|
||||
@ -272,6 +272,9 @@ NbOfObjects=Number of objects
|
||||
NbOfReferers=Number of referers
|
||||
Referers=Referers
|
||||
TotalQuantity=Total quantity
|
||||
DateFromTo=From %s to %s
|
||||
DateFrom=From %s
|
||||
DateUntil=Until %s
|
||||
# Countries
|
||||
CountryFR=France
|
||||
CountryBE=Belgium
|
||||
|
||||
@ -272,6 +272,9 @@ NbOfObjects=Nombre d'objets
|
||||
NbOfReferers=Nombre de références
|
||||
Referers=Référents
|
||||
TotalQuantity=Quantité totale
|
||||
DateFromTo=Du %s au %s
|
||||
DateFrom=A partir du %s
|
||||
DateUntil=Jusqu'au %s
|
||||
# Countries
|
||||
CountryFR=France
|
||||
CountryBE=Belgique
|
||||
|
||||
Loading…
Reference in New Issue
Block a user