124 |
$facture->remise = $_POST["remise"]; |
$facture->remise = $_POST["remise"]; |
125 |
$facture->remise_percent = $_POST["remise_percent"]; |
$facture->remise_percent = $_POST["remise_percent"]; |
126 |
|
|
127 |
if (!$_POST["propalid"] && !$_POST["commandeid"]) |
if (! $_POST["propalid"] && ! $_POST["commandeid"] && ! $_POST["contratid"]) |
128 |
{ |
{ |
129 |
for ($i = 1 ; $i <= $NBLINES ; $i++) |
for ($i = 1 ; $i <= $NBLINES ; $i++) |
130 |
{ |
{ |
187 |
} |
} |
188 |
|
|
189 |
/* |
/* |
190 |
* Commande |
* Si création depuis commande |
191 |
*/ |
*/ |
192 |
if ($_POST["commandeid"]) |
if ($_POST["commandeid"]) |
193 |
{ |
{ |
222 |
} |
} |
223 |
} |
} |
224 |
|
|
225 |
|
/* |
226 |
|
* Si création depuis contrat |
227 |
|
*/ |
228 |
|
if ($_POST["contratid"]) |
229 |
|
{ |
230 |
|
$facture->contratid = $_POST["contratid"]; |
231 |
|
$facid = $facture->create($user); |
232 |
|
|
233 |
|
if ($facid) |
234 |
|
{ |
235 |
|
$contrat = New Contrat($db); |
236 |
|
if ( $contrat->fetch($_POST["contratid"]) ) |
237 |
|
{ |
238 |
|
$lines = $contrat->fetch_lignes(); |
239 |
|
for ($i = 0 ; $i < sizeof($lines) ; $i++) |
240 |
|
{ |
241 |
|
$result = $facture->addline($facid, |
242 |
|
addslashes($lines[$i]->description), |
243 |
|
$lines[$i]->subprice, |
244 |
|
$lines[$i]->qty, |
245 |
|
$lines[$i]->tva_tx, |
246 |
|
$lines[$i]->product_id, |
247 |
|
$lines[$i]->remise_percent); |
248 |
|
} |
249 |
|
} |
250 |
|
else |
251 |
|
{ |
252 |
|
print $langs->trans("UnknownError"); |
253 |
|
} |
254 |
|
} |
255 |
|
else |
256 |
|
{ |
257 |
|
dolibarr_print_error($db); |
258 |
|
} |
259 |
|
} |
260 |
|
|
261 |
|
// Fin création facture, on l'affiche |
262 |
if ($facid) |
if ($facid) |
263 |
{ |
{ |
264 |
Header("Location: facture.php?facid=".$facid); |
Header("Location: facture.php?facid=".$facid); |
551 |
{ |
{ |
552 |
print_titre($langs->trans("NewBill")); |
print_titre($langs->trans("NewBill")); |
553 |
|
|
554 |
|
$soc = new Societe($db); |
555 |
|
|
556 |
if ($_GET["propalid"]) |
if ($_GET["propalid"]) |
557 |
{ |
{ |
558 |
$propal = New Propal($db); |
$propal = New Propal($db); |
559 |
$propal->fetch($_GET["propalid"]); |
$propal->fetch($_GET["propalid"]); |
560 |
$societe_id = $propal->soc_id; |
$societe_id = $propal->soc_id; |
561 |
|
$soc->fetch($societe_id); |
562 |
} |
} |
563 |
elseif ($_GET["commandeid"]) |
elseif ($_GET["commandeid"]) |
564 |
{ |
{ |
565 |
$commande = New Commande($db); |
$commande = New Commande($db); |
566 |
$commande->fetch($_GET["commandeid"]); |
$commande->fetch($_GET["commandeid"]); |
567 |
$societe_id = $commande->soc_id; |
$societe_id = $commande->soc_id; |
568 |
|
$soc->fetch($societe_id); |
569 |
} |
} |
570 |
elseif ($_GET["contratid"]) |
elseif ($_GET["contratid"]) |
571 |
{ |
{ |
572 |
$contrat = New Contrat($db); |
$contrat = New Contrat($db); |
573 |
$contrat->fetch($_GET["contratid"]); |
$contrat->fetch($_GET["contratid"]); |
574 |
$societe_id = $contrat->soc_id; |
$societe_id = $contrat->societe->id; |
575 |
|
$soc=$contrat->societe; |
576 |
|
} |
577 |
|
else |
578 |
|
{ |
579 |
|
$societe_id=$socidp; |
580 |
|
$soc->fetch($societe_id); |
581 |
} |
} |
|
else $societe_id=$socidp; |
|
582 |
|
|
|
$soc = new Societe($db); |
|
|
$soc->fetch($societe_id); |
|
583 |
|
|
584 |
print '<form action="facture.php" method="post">'; |
print '<form action="facture.php" method="post">'; |
585 |
print '<input type="hidden" name="action" value="add">'; |
print '<input type="hidden" name="action" value="add">'; |
586 |
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n"; |
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n"; |
|
print '<input type="hidden" name="remise_percent" value="0">'; |
|
587 |
|
|
588 |
print '<table class="border" width="100%">'; |
print '<table class="border" width="100%">'; |
589 |
|
|
619 |
print '</textarea></td></tr>'; |
print '</textarea></td></tr>'; |
620 |
|
|
621 |
// Conditions de réglement |
// Conditions de réglement |
622 |
$id_condition_paiements_defaut=1; |
$cond_reglement_id_defaut=1; |
623 |
print "<tr><td nowrap>".$langs->trans("PaymentConditions")."</td><td>"; |
print "<tr><td nowrap>".$langs->trans("PaymentConditions")."</td><td>"; |
624 |
$html->select_conditions_paiements($id_condition_paiements_defaut,'cond_reglement_id'); |
$html->select_conditions_paiements($cond_reglement_id_defaut,'cond_reglement_id'); |
625 |
print "</td></tr>"; |
print "</td></tr>"; |
626 |
|
|
627 |
// Mode de réglement |
// Mode de réglement |
644 |
|
|
645 |
if ($_GET["propalid"] > 0) |
if ($_GET["propalid"] > 0) |
646 |
{ |
{ |
647 |
$amount = ($propal->price); |
print '<input type="hidden" name="amount" value="'.$propal->price.'">'."\n"; |
|
print '<input type="hidden" name="amount" value="'.$amount.'">'."\n"; |
|
648 |
print '<input type="hidden" name="total" value="'.$propal->total.'">'."\n"; |
print '<input type="hidden" name="total" value="'.$propal->total.'">'."\n"; |
649 |
print '<input type="hidden" name="remise" value="'.$propal->remise.'">'."\n"; |
print '<input type="hidden" name="remise" value="'.$propal->remise.'">'."\n"; |
650 |
print '<input type="hidden" name="remise_percent" value="'.$propal->remise_percent.'">'."\n"; |
print '<input type="hidden" name="remise_percent" value="'.$propal->remise_percent.'">'."\n"; |
653 |
|
|
654 |
print '<tr><td>'.$langs->trans("Proposal").'</td><td colspan="2">'.$propal->ref.'</td></tr>'; |
print '<tr><td>'.$langs->trans("Proposal").'</td><td colspan="2">'.$propal->ref.'</td></tr>'; |
655 |
print '<tr><td>'.$langs->trans("GlobalDiscount").'</td><td colspan="2">'.$propal->remise_percent.'%</td></tr>'; |
print '<tr><td>'.$langs->trans("GlobalDiscount").'</td><td colspan="2">'.$propal->remise_percent.'%</td></tr>'; |
656 |
print '<tr><td>'.$langs->trans("TotalHT").'</td><td colspan="2">'.price($amount).'</td></tr>'; |
print '<tr><td>'.$langs->trans("TotalHT").'</td><td colspan="2">'.price($propal->price).'</td></tr>'; |
657 |
print '<tr><td>'.$langs->trans("VAT").'</td><td colspan="2">'.price($propal->tva)."</td></tr>"; |
print '<tr><td>'.$langs->trans("VAT").'</td><td colspan="2">'.price($propal->tva)."</td></tr>"; |
658 |
print '<tr><td>'.$langs->trans("TotalTTC").'</td><td colspan="2">'.price($propal->total)."</td></tr>"; |
print '<tr><td>'.$langs->trans("TotalTTC").'</td><td colspan="2">'.price($propal->total)."</td></tr>"; |
659 |
} |
} |
660 |
elseif ($_GET["commandeid"] > 0) |
elseif ($_GET["commandeid"] > 0) |
661 |
{ |
{ |
662 |
|
$commande->remise_percent=$soc->remise_client; |
663 |
print '<input type="hidden" name="commandeid" value="'.$commande->id.'">'; |
print '<input type="hidden" name="commandeid" value="'.$commande->id.'">'; |
664 |
|
print '<input type="hidden" name="remise_percent" value="'.$commande->remise_percent.'">'."\n"; |
665 |
|
|
666 |
print '<tr><td>'.$langs->trans("Order").'</td><td colspan="2">'.$commande->ref.'</td></tr>'; |
print '<tr><td>'.$langs->trans("Order").'</td><td colspan="2">'.$commande->ref.'</td></tr>'; |
667 |
print '<tr><td>'.$langs->trans("TotalHT").'</td><td colspan="2">'.price($commande->total_ht).'</td></tr>'; |
print '<tr><td>'.$langs->trans("TotalHT").'</td><td colspan="2">'.price($commande->total_ht).'</td></tr>'; |
670 |
} |
} |
671 |
elseif ($_GET["contratid"] > 0) |
elseif ($_GET["contratid"] > 0) |
672 |
{ |
{ |
673 |
$amount = ($obj->price); |
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva |
674 |
print '<input type="hidden" name="amount" value="'.$amount.'">'."\n"; |
$contrat->remise=0; |
675 |
print '<input type="hidden" name="total" value="'.$obj->total.'">'."\n"; |
$contrat->remise_percent=$soc->remise_client; |
676 |
print '<input type="hidden" name="remise" value="'.$obj->remise.'">'."\n"; |
$contrat->update_price(); |
677 |
print '<input type="hidden" name="remise_percent" value="'.$obj->remise_percent.'">'."\n"; |
|
678 |
print '<input type="hidden" name="tva" value="'.$obj->tva.'">'."\n"; |
print '<input type="hidden" name="amount" value="'.$contrat->total_ht.'">'."\n"; |
679 |
|
print '<input type="hidden" name="total" value="'.$contrat->total_ttc.'">'."\n"; |
680 |
|
print '<input type="hidden" name="remise" value="'.$contrat->remise.'">'."\n"; |
681 |
|
print '<input type="hidden" name="remise_percent" value="'.$contrat->remise_percent.'">'."\n"; |
682 |
|
print '<input type="hidden" name="tva" value="'.$contrat->total_tva.'">'."\n"; |
683 |
print '<input type="hidden" name="contratid" value="'.$_GET["contratid"].'">'; |
print '<input type="hidden" name="contratid" value="'.$_GET["contratid"].'">'; |
684 |
|
|
685 |
print '<tr><td>'.$langs->trans("Contract").'</td><td colspan="2">'.$obj->ref.'</td></tr>'; |
print '<tr><td>'.$langs->trans("Contract").'</td><td colspan="2">'.$contrat->ref.'</td></tr>'; |
686 |
print '<tr><td>'.$langs->trans("TotalHT").'</td><td colspan="2">'.price($amount).'</td></tr>'; |
print '<tr><td>'.$langs->trans("TotalHT").'</td><td colspan="2">'.price($contrat->total_ht).'</td></tr>'; |
687 |
print '<tr><td>'.$langs->trans("VAT").'</td><td colspan="2">'.price($obj->tva)."</td></tr>"; |
print '<tr><td>'.$langs->trans("VAT").'</td><td colspan="2">'.price($contrat->total_tva)."</td></tr>"; |
688 |
print '<tr><td>'.$langs->trans("TotalTTC").'</td><td colspan="2">'.price($obj->total)."</td></tr>"; |
print '<tr><td>'.$langs->trans("TotalTTC").'</td><td colspan="2">'.price($contrat->total_ttc)."</td></tr>"; |
689 |
} |
} |
690 |
else |
else |
691 |
{ |
{ |
725 |
/* |
/* |
726 |
* Factures récurrentes |
* Factures récurrentes |
727 |
*/ |
*/ |
728 |
if ($_GET["propalid"] == 0 && $_GET["commandeid"] == 0) |
if ($_GET["propalid"] == 0 && $_GET["commandeid"] == 0 && $_GET["contratid"] == 0) |
729 |
{ |
{ |
730 |
$sql = "SELECT r.rowid, r.titre, r.amount FROM ".MAIN_DB_PREFIX."facture_rec as r"; |
$sql = "SELECT r.rowid, r.titre, r.amount FROM ".MAIN_DB_PREFIX."facture_rec as r"; |
731 |
$sql .= " WHERE r.fk_soc = ".$soc->id; |
$sql .= " WHERE r.fk_soc = ".$soc->id; |
766 |
print_titre($langs->trans("ProductsAndServices")); |
print_titre($langs->trans("ProductsAndServices")); |
767 |
|
|
768 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
769 |
print '<tr class="liste_titre"><td>'.$langs->trans("Ref").'</td><td>'.$langs->trans("Description").'</td>'; |
print '<tr class="liste_titre">'; |
770 |
|
print '<td>'.$langs->trans("Ref").'</td>'; |
771 |
|
print '<td>'.$langs->trans("Description").'</td>'; |
772 |
print '<td align="right">'.$langs->trans("VAT").'</td>'; |
print '<td align="right">'.$langs->trans("VAT").'</td>'; |
773 |
print '<td align="right">'.$langs->trans("PriceUHT").'</td>'; |
print '<td align="right">'.$langs->trans("PriceUHT").'</td>'; |
774 |
print '<td align="right">'.$langs->trans("Qty").'</td>'; |
print '<td align="right">'.$langs->trans("Qty").'</td>'; |
810 |
$sql = "SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.price, pt.qty, pt.remise_percent"; |
$sql = "SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.price, pt.qty, pt.remise_percent"; |
811 |
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt "; |
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt "; |
812 |
$sql .= " WHERE pt.fk_propal = ".$_GET["propalid"]; |
$sql .= " WHERE pt.fk_propal = ".$_GET["propalid"]; |
813 |
$sql .= " AND pt.fk_product = 0"; |
$sql .= " AND (pt.fk_product = 0 or pt.fk_product is null)"; |
814 |
$sql .= " ORDER BY pt.rowid ASC"; |
$sql .= " ORDER BY pt.rowid ASC"; |
815 |
$result=$db->query($sql); |
$result=$db->query($sql); |
816 |
if ($result) |
if ($result) |
822 |
$objp = $db->fetch_object($result); |
$objp = $db->fetch_object($result); |
823 |
$var=!$var; |
$var=!$var; |
824 |
print "<tr $bc[$var]><td> </td>\n"; |
print "<tr $bc[$var]><td> </td>\n"; |
825 |
print '<td>'.$objp->product.'</td>'; |
print '<td>'.dolibarr_trunc($objp->product,60).'</td>'; |
826 |
print '<td align="right">'.$objp->tva_tx.'%</td>'; |
print '<td align="right">'.$objp->tva_tx.'%</td>'; |
827 |
print '<td align="right">'.price($objp->price).'</td>'; |
print '<td align="right">'.price($objp->price).'</td>'; |
828 |
print '<td align="right">'.$objp->qty.'</td>'; |
print '<td align="right">'.$objp->qty.'</td>'; |
842 |
// Si creation depuis une commande |
// Si creation depuis une commande |
843 |
if ($_GET["commandeid"]) |
if ($_GET["commandeid"]) |
844 |
{ |
{ |
845 |
|
print '<br>'; |
846 |
print_titre($langs->trans("Products")); |
print_titre($langs->trans("Products")); |
847 |
|
|
848 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
849 |
print '<tr class="liste_titre"><td>'.$langs->trans("Ref").'</td><td>'.$langs->trans("Product").'</td>'; |
print '<tr class="liste_titre">'; |
850 |
print '<td align="right">'.$langs->trans("Price").'</td><td align="center">'.$langs->trans("Discount").'</td><td align="center">'.$langs->trans("Qty").'</td></tr>'; |
print '<td>'.$langs->trans("Ref").'</td>'; |
851 |
|
print '<td>'.$langs->trans("Description").'</td>'; |
852 |
|
print '<td align="right">'.$langs->trans("VAT").'</td>'; |
853 |
|
print '<td align="right">'.$langs->trans("PriceUHT").'</td>'; |
854 |
|
print '<td align="right">'.$langs->trans("Qty").'</td>'; |
855 |
|
print '<td align="right">'.$langs->trans("Discount").'</td></tr>'; |
856 |
|
|
857 |
$sql = "SELECT pt.rowid, p.label as product, p.ref, pt.subprice, pt.qty, p.rowid as prodid, pt.remise_percent, pt.description"; |
$sql = "SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description,"; |
858 |
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as pt, ".MAIN_DB_PREFIX."product as p"; |
$sql.= " p.label as product, p.ref, p.rowid as prodid"; |
859 |
$sql .= " WHERE pt.fk_product = p.rowid AND pt.fk_commande = ".$commande->id; |
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as pt, ".MAIN_DB_PREFIX."product as p"; |
860 |
$sql .= " ORDER BY pt.rowid ASC"; |
$sql.= " WHERE pt.fk_product = p.rowid AND pt.fk_commande = ".$commande->id; |
861 |
|
$sql.= " ORDER BY pt.rowid ASC"; |
862 |
|
|
863 |
$result = $db->query($sql); |
$result = $db->query($sql); |
864 |
if ($result) |
if ($result) |
865 |
{ |
{ |
866 |
$num = $db->num_rows(); |
$num = $db->num_rows($result); |
867 |
$i = 0; |
$i = 0; |
868 |
$var=True; |
$var=True; |
869 |
while ($i < $num) |
while ($i < $num) |
870 |
{ |
{ |
871 |
$objp = $db->fetch_object(); |
$objp = $db->fetch_object($result); |
872 |
$var=!$var; |
$var=!$var; |
873 |
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(""),"product")." ".$objp->ref."</a>"; |
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(""),"product")." ".$objp->ref."</a>"; |
874 |
print $objp->product?' - '.$objp->product:''; |
print $objp->product?' - '.$objp->product:''; |
876 |
print '<td>'; |
print '<td>'; |
877 |
print dolibarr_trunc($objp->description,60); |
print dolibarr_trunc($objp->description,60); |
878 |
print '</td>'; |
print '</td>'; |
879 |
|
print '<td align="right">'.$objp->tva_tx.'%</td>'; |
880 |
print '<td align="right">'.price($objp->subprice).'</td>'; |
print '<td align="right">'.price($objp->subprice).'</td>'; |
881 |
print '<td align="center">'.$objp->remise_percent.'%</td>'; |
print '<td align="right">'.$objp->qty.'</td>'; |
882 |
print '<td align="center">'.$objp->qty.'</td></tr>'; |
print '<td align="right">'.$objp->remise_percent.'%</td>'; |
883 |
|
print '</tr>'; |
884 |
$i++; |
$i++; |
885 |
} |
} |
886 |
} |
} |
889 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
890 |
} |
} |
891 |
// Lignes de commande non produits prédéfinis |
// Lignes de commande non produits prédéfinis |
892 |
$sql = "SELECT pt.rowid, pt.description as product, 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"; |
893 |
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as pt"; |
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as pt"; |
894 |
$sql .= " WHERE pt.fk_commande = ".$commande->id; |
$sql .= " WHERE pt.fk_commande = ".$commande->id; |
895 |
$sql .= " AND pt.fk_product = 0"; |
$sql .= " AND (pt.fk_product = 0 or pt.fk_product is null)"; |
896 |
$sql .= " ORDER BY pt.rowid ASC"; |
$sql .= " ORDER BY pt.rowid ASC"; |
897 |
|
|
898 |
$result=$db->query($sql); |
$result=$db->query($sql); |
905 |
$objp = $db->fetch_object($result); |
$objp = $db->fetch_object($result); |
906 |
$var=!$var; |
$var=!$var; |
907 |
print "<tr $bc[$var]><td> </td>\n"; |
print "<tr $bc[$var]><td> </td>\n"; |
908 |
print '<td>'.$objp->product.'</td>'; |
print '<td>'.dolibarr_trunc($objp->product,60).'</td>'; |
909 |
|
print '<td align="right">'.$objp->tva_tx.'%</td>'; |
910 |
print '<td align="right">'.price($objp->subprice).'</td>'; |
print '<td align="right">'.price($objp->subprice).'</td>'; |
911 |
print '<td align="center">'.$objp->remise_percent.'%</td>'; |
print '<td align="right">'.$objp->qty.'</td>'; |
912 |
print '<td align="center">'.$objp->qty.'</td>'; |
print '<td align="right">'.$objp->remise_percent.'%</td>'; |
913 |
print '</tr>'; |
print '</tr>'; |
914 |
$i++; |
$i++; |
915 |
} |
} |
921 |
|
|
922 |
print '</table>'; |
print '</table>'; |
923 |
} |
} |
924 |
|
|
925 |
|
// Si creation depuis un contrat |
926 |
|
if ($_GET["contratid"]) |
927 |
|
{ |
928 |
|
print '<br>'; |
929 |
|
print_titre($langs->trans("Services")); |
930 |
|
|
931 |
|
print '<table class="noborder" width="100%">'; |
932 |
|
print '<tr class="liste_titre">'; |
933 |
|
print '<td>'.$langs->trans("Ref").'</td>'; |
934 |
|
print '<td>'.$langs->trans("Description").'</td>'; |
935 |
|
print '<td align="right">'.$langs->trans("VAT").'</td>'; |
936 |
|
print '<td align="right">'.$langs->trans("PriceUHT").'</td>'; |
937 |
|
print '<td align="right">'.$langs->trans("Qty").'</td>'; |
938 |
|
print '<td align="right">'.$langs->trans("Discount").'</td></tr>'; |
939 |
|
|
940 |
|
$sql = "SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description,"; |
941 |
|
$sql.= " p.label as product, p.ref, p.rowid as prodid"; |
942 |
|
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as pt, ".MAIN_DB_PREFIX."product as p"; |
943 |
|
$sql.= " WHERE pt.fk_product = p.rowid AND pt.fk_contrat = ".$contrat->id; |
944 |
|
$sql.= " ORDER BY pt.rowid ASC"; |
945 |
|
|
946 |
|
$result = $db->query($sql); |
947 |
|
if ($result) |
948 |
|
{ |
949 |
|
$num = $db->num_rows($result); |
950 |
|
$i = 0; |
951 |
|
$var=True; |
952 |
|
while ($i < $num) |
953 |
|
{ |
954 |
|
$objp = $db->fetch_object($result); |
955 |
|
$var=!$var; |
956 |
|
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.img_object($langs->trans(""),"service")." ".$objp->ref."</a>"; |
957 |
|
print $objp->product?' - '.$objp->product:''; |
958 |
|
print "</td>\n"; |
959 |
|
print '<td>'; |
960 |
|
print dolibarr_trunc($objp->description,60); |
961 |
|
print '</td>'; |
962 |
|
print '<td align="right">'.$objp->tva_tx.'%</td>'; |
963 |
|
print '<td align="right">'.price($objp->subprice).'</td>'; |
964 |
|
print '<td align="right">'.$objp->qty.'</td>'; |
965 |
|
print '<td align="right">'.$objp->remise_percent.'%</td>'; |
966 |
|
print '</tr>'; |
967 |
|
$i++; |
968 |
|
} |
969 |
|
} |
970 |
|
else |
971 |
|
{ |
972 |
|
dolibarr_print_error($db); |
973 |
|
} |
974 |
|
// Lignes de contrat non produits prédéfinis |
975 |
|
$sql = "SELECT pt.rowid, pt.description as product, pt.tva_tx, pt.subprice, pt.qty, pt.remise_percent"; |
976 |
|
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as pt"; |
977 |
|
$sql .= " WHERE pt.fk_contrat = ".$contrat->id; |
978 |
|
$sql .= " AND (pt.fk_product = 0 or pt.fk_product is null)"; |
979 |
|
$sql .= " ORDER BY pt.rowid ASC"; |
980 |
|
|
981 |
|
$result=$db->query($sql); |
982 |
|
if ($result) |
983 |
|
{ |
984 |
|
$num = $db->num_rows($result); |
985 |
|
$i = 0; |
986 |
|
while ($i < $num) |
987 |
|
{ |
988 |
|
$objp = $db->fetch_object($result); |
989 |
|
$var=!$var; |
990 |
|
print "<tr $bc[$var]><td> </td>\n"; |
991 |
|
print '<td>'.dolibarr_trunc($objp->product,60).'</td>'; |
992 |
|
print '<td align="right">'.$objp->tva_tx.'%</td>'; |
993 |
|
print '<td align="right">'.price($objp->subprice).'</td>'; |
994 |
|
print '<td align="right">'.$objp->qty.'</td>'; |
995 |
|
print '<td align="right">'.$objp->remise_percent.'%</td>'; |
996 |
|
print '</tr>'; |
997 |
|
$i++; |
998 |
|
} |
999 |
|
} |
1000 |
|
else |
1001 |
|
{ |
1002 |
|
dolibarr_print_error($db); |
1003 |
|
} |
1004 |
|
|
1005 |
|
print '</table>'; |
1006 |
|
} |
1007 |
|
|
1008 |
} |
} |
1009 |
else |
else |
1010 |
{ |
{ |