240 |
{ |
{ |
241 |
$liblignefac=($contrat->lignes[$i]->desc?$contrat->lignes[$i]->desc:$contrat->lignes[$i]->libelle); |
$liblignefac=($contrat->lignes[$i]->desc?$contrat->lignes[$i]->desc:$contrat->lignes[$i]->libelle); |
242 |
|
|
243 |
|
// Plage de dates |
244 |
|
$date_start=$contrat->lignes[$i]->date_debut_prevue; |
245 |
|
if ($contrat->lignes[$i]->date_debut_reel) $date_start=$contrat->lignes[$i]->date_debut_reel; |
246 |
|
$date_end=$contrat->lignes[$i]->date_fin_prevue; |
247 |
|
if ($contrat->lignes[$i]->date_fin_reel) $date_end=$contrat->lignes[$i]->date_fin_reel; |
248 |
|
|
249 |
$result = $facture->addline($facid, |
$result = $facture->addline($facid, |
250 |
addslashes($liblignefac), |
addslashes($liblignefac), |
251 |
$lines[$i]->subprice, |
$lines[$i]->subprice, |
252 |
$lines[$i]->qty, |
$lines[$i]->qty, |
253 |
$lines[$i]->tva_tx, |
$lines[$i]->tva_tx, |
254 |
$lines[$i]->product_id, |
$lines[$i]->product_id, |
255 |
$lines[$i]->remise_percent); |
$lines[$i]->remise_percent, |
256 |
|
$date_start, |
257 |
|
$date_end); |
258 |
} |
} |
259 |
} |
} |
260 |
else |
else |
547 |
} |
} |
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
/********************************************************************* |
553 |
|
* |
554 |
|
* Fonctions internes |
555 |
|
* |
556 |
|
**********************************************************************/ |
557 |
|
function print_date_range($date_start,$date_end) |
558 |
|
{ |
559 |
|
global $langs; |
560 |
|
|
561 |
|
if ($date_start && $date_end) |
562 |
|
{ |
563 |
|
print ' ('.$langs->trans("DateFromTo",dolibarr_print_date($date_start),dolibarr_print_date($date_end)).')'; |
564 |
|
} |
565 |
|
if ($date_start && ! $date_end) |
566 |
|
{ |
567 |
|
print ' ('.$langs->trans("DateFrom",dolibarr_print_date($date_start)).')'; |
568 |
|
} |
569 |
|
if (! $date_start && $date_end) |
570 |
|
{ |
571 |
|
print ' ('.$langs->trans("DateUntil",dolibarr_print_date($date_end)).')'; |
572 |
|
} |
573 |
|
} |
574 |
|
|
575 |
|
|
576 |
|
|
577 |
llxHeader('',$langs->trans("Bill"),'Facture'); |
llxHeader('',$langs->trans("Bill"),'Facture'); |
578 |
|
|
579 |
$html = new Form($db); |
$html = new Form($db); |
974 |
print '<td align="right">'.$langs->trans("Qty").'</td>'; |
print '<td align="right">'.$langs->trans("Qty").'</td>'; |
975 |
print '<td align="right">'.$langs->trans("Discount").'</td></tr>'; |
print '<td align="right">'.$langs->trans("Discount").'</td></tr>'; |
976 |
|
|
977 |
|
// Lignes de contrat produits prédéfinis |
978 |
$sql = "SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description,"; |
$sql = "SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description,"; |
979 |
|
$sql.= " pt.date_ouverture_prevue as date_debut_prevue, pt.date_ouverture as date_debut_reel,"; |
980 |
|
$sql.= " pt.date_fin_validite as date_fin_prevue, pt.date_cloture as date_fin_reel,"; |
981 |
$sql.= " p.label as product, p.ref, p.rowid as prodid"; |
$sql.= " p.label as product, p.ref, p.rowid as prodid"; |
982 |
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as pt, ".MAIN_DB_PREFIX."product as p"; |
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as pt, ".MAIN_DB_PREFIX."product as p"; |
983 |
$sql.= " WHERE pt.fk_product = p.rowid AND pt.fk_contrat = ".$contrat->id; |
$sql.= " WHERE pt.fk_product = p.rowid AND pt.fk_contrat = ".$contrat->id; |
995 |
$var=!$var; |
$var=!$var; |
996 |
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 '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(""),"service")." ".$objp->ref."</a>"; |
997 |
print $objp->product?' - '.$objp->product:''; |
print $objp->product?' - '.$objp->product:''; |
998 |
|
// Plage de dates |
999 |
|
$date_start=$objp->date_debut_prevue; |
1000 |
|
if ($objp->date_debut_reel) $date_start=$objp->date_debut_reel; |
1001 |
|
$date_end=$objp->date_fin_prevue; |
1002 |
|
if ($objp->date_fin_reel) $date_end=$objp->date_fin_reel; |
1003 |
|
print_date_range($date_start,$date_end); |
1004 |
|
|
1005 |
print "</td>\n"; |
print "</td>\n"; |
1006 |
print '<td>'; |
print '<td>'; |
1007 |
print dolibarr_trunc($objp->description,60); |
print dolibarr_trunc($objp->description,60); |
1019 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
1020 |
} |
} |
1021 |
// Lignes de contrat non produits prédéfinis |
// Lignes de contrat non produits prédéfinis |
1022 |
$sql = "SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.subprice, pt.qty, pt.remise_percent"; |
$sql = "SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.subprice, pt.qty, pt.remise_percent,"; |
1023 |
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as pt"; |
$sql.= " pt.date_ouverture_prevue as date_debut_prevue, pt.date_ouverture as date_debut_reel,"; |
1024 |
$sql .= " WHERE pt.fk_contrat = ".$contrat->id; |
$sql.= " pt.date_fin_validite as date_fin_prevue, pt.date_cloture as date_fin_reel"; |
1025 |
$sql .= " AND (pt.fk_product = 0 or pt.fk_product is null)"; |
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as pt"; |
1026 |
$sql .= " ORDER BY pt.rowid ASC"; |
$sql.= " WHERE pt.fk_contrat = ".$contrat->id; |
1027 |
|
$sql.= " AND (pt.fk_product = 0 or pt.fk_product is null)"; |
1028 |
|
$sql.= " ORDER BY pt.rowid ASC"; |
1029 |
|
|
1030 |
$result=$db->query($sql); |
$result=$db->query($sql); |
1031 |
if ($result) |
if ($result) |
1353 |
else print img_object($langs->trans('ShowProduct'),'product'); |
else print img_object($langs->trans('ShowProduct'),'product'); |
1354 |
print ' '.$objp->ref.'</a>'; |
print ' '.$objp->ref.'</a>'; |
1355 |
print ' - '.nl2br(stripslashes($objp->product)); |
print ' - '.nl2br(stripslashes($objp->product)); |
1356 |
if ($objp->date_start && $objp->date_end) |
print_date_range($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).')'; |
|
|
} |
|
1357 |
print ($objp->description && $objp->description!=$objp->product)?'<br>'.$objp->description:''; |
print ($objp->description && $objp->description!=$objp->product)?'<br>'.$objp->description:''; |
1358 |
print '</td>'; |
print '</td>'; |
1359 |
} |
} |
1360 |
else |
else |
1361 |
{ |
{ |
1362 |
print '<td>'.stripslashes(nl2br($objp->description)); |
print '<td>'.stripslashes(nl2br($objp->description)); |
1363 |
if ($objp->date_start && $objp->date_end) |
print_date_range($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).')'; |
|
|
} |
|
1364 |
print "</td>\n"; |
print "</td>\n"; |
1365 |
} |
} |
1366 |
print '<td align="right">'.$objp->tva_taux.'%</td>'; |
print '<td align="right">'.$objp->tva_taux.'%</td>'; |