458 |
if ($id > 0) |
if ($id > 0) |
459 |
{ |
{ |
460 |
$contrat = New Contrat($db); |
$contrat = New Contrat($db); |
461 |
if ( $contrat->fetch($id) > 0) |
$result=$contrat->fetch($id); |
462 |
|
if ($result <= 0) |
463 |
{ |
{ |
464 |
|
dolibarr_print_error($db); |
465 |
|
exit; |
466 |
|
} |
467 |
|
|
468 |
|
if ($mesg) print $mesg; |
469 |
|
|
470 |
|
$author = new User($db); |
471 |
|
$author->id = $contrat->user_author_id; |
472 |
|
$author->fetch(); |
473 |
|
|
474 |
|
$commercial_signature = new User($db); |
475 |
|
$commercial_signature->id = $contrat->commercial_signature_id; |
476 |
|
$commercial_signature->fetch(); |
477 |
|
|
478 |
|
$commercial_suivi = new User($db); |
479 |
|
$commercial_suivi->id = $contrat->commercial_suivi_id; |
480 |
|
$commercial_suivi->fetch(); |
481 |
|
|
482 |
|
$h = 0; |
483 |
|
$head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; |
484 |
|
$head[$h][1] = $langs->trans("ContractCard"); |
485 |
|
$hselected = $h; |
486 |
|
$h++; |
487 |
|
|
488 |
|
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id; |
489 |
|
$head[$h][1] = $langs->trans("ContractContacts"); |
490 |
|
$h++; |
491 |
|
|
492 |
|
$head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; |
493 |
|
$head[$h][1] = $langs->trans("Info"); |
494 |
|
$h++; |
495 |
|
|
496 |
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id); |
497 |
|
|
498 |
|
|
499 |
|
/* |
500 |
|
* Confirmation de la suppression du contrat |
501 |
|
*/ |
502 |
|
if ($_GET["action"] == 'delete') |
503 |
|
{ |
504 |
|
$html->form_confirm("fiche.php?id=$id",$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete"); |
505 |
|
print '<br>'; |
506 |
|
} |
507 |
|
|
508 |
if ($mesg) print $mesg; |
/* |
509 |
|
* Confirmation de la validation |
510 |
$author = new User($db); |
*/ |
511 |
$author->id = $contrat->user_author_id; |
if ($_GET["action"] == 'valid') |
512 |
$author->fetch(); |
{ |
513 |
|
//$numfa = contrat_get_num($soc); |
514 |
$commercial_signature = new User($db); |
$html->form_confirm("fiche.php?id=$id",$langs->trans("ValidateAContract"),$langs->trans("ConfirmValidateContract"),"confirm_valid"); |
515 |
$commercial_signature->id = $contrat->commercial_signature_id; |
print '<br>'; |
516 |
$commercial_signature->fetch(); |
} |
|
|
|
|
$commercial_suivi = new User($db); |
|
|
$commercial_suivi->id = $contrat->commercial_suivi_id; |
|
|
$commercial_suivi->fetch(); |
|
|
|
|
|
$h = 0; |
|
|
$head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; |
|
|
$head[$h][1] = $langs->trans("ContractCard"); |
|
|
$hselected = $h; |
|
|
$h++; |
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id; |
|
|
$head[$h][1] = $langs->trans("ContractContacts"); |
|
|
$h++; |
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; |
|
|
$head[$h][1] = $langs->trans("Info"); |
|
|
$h++; |
|
|
|
|
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id); |
|
|
|
|
|
|
|
|
/* |
|
|
* Confirmation de la suppression du contrat |
|
|
*/ |
|
|
if ($_GET["action"] == 'delete') |
|
|
{ |
|
|
$html->form_confirm("fiche.php?id=$id",$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete"); |
|
|
print '<br>'; |
|
|
} |
|
517 |
|
|
518 |
/* |
/* |
519 |
* Confirmation de la validation |
* Confirmation de la fermeture |
520 |
*/ |
*/ |
521 |
if ($_GET["action"] == 'valid') |
if ($_GET["action"] == 'close') |
522 |
{ |
{ |
523 |
//$numfa = contrat_get_num($soc); |
$html->form_confirm("fiche.php?id=$id",$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close"); |
524 |
$html->form_confirm("fiche.php?id=$id",$langs->trans("ValidateAContract"),$langs->trans("ConfirmValidateContract"),"confirm_valid"); |
print '<br>'; |
525 |
print '<br>'; |
} |
526 |
} |
|
527 |
|
/* |
528 |
|
* Contrat |
529 |
|
*/ |
530 |
|
if ($contrat->brouillon == 1 && $user->rights->contrat->creer) |
531 |
|
{ |
532 |
|
print '<form action="fiche.php?id='.$id.'" method="post">'; |
533 |
|
print '<input type="hidden" name="action" value="setremise">'; |
534 |
|
} |
535 |
|
|
536 |
|
print '<table class="border" width="100%">'; |
537 |
|
|
538 |
/* |
// Reference du contrat |
539 |
* Confirmation de la fermeture |
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">'; |
540 |
*/ |
print $contrat->ref; |
541 |
if ($_GET["action"] == 'close') |
print "</td></tr>"; |
542 |
|
|
543 |
|
// Customer |
544 |
|
print "<tr><td>".$langs->trans("Customer")."</td>"; |
545 |
|
print '<td colspan="3">'; |
546 |
|
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$contrat->societe->id.'">'.$contrat->societe->nom.'</a></b></td></tr>'; |
547 |
|
|
548 |
|
// Statut contrat |
549 |
|
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'; |
550 |
|
print $contrat->statuts[$contrat->statut]; |
551 |
|
print "</td></tr>"; |
552 |
|
|
553 |
|
// Date |
554 |
|
print '<tr><td>'.$langs->trans("Date").'</td>'; |
555 |
|
print '<td colspan="3">'.dolibarr_print_date($contrat->date_contrat,"%A %d %B %Y")."</td></tr>\n"; |
556 |
|
|
557 |
|
// Factures associées |
558 |
|
/* |
559 |
|
TODO |
560 |
|
*/ |
561 |
|
|
562 |
|
// Projet |
563 |
|
if ($conf->projet->enabled) |
564 |
|
{ |
565 |
|
$langs->load("projects"); |
566 |
|
print '<tr><td>'; |
567 |
|
print '<table width="100%" class="nobordernopadding"><tr><td>'; |
568 |
|
print $langs->trans("Project"); |
569 |
|
print '</td>'; |
570 |
|
if ($_GET["action"] != "classer") print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classer&id='.$id.'">'.img_edit($langs->trans("SetProject")).'</a></td>'; |
571 |
|
print '</tr></table>'; |
572 |
|
print '</td><td colspan="3">'; |
573 |
|
if ($_GET["action"] == "classer") |
574 |
{ |
{ |
575 |
$html->form_confirm("fiche.php?id=$id",$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close"); |
$html->form_project("fiche.php?id=$id",$contrat->fk_soc,$contrat->fk_projet,"projetid"); |
|
print '<br>'; |
|
576 |
} |
} |
577 |
|
else |
|
/* |
|
|
* Contrat |
|
|
*/ |
|
|
if ($contrat->brouillon == 1 && $user->rights->contrat->creer) |
|
578 |
{ |
{ |
579 |
print '<form action="fiche.php?id='.$id.'" method="post">'; |
$html->form_project("fiche.php?id=$id",$contrat->fk_soc,$contrat->fk_projet,"none"); |
|
print '<input type="hidden" name="action" value="setremise">'; |
|
580 |
} |
} |
|
|
|
|
print '<table class="border" width="100%">'; |
|
|
|
|
|
// Reference du contrat |
|
|
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">'; |
|
|
print $contrat->ref; |
|
581 |
print "</td></tr>"; |
print "</td></tr>"; |
582 |
|
} |
583 |
|
|
584 |
// Customer |
print '<tr><td width="25%">'.$langs->trans("SalesRepresentativeFollowUp").'</td><td>'.$commercial_suivi->fullname.'</td>'; |
585 |
print "<tr><td>".$langs->trans("Customer")."</td>"; |
print '<td width="25%">'.$langs->trans("SalesRepresentativeSignature").'</td><td>'.$commercial_signature->fullname.'</td></tr>'; |
586 |
print '<td colspan="3">'; |
print "</table>"; |
|
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$contrat->societe->id.'">'.$contrat->societe->nom.'</a></b></td></tr>'; |
|
|
|
|
|
// Statut contrat |
|
|
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'; |
|
|
print $contrat->statuts[$contrat->statut]; |
|
|
print "</td></tr>"; |
|
587 |
|
|
588 |
// Date |
if ($contrat->brouillon == 1 && $user->rights->contrat->creer) |
589 |
print '<tr><td>'.$langs->trans("Date").'</td>'; |
{ |
590 |
print '<td colspan="3">'.dolibarr_print_date($contrat->date_contrat,"%A %d %B %Y")."</td></tr>\n"; |
print '</form>'; |
591 |
|
} |
|
// Factures associées |
|
|
/* |
|
|
TODO |
|
|
*/ |
|
592 |
|
|
593 |
// Projet |
/* |
594 |
if ($conf->projet->enabled) |
* Lignes de contrats |
595 |
{ |
*/ |
596 |
$langs->load("projects"); |
echo '<br><table class="noborder" width="100%">'; |
597 |
print '<tr><td>'; |
|
598 |
print '<table width="100%" class="nobordernopadding"><tr><td>'; |
$sql = "SELECT cd.statut, cd.label, cd.fk_product, cd.description, cd.price_ht, cd.qty, cd.rowid, cd.tva_tx, cd.remise_percent, cd.subprice,"; |
599 |
print $langs->trans("Project"); |
$sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_debut, ".$db->pdate("cd.date_ouverture")." as date_debut_reelle,"; |
600 |
print '</td>'; |
$sql.= " ".$db->pdate("cd.date_fin_validite")." as date_fin, ".$db->pdate("cd.date_cloture")." as date_fin_reelle"; |
601 |
if ($_GET["action"] != "classer") print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classer&id='.$id.'">'.img_edit($langs->trans("SetProject")).'</a></td>'; |
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; |
602 |
print '</tr></table>'; |
$sql.= " WHERE cd.fk_contrat = ".$id; |
603 |
print '</td><td colspan="3">'; |
$sql.= " ORDER BY cd .rowid"; |
|
if ($_GET["action"] == "classer") |
|
|
{ |
|
|
$html->form_project("fiche.php?id=$id",$contrat->fk_soc,$contrat->fk_projet,"projetid"); |
|
|
} |
|
|
else |
|
|
{ |
|
|
$html->form_project("fiche.php?id=$id",$contrat->fk_soc,$contrat->fk_projet,"none"); |
|
|
} |
|
|
print "</td></tr>"; |
|
|
} |
|
604 |
|
|
605 |
print '<tr><td width="25%">'.$langs->trans("SalesRepresentativeFollowUp").'</td><td>'.$commercial_suivi->fullname.'</td>'; |
$result = $db->query($sql); |
606 |
print '<td width="25%">'.$langs->trans("SalesRepresentativeSignature").'</td><td>'.$commercial_signature->fullname.'</td></tr>'; |
if ($result) |
607 |
print "</table>"; |
{ |
608 |
|
$num = $db->num_rows($result); |
609 |
|
$i = 0; $total = 0; |
610 |
|
|
611 |
if ($contrat->brouillon == 1 && $user->rights->contrat->creer) |
if ($num) |
612 |
{ |
{ |
613 |
print '</form>'; |
print '<tr class="liste_titre">'; |
614 |
|
print '<td>'.$langs->trans("Service").'</td>'; |
615 |
|
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>'; |
616 |
|
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>'; |
617 |
|
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>'; |
618 |
|
print '<td width="50" align="right">'.$langs->trans("Discount").'</td>'; |
619 |
|
print '<td width="30"> </td>'; |
620 |
|
print '<td width="30" align="center">'.$langs->trans("Status").'</td>'; |
621 |
|
print "</tr>\n"; |
622 |
} |
} |
623 |
|
$var=true; |
624 |
/* |
while ($i < $num) |
|
* Lignes de contrats |
|
|
*/ |
|
|
echo '<br><table class="noborder" width="100%">'; |
|
|
|
|
|
$sql = "SELECT cd.statut, cd.label, cd.fk_product, cd.description, cd.price_ht, cd.qty, cd.rowid, cd.tva_tx, cd.remise_percent, cd.subprice,"; |
|
|
$sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_debut, ".$db->pdate("cd.date_ouverture")." as date_debut_reelle,"; |
|
|
$sql.= " ".$db->pdate("cd.date_fin_validite")." as date_fin, ".$db->pdate("cd.date_cloture")." as date_fin_reelle"; |
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; |
|
|
$sql.= " WHERE cd.fk_contrat = ".$id; |
|
|
$sql.= " ORDER BY cd .rowid"; |
|
|
|
|
|
$result = $db->query($sql); |
|
|
if ($result) |
|
625 |
{ |
{ |
626 |
$num = $db->num_rows($result); |
$objp = $db->fetch_object($result); |
|
$i = 0; $total = 0; |
|
627 |
|
|
628 |
if ($num) |
$var=!$var; |
|
{ |
|
|
print '<tr class="liste_titre">'; |
|
|
print '<td>'.$langs->trans("Service").'</td>'; |
|
|
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>'; |
|
|
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>'; |
|
|
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>'; |
|
|
print '<td width="50" align="right">'.$langs->trans("Discount").'</td>'; |
|
|
print '<td width="30"> </td>'; |
|
|
print '<td width="30" align="center">'.$langs->trans("Status").'</td>'; |
|
|
print "</tr>\n"; |
|
|
} |
|
|
$var=true; |
|
|
while ($i < $num) |
|
|
{ |
|
|
$objp = $db->fetch_object($result); |
|
629 |
|
|
630 |
$var=!$var; |
if ($_GET["action"] != 'editline' || $_GET["rowid"] != $objp->rowid) |
631 |
|
{ |
632 |
|
|
633 |
if ($_GET["action"] != 'editline' || $_GET["rowid"] != $objp->rowid) |
print '<tr '.$bc[$var].' valign="top">'; |
634 |
|
if ($objp->fk_product > 0) |
635 |
{ |
{ |
636 |
|
print '<td>'; |
637 |
print '<tr '.$bc[$var].' valign="top">'; |
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; |
638 |
if ($objp->fk_product > 0) |
print img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a>'; |
639 |
{ |
if ($objp->description) print '<br />'.stripslashes(nl2br($objp->description)); |
|
print '<td>'; |
|
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; |
|
|
print img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a>'; |
|
|
if ($objp->description) print '<br />'.stripslashes(nl2br($objp->description)); |
|
|
print '</td>'; |
|
|
} |
|
|
else |
|
|
{ |
|
|
print "<td>".stripslashes(nl2br($objp->description))."</td>\n"; |
|
|
} |
|
|
// TVA |
|
|
print '<td align="center">'.$objp->tva_tx.'%</td>'; |
|
|
// Prix |
|
|
print '<td align="right">'.price($objp->subprice)."</td>\n"; |
|
|
// Quantité |
|
|
print '<td align="center">'.$objp->qty.'</td>'; |
|
|
// Remise |
|
|
if ($objp->remise_percent > 0) |
|
|
{ |
|
|
print '<td align="right">'.$objp->remise_percent."%</td>\n"; |
|
|
} |
|
|
else |
|
|
{ |
|
|
print '<td> </td>'; |
|
|
} |
|
|
// Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé) |
|
|
print '<td align="center" nowrap>'; |
|
|
if ($contrat->statut != 2 && $user->rights->contrat->creer) |
|
|
{ |
|
|
print '<a href="fiche.php?id='.$id.'&action=editline&rowid='.$objp->rowid.'">'; |
|
|
print img_edit(); |
|
|
print '</a>'; |
|
|
} |
|
|
else { |
|
|
print ' '; |
|
|
} |
|
|
if ($contrat->statut == 0 && $user->rights->contrat->creer) |
|
|
{ |
|
|
print ' '; |
|
|
print '<a href="fiche.php?id='.$id.'&action=deleteline&lineid='.$objp->rowid.'">'; |
|
|
print img_delete(); |
|
|
print '</a>'; |
|
|
} |
|
|
print '</td>'; |
|
|
|
|
|
// Statut |
|
|
print '<td align="center">'; |
|
|
if ($contrat->statut > 0) print '<a href="'.DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id.'&ligne='.$objp->rowid.'">';; |
|
|
print img_statut($objp->statut); |
|
|
if ($contrat->statut > 0) print '</a>'; |
|
640 |
print '</td>'; |
print '</td>'; |
641 |
|
} |
642 |
|
else |
643 |
|
{ |
644 |
|
print "<td>".stripslashes(nl2br($objp->description))."</td>\n"; |
645 |
|
} |
646 |
|
// TVA |
647 |
|
print '<td align="center">'.$objp->tva_tx.'%</td>'; |
648 |
|
// Prix |
649 |
|
print '<td align="right">'.price($objp->subprice)."</td>\n"; |
650 |
|
// Quantité |
651 |
|
print '<td align="center">'.$objp->qty.'</td>'; |
652 |
|
// Remise |
653 |
|
if ($objp->remise_percent > 0) |
654 |
|
{ |
655 |
|
print '<td align="right">'.$objp->remise_percent."%</td>\n"; |
656 |
|
} |
657 |
|
else |
658 |
|
{ |
659 |
|
print '<td> </td>'; |
660 |
|
} |
661 |
|
// Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé) |
662 |
|
print '<td align="center" nowrap>'; |
663 |
|
if ($contrat->statut != 2 && $user->rights->contrat->creer) |
664 |
|
{ |
665 |
|
print '<a href="fiche.php?id='.$id.'&action=editline&rowid='.$objp->rowid.'">'; |
666 |
|
print img_edit(); |
667 |
|
print '</a>'; |
668 |
|
} |
669 |
|
else { |
670 |
|
print ' '; |
671 |
|
} |
672 |
|
if ($contrat->statut == 0 && $user->rights->contrat->creer) |
673 |
|
{ |
674 |
|
print ' '; |
675 |
|
print '<a href="fiche.php?id='.$id.'&action=deleteline&lineid='.$objp->rowid.'">'; |
676 |
|
print img_delete(); |
677 |
|
print '</a>'; |
678 |
|
} |
679 |
|
print '</td>'; |
680 |
|
|
681 |
|
// Statut |
682 |
|
print '<td align="center">'; |
683 |
|
if ($contrat->statut > 0) print '<a href="'.DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id.'&ligne='.$objp->rowid.'">';; |
684 |
|
print img_statut($objp->statut); |
685 |
|
if ($contrat->statut > 0) print '</a>'; |
686 |
|
print '</td>'; |
687 |
|
|
688 |
print "</tr>\n"; |
print "</tr>\n"; |
|
|
|
|
// Dates mise en service |
|
|
print '<tr '.$bc[$var].'>'; |
|
|
print '<td colspan="7">'; |
|
|
// Si pas encore activé |
|
|
if (! $objp->date_debut_reelle) { |
|
|
print $langs->trans("DateStartPlanned").': '; |
|
|
if ($objp->date_debut) print dolibarr_print_date($objp->date_debut); |
|
|
else print $langs->trans("Unknown"); |
|
|
} |
|
|
// Si activé |
|
|
if ($objp->date_debut_reelle) { |
|
|
print $langs->trans("DateStartReal").': '; |
|
|
if ($objp->date_debut_reelle) print dolibarr_print_date($objp->date_debut_reelle); |
|
|
else print $langs->trans("ContractStatusNotRunning"); |
|
|
} |
|
689 |
|
|
690 |
print ' - '; |
// Dates mise en service |
691 |
|
print '<tr '.$bc[$var].'>'; |
692 |
// Si pas encore activé |
print '<td colspan="7">'; |
693 |
if (! $objp->date_debut_reelle) { |
// Si pas encore activé |
694 |
print $langs->trans("DateEndPlanned").': '; |
if (! $objp->date_debut_reelle) { |
695 |
if ($objp->date_fin) { |
print $langs->trans("DateStartPlanned").': '; |
696 |
print dolibarr_print_date($objp->date_fin); |
if ($objp->date_debut) print dolibarr_print_date($objp->date_debut); |
697 |
} |
else print $langs->trans("Unknown"); |
698 |
else print $langs->trans("Unknown"); |
} |
699 |
} |
// Si activé |
700 |
// Si activé |
if ($objp->date_debut_reelle) { |
701 |
if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { |
print $langs->trans("DateStartReal").': '; |
702 |
print $langs->trans("DateEndPlanned").': '; |
if ($objp->date_debut_reelle) print dolibarr_print_date($objp->date_debut_reelle); |
703 |
if ($objp->date_fin) { |
else print $langs->trans("ContractStatusNotRunning"); |
704 |
print dolibarr_print_date($objp->date_fin); |
} |
705 |
if ($objp->date_fin < time()) { print " ".img_warning($langs->trans("Late")); } |
|
706 |
} |
print ' - '; |
707 |
else print $langs->trans("Unknown"); |
|
708 |
|
// Si pas encore activé |
709 |
|
if (! $objp->date_debut_reelle) { |
710 |
|
print $langs->trans("DateEndPlanned").': '; |
711 |
|
if ($objp->date_fin) { |
712 |
|
print dolibarr_print_date($objp->date_fin); |
713 |
} |
} |
714 |
// Si désactivé |
else print $langs->trans("Unknown"); |
715 |
if ($objp->date_debut_reelle && $objp->date_fin_reelle) { |
} |
716 |
print $langs->trans("DateEndReal").': '; |
// Si activé |
717 |
print dolibarr_print_date($objp->date_fin_reelle); |
if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { |
718 |
|
print $langs->trans("DateEndPlanned").': '; |
719 |
|
if ($objp->date_fin) { |
720 |
|
print dolibarr_print_date($objp->date_fin); |
721 |
|
if ($objp->date_fin < time()) { print " ".img_warning($langs->trans("Late")); } |
722 |
} |
} |
723 |
print '</td>'; |
else print $langs->trans("Unknown"); |
724 |
print '</tr>'; |
} |
725 |
|
// Si désactivé |
726 |
|
if ($objp->date_debut_reelle && $objp->date_fin_reelle) { |
727 |
|
print $langs->trans("DateEndReal").': '; |
728 |
|
print dolibarr_print_date($objp->date_fin_reelle); |
729 |
} |
} |
730 |
|
print '</td>'; |
731 |
|
print '</tr>'; |
732 |
|
} |
733 |
|
|
734 |
// Ligne en mode update |
// Ligne en mode update |
735 |
else |
else |
736 |
|
{ |
737 |
|
print "<form action=\"fiche.php?id=$id\" method=\"post\">"; |
738 |
|
print '<input type="hidden" name="action" value="updateligne">'; |
739 |
|
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">'; |
740 |
|
// Ligne carac |
741 |
|
print "<tr $bc[$var]>"; |
742 |
|
print '<td>'; |
743 |
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; |
744 |
|
if ($objp->label) |
745 |
{ |
{ |
746 |
print "<form action=\"fiche.php?id=$id\" method=\"post\">"; |
print img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a><br>'; |
|
print '<input type="hidden" name="action" value="updateligne">'; |
|
|
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">'; |
|
|
// Ligne carac |
|
|
print "<tr $bc[$var]>"; |
|
|
print '<td>'; |
|
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; |
|
|
if ($objp->label) |
|
|
{ |
|
|
print img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a><br>'; |
|
|
} |
|
|
print '<textarea name="eldesc" cols="60" rows="1">'.$objp->description.'</textarea></td>'; |
|
|
print '<td align="right">'; |
|
|
print $html->select_tva("eltva_tx",$objp->tva_tx); |
|
|
print '</td>'; |
|
|
print '<td align="right"><input size="6" type="text" name="elprice" value="'.price($objp->subprice).'"></td>'; |
|
|
print '<td align="center"><input size="3" type="text" name="elqty" value="'.$objp->qty.'"></td>'; |
|
|
print '<td align="right"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>'; |
|
|
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>'; |
|
|
// Ligne dates prévues |
|
|
print "<tr $bc[$var]>"; |
|
|
print '<td colspan="8">'; |
|
|
print $langs->trans("DateStartPlanned").' '; |
|
|
$html->select_date($objp->date_debut,"date_start_update",0,0,($objp->date_debut>0?0:1)); |
|
|
print ' '.$langs->trans("DateEndPlanned").' '; |
|
|
$html->select_date($objp->date_fin,"date_end_update",0,0,($objp->date_fin>0?0:1)); |
|
|
print '</td>'; |
|
|
print '</tr>'; |
|
|
|
|
|
print "</form>\n"; |
|
747 |
} |
} |
748 |
$i++; |
print '<textarea name="eldesc" cols="60" rows="1">'.$objp->description.'</textarea></td>'; |
749 |
|
print '<td align="right">'; |
750 |
|
print $html->select_tva("eltva_tx",$objp->tva_tx); |
751 |
|
print '</td>'; |
752 |
|
print '<td align="right"><input size="6" type="text" name="elprice" value="'.price($objp->subprice).'"></td>'; |
753 |
|
print '<td align="center"><input size="3" type="text" name="elqty" value="'.$objp->qty.'"></td>'; |
754 |
|
print '<td align="right"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>'; |
755 |
|
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>'; |
756 |
|
// Ligne dates prévues |
757 |
|
print "<tr $bc[$var]>"; |
758 |
|
print '<td colspan="8">'; |
759 |
|
print $langs->trans("DateStartPlanned").' '; |
760 |
|
$html->select_date($objp->date_debut,"date_start_update",0,0,($objp->date_debut>0?0:1)); |
761 |
|
print ' '.$langs->trans("DateEndPlanned").' '; |
762 |
|
$html->select_date($objp->date_fin,"date_end_update",0,0,($objp->date_fin>0?0:1)); |
763 |
|
print '</td>'; |
764 |
|
print '</tr>'; |
765 |
|
|
766 |
|
print "</form>\n"; |
767 |
} |
} |
768 |
$db->free($result); |
$i++; |
|
} |
|
|
else |
|
|
{ |
|
|
dolibarr_print_error($db); |
|
769 |
} |
} |
770 |
|
$db->free($result); |
771 |
|
} |
772 |
|
else |
773 |
|
{ |
774 |
|
dolibarr_print_error($db); |
775 |
|
} |
776 |
|
|
777 |
|
|
778 |
/* |
/* |
779 |
* Ajouter une ligne produit/service |
* Ajouter une ligne produit/service |
780 |
*/ |
*/ |
781 |
if ($user->rights->contrat->creer && $contrat->statut == 0) |
if ($user->rights->contrat->creer && $contrat->statut == 0) |
782 |
{ |
{ |
783 |
print "<tr class=\"liste_titre\">"; |
print "<tr class=\"liste_titre\">"; |
784 |
print '<td>'.$langs->trans("Service").'</td>'; |
print '<td>'.$langs->trans("Service").'</td>'; |
785 |
print '<td align="center">'.$langs->trans("VAT").'</td>'; |
print '<td align="center">'.$langs->trans("VAT").'</td>'; |
786 |
print '<td align="right">'.$langs->trans("PriceUHT").'</td>'; |
print '<td align="right">'.$langs->trans("PriceUHT").'</td>'; |
787 |
print '<td align="center">'.$langs->trans("Qty").'</td>'; |
print '<td align="center">'.$langs->trans("Qty").'</td>'; |
788 |
print '<td align="right">'.$langs->trans("Discount").'</td>'; |
print '<td align="right">'.$langs->trans("Discount").'</td>'; |
789 |
print '<td> </td>'; |
print '<td> </td>'; |
790 |
print '<td> </td>'; |
print '<td> </td>'; |
791 |
print "</tr>\n"; |
print "</tr>\n"; |
792 |
|
|
793 |
|
$var=false; |
794 |
|
|
795 |
|
print '<form action="fiche.php?id='.$id.'" method="post">'; |
796 |
|
print '<input type="hidden" name="action" value="addligne">'; |
797 |
|
print '<input type="hidden" name="mode" value="predefined">'; |
798 |
|
print '<input type="hidden" name="id" value="'.$id.'">'; |
799 |
|
|
800 |
$var=false; |
print "<tr $bc[$var]>"; |
801 |
|
print '<td colspan="3">'; |
802 |
|
$html->select_produits('','p_idprod','',0); |
803 |
|
print '</td>'; |
804 |
|
|
805 |
print '<form action="fiche.php?id='.$id.'" method="post">'; |
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>'; |
806 |
print '<input type="hidden" name="action" value="addligne">'; |
print '<td align="right" nowrap><input type="text" class="flat" size="1" name="premise" value="0">%</td>'; |
807 |
print '<input type="hidden" name="mode" value="predefined">'; |
print '<td align="center" colspan="3" rowspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; |
808 |
print '<input type="hidden" name="id" value="'.$id.'">'; |
|
809 |
|
print "<tr $bc[$var]>"; |
810 |
print "<tr $bc[$var]>"; |
print '<td colspan="8">'; |
811 |
print '<td colspan="3">'; |
print $langs->trans("DateStartPlanned").' '; |
812 |
$html->select_produits('','p_idprod','',0); |
$html->select_date('',"date_start",0,0,1); |
813 |
print '</td>'; |
print ' '.$langs->trans("DateEndPlanned").' '; |
814 |
|
$html->select_date('',"date_end",0,0,1); |
815 |
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>'; |
print '</td>'; |
816 |
print '<td align="right" nowrap><input type="text" class="flat" size="1" name="premise" value="0">%</td>'; |
print '</tr>'; |
817 |
print '<td align="center" colspan="3" rowspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; |
|
818 |
|
print '</form>'; |
|
print "<tr $bc[$var]>"; |
|
|
print '<td colspan="8">'; |
|
|
print $langs->trans("DateStartPlanned").' '; |
|
|
$html->select_date('',"date_start",0,0,1); |
|
|
print ' '.$langs->trans("DateEndPlanned").' '; |
|
|
$html->select_date('',"date_end",0,0,1); |
|
|
print '</td>'; |
|
|
print '</tr>'; |
|
|
|
|
|
print '</form>'; |
|
819 |
|
|
820 |
$var=!$var; |
$var=!$var; |
821 |
|
|
822 |
print '<form action="fiche.php?id='.$id.'" method="post">'; |
print '<form action="fiche.php?id='.$id.'" method="post">'; |
823 |
print '<input type="hidden" name="action" value="addligne">'; |
print '<input type="hidden" name="action" value="addligne">'; |
824 |
print '<input type="hidden" name="mode" value="libre">'; |
print '<input type="hidden" name="mode" value="libre">'; |
825 |
print '<input type="hidden" name="id" value="'.$id.'">'; |
print '<input type="hidden" name="id" value="'.$id.'">'; |
826 |
|
|
827 |
print "<tr $bc[$var]>"; |
print "<tr $bc[$var]>"; |
828 |
print '<td><textarea name="desc" cols="50" rows="1"></textarea></td>'; |
print '<td><textarea name="desc" cols="50" rows="1"></textarea></td>'; |
829 |
|
|
830 |
print '<td>'; |
print '<td>'; |
831 |
$html->select_tva("tva_tx",$conf->defaulttx); |
$html->select_tva("tva_tx",$conf->defaulttx); |
832 |
print '</td>'; |
print '</td>'; |
833 |
print '<td align="right"><input type="text" class="flat" size="4" name="pu" value=""></td>'; |
print '<td align="right"><input type="text" class="flat" size="4" name="pu" value=""></td>'; |
834 |
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>'; |
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>'; |
835 |
print '<td align="right" nowrap><input type="text" class="flat" size="1" name="premise" value="0">%</td>'; |
print '<td align="right" nowrap><input type="text" class="flat" size="1" name="premise" value="0">%</td>'; |
836 |
print '<td align="center" colspan="2" rowspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; |
print '<td align="center" colspan="2" rowspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>'; |
837 |
|
|
838 |
print '</tr>'."\n"; |
print '</tr>'."\n"; |
839 |
|
|
840 |
print "<tr $bc[$var]>"; |
print "<tr $bc[$var]>"; |
841 |
print '<td colspan="8">'; |
print '<td colspan="8">'; |
842 |
print $langs->trans("DateStartPlanned").' '; |
print $langs->trans("DateStartPlanned").' '; |
843 |
$html->select_date('',"date_start",0,0,1); |
$html->select_date('',"date_start",0,0,1); |
844 |
print ' '.$langs->trans("DateEndPlanned").' '; |
print ' '.$langs->trans("DateEndPlanned").' '; |
845 |
$html->select_date('',"date_end",0,0,1); |
$html->select_date('',"date_end",0,0,1); |
846 |
print '</td>'; |
print '</td>'; |
847 |
print '</tr>'; |
print '</tr>'; |
848 |
|
|
849 |
print '</form>'; |
print '</form>'; |
850 |
} |
} |
851 |
print "</table>"; |
print "</table>"; |
852 |
/* |
/* |
853 |
* Fin Ajout ligne |
* Fin Ajout ligne |
854 |
*/ |
*/ |
|
|
|
|
print '</div>'; |
|
|
|
|
|
/************************************************************* |
|
|
* Boutons Actions |
|
|
*************************************************************/ |
|
855 |
|
|
856 |
if ($user->societe_id == 0) |
print '</div>'; |
|
{ |
|
|
print '<div class="tabsAction">'; |
|
857 |
|
|
|
if ($contrat->statut == 0 && $num) |
|
|
{ |
|
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Validate").'</a>'; |
|
|
} |
|
858 |
|
|
859 |
$numclos=$contrat->array_detail(5); // Tableau des lignes au statut clos |
/************************************************************* |
860 |
if ($contrat->statut == 1 && $num == sizeof($numclos)) |
* Boutons Actions |
861 |
{ |
*************************************************************/ |
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=close">'.$langs->trans("Close").'</a>'; |
|
|
} |
|
862 |
|
|
863 |
if ($contrat->statut == 0 && $user->rights->contrat->supprimer) |
if ($user->societe_id == 0) |
864 |
{ |
{ |
865 |
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>'; |
print '<div class="tabsAction">'; |
|
} |
|
866 |
|
|
867 |
print "</div>"; |
if ($contrat->statut == 0 && $num) |
868 |
|
{ |
869 |
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Validate").'</a>'; |
870 |
} |
} |
871 |
|
|
872 |
|
if ($contrat->statut > 0 && $user->rights->facture->creer) |
873 |
|
{ |
874 |
|
$langs->load("bills"); |
875 |
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&contratid='.$contrat->id.'&socidp='.$contrat->societe->id.'">'.$langs->trans("CreateBill").'</a>'; |
876 |
|
} |
877 |
|
|
878 |
|
$numclos=$contrat->array_detail(5); // Tableau des lignes au statut clos |
879 |
|
if ($contrat->statut == 1 && $num == sizeof($numclos)) |
880 |
|
{ |
881 |
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=close">'.$langs->trans("Close").'</a>'; |
882 |
|
} |
883 |
|
|
884 |
|
if ($contrat->statut == 0 && $user->rights->contrat->supprimer) |
885 |
|
{ |
886 |
|
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>'; |
887 |
|
} |
888 |
|
|
889 |
|
print "</div>"; |
890 |
} |
} |
891 |
else |
|
|
{ |
|
|
// Contrat non trouvé |
|
|
print "Contrat inexistant ou accés refusé"; |
|
|
} |
|
892 |
} |
} |
893 |
} |
} |
894 |
|
|