From 61063d730961060a1d96e1b629b655e56a29061d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Jul 2005 02:37:16 +0000 Subject: [PATCH] =?UTF-8?q?New:=20Ajout=20gestion=20=E9tat=20validation=20?= =?UTF-8?q?des=20contrats?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/index.php | 9 +- htdocs/contrat/contrat.class.php | 77 ++++- htdocs/contrat/fiche.php | 200 ++++++----- htdocs/contrat/index.php | 63 +++- htdocs/contrat/ligne.php | 574 +++++++++++++++++-------------- htdocs/contrat/liste.php | 9 +- htdocs/contrat/statut5.png | Bin 0 -> 200 bytes 7 files changed, 558 insertions(+), 374 deletions(-) create mode 100644 htdocs/contrat/statut5.png diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index a1552e0885e..5244279a21f 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -46,7 +46,7 @@ if ($user->societe_id > 0) $socidp = $user->societe_id; } -$max=4; +$max=5; llxHeader(); @@ -249,7 +249,7 @@ if ($user->rights->societe->lire) { $sql .= " AND s.idp = $user->societe_id"; } - $sql .= " ORDER BY s.datec DESC "; + $sql .= " ORDER BY s.datec DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); @@ -295,7 +295,8 @@ if ($socidp) { $sql .= " AND s.idp = $socidp"; } -$sql .= " ORDER BY a.datea DESC limit 5"; +$sql .= " ORDER BY a.datea DESC"; +$sql .= $db->plimit($max, 0); $resql=$db->query($sql); if ($resql) @@ -303,7 +304,7 @@ if ($resql) $num = $db->num_rows($resql); print ''; - print ''; + print ''; $var = true; $i = 0; diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index cae8afcc53a..d52e43d7a20 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -65,8 +65,8 @@ class Contrat $this->user_cloture = new User($DB); // Statut 0=ouvert, 1=actif, 2=cloturé - $this->statuts[0]=$langs->trans("Opened"); - $this->statuts[1]=$langs->trans("Running"); + $this->statuts[0]=$langs->trans("Draft"); + $this->statuts[1]=$langs->trans("Validated"); $this->statuts[2]=$langs->trans("Closed"); } @@ -160,6 +160,42 @@ class Contrat } } + + /** + * \brief Active une ligne detail d'un contrat + * \param user Objet User qui avtice le contrat + * \param line_id Id de la ligne de detail à activer + * \param date Date fin + * \return int < 0 si erreur, > 0 si ok + */ + function close_line($user, $line_id, $dateend) + { + // statut actif : 4 + + $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 5,"; + $sql.= " date_cloture = '".$this->db->idate($dateend)."',"; + $sql.= " fk_user_cloture = ".$user->id; + $sql.= " WHERE rowid = ".$line_id . " AND statut = 4"; + + $result = $this->db->query($sql) ; + + if ($result) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $interface->run_triggers('CONTRACT_SERVICE_CLOSE',$this,$user,$lang,$conf); + // Fin appel triggers + + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + /** * \brief Cloture un contrat @@ -185,12 +221,31 @@ class Contrat return 1; } + /** + * \brief Valide un contrat + * \param user Objet User qui valide + * \param lang Environnement langue de l'utilisateur + * \param conf Environnement de configuration lors de l'opération + */ + function validate($user,$lang='',$conf='') + { + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 1"; + $sql .= " WHERE rowid = ".$this->id . " AND statut = 0"; + + $result = $this->db->query($sql) ; + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $interface->run_triggers('CONTRACT_VALIDATE',$this,$user,$lang,$conf); + // Fin appel triggers + } + /** * \brief Annule un contrat * \param user Objet User qui annule * \param lang Environnement langue de l'utilisateur * \param conf Environnement de configuration lors de l'opération - * */ function annule($user,$lang='',$conf='') { @@ -206,7 +261,6 @@ class Contrat $interface->run_triggers('CONTRACT_CANCEL',$this,$user,$lang,$conf); // Fin appel triggers } - /** * \brief Charge de la base les données du contrat @@ -361,7 +415,7 @@ class Contrat } $remise = 0; - $price = round(ereg_replace(",",".",$pu), 2); + $price = ereg_replace(",",".",round($pu, 2)); $subprice = $price; if (trim(strlen($remise_percent)) > 0) { @@ -370,11 +424,14 @@ class Contrat } // Insertion dans la base - $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet "; - $sql.= "(fk_contrat,label,description,fk_product, price_ht,qty,tva_tx, remise_percent, subprice, remise"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; + $sql.= " (fk_contrat, label, description, fk_product, price_ht, qty, tva_tx,"; + $sql.= " remise_percent, subprice, remise"; if ($datestart > 0) { $sql.= ",date_ouverture_prevue"; } if ($dateend > 0) { $sql.= ",date_fin_validite"; } - $sql.= ") VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',$fk_product,".ereg_replace(",",".",$price).", '$qty', $txtva, $remise_percent,'".ereg_replace(",",".",$subprice)."','".ereg_replace(",",".", $remise)."'"; + $sql.= ") VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',"; + $sql.= ($fk_product>0 ? $fk_product : "null"); + $sql.= ",".ereg_replace(",",".",$price).", '$qty', $txtva, $remise_percent,'".ereg_replace(",",".",$subprice)."','".ereg_replace(",",".", $remise)."'"; if ($datestart > 0) { $sql.= ",".$this->db->idate($datestart); } if ($dateend > 0) { $sql.= ",".$this->db->idate($dateend); } $sql.= ");"; @@ -497,8 +554,8 @@ class Contrat global $langs; $langs->load("contracts"); - if ($statut == 0) { return $langs->trans("ContractStatusNotRunning"); } - if ($statut == 1) { return $langs->trans("ContractStatusRunning"); } + if ($statut == 0) { return $langs->trans("ContractStatusDraft"); } + if ($statut == 1) { return $langs->trans("ContractStatusValidated"); } if ($statut == 2) { return $langs->trans("ContractStatusClosed"); } } diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 3618b1f6a6d..8afc8473a20 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -29,6 +29,9 @@ */ require("./pre.inc.php"); +require("../project.class.php"); +require("../propal.class.php"); +require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); $langs->load("contracts"); $langs->load("orders"); @@ -36,13 +39,9 @@ $langs->load("companies"); $user->getrights('contrat'); -if (!$user->rights->contrat->lire) +if (! $user->rights->contrat->lire) accessforbidden(); -require("../project.class.php"); -require("../propal.class.php"); -require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); - $date_start_update=mktime(12, 0 , 0, $_POST["date_start_updatemonth"], $_POST["date_start_updateday"], $_POST["date_start_updateyear"]); $date_end_update=mktime(12, 0 , 0, $_POST["date_end_updatemonth"], $_POST["date_end_updateday"], $_POST["date_end_updateyear"]); $date_start=mktime(12, 0 , 0, $_POST["date_startmonth"], $_POST["date_startday"], $_POST["date_startyear"]); @@ -108,18 +107,19 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer) $result = 0; $contrat = new Contrat($db); $result=$contrat->fetch($_GET["id"]); - if ($_POST["p_idprod"] > 0) + if (($_POST["p_idprod"] > 0 && $_POST["mode"]=='predefined') || ($_POST["mode"]=='libre')) { //print $_POST["desc"]." - ".$_POST["pu"]." - ".$_POST["pqty"]." - ".$_POST["tva_tx"]." - ".$_POST["p_idprod"]." - ".$_POST["premise"]; exit; - $result = $contrat->addline($_POST["desc"], - $_POST["pu"], - $_POST["pqty"], - $_POST["tva_tx"], - $_POST["p_idprod"], - $_POST["premise"], - $date_start, - $date_end - ); + $result = $contrat->addline( + $_POST["desc"], + $_POST["pu"], + $_POST["pqty"], + $_POST["tva_tx"], + $_POST["p_idprod"], + $_POST["premise"], + $date_start, + $date_end + ); } if ($result >= 0) @@ -174,23 +174,23 @@ if ($_GET["action"] == 'deleteline' && $user->rights->contrat->creer) } } -if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->rights->contrat->valider) +if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->contrat->creer) { $contrat = new Contrat($db); $contrat->fetch($_GET["id"]); $soc = new Societe($db); $soc->fetch($contrat->soc_id); - $result = $contrat->valid($user); + $result = $contrat->validate($user); } -if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->contrat->valider) +if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == 'yes' && $user->rights->contrat->creer) { $contrat = new Contrat($db); $contrat->fetch($_GET["id"]); $result = $contrat->cancel($user); } -if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes) +if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') { if ($user->rights->contrat->supprimer ) { @@ -202,22 +202,11 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes) } } -/* -* -*/ -if ($action == 'pdf') -{ - /* - * Generation de la commande - * définit dans /includes/modules/commande/modules_commande.php - */ - commande_pdf_create($db, $_GET["id"]); -} + + llxHeader('',$langs->trans("ContractCard"),"Contrat"); - - $html = new Form($db); @@ -251,7 +240,7 @@ if ($_GET["action"] == 'create') print ''; print ''; - print '' ."\n"; + print ''."\n"; print ''; print '
'.$langs->trans("LastDoneTasks").'
'.$langs->trans("LastDoneTasks",$max).'
'; @@ -262,7 +251,9 @@ if ($_GET["action"] == 'create') print ''; */ print ''; + print ''; - /* - * - */ print ''; print "\n"; print "
'.$langs->trans("SalesRepresentativeFollowUp").''; print '
'.$langs->trans("SalesRepresentativeSignature").''; print '
'.$langs->trans("Comment").''; - print '

\n"; @@ -374,8 +363,8 @@ if ($_GET["action"] == 'create') if ($propalid) { /* - * Produits - */ + * Produits + */ print_titre($langs->trans("Products")); print ''; @@ -403,9 +392,10 @@ if ($_GET["action"] == 'create') $i++; } } - $sql = "SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent"; - $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt WHERE pt.fk_propal = $propalid AND pt.fk_product = 0"; - $sql .= " ORDER BY pt.rowid ASC"; + $sql = "SELECT pt.rowid, pt.description as product, pt.price, pt.qty, pt.remise_percent"; + $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pt"; + $sql.= " WHERE pt.fk_propal = $propalid AND pt.fk_product = 0"; + $sql.= " ORDER BY pt.rowid ASC"; $result=$db->query($sql); if ($result) { @@ -490,7 +480,7 @@ else if ($_GET["action"] == 'valid') { //$numfa = contrat_get_num($soc); - $html->form_confirm("fiche.php?id=$id",$langs->trans("ValidateAContract"),"Etes-vous sûr de vouloir valider cette contrat ?","confirm_valid"); + $html->form_confirm("fiche.php?id=$id",$langs->trans("ValidateAContract"),$langs->trans("ConfirmValidateContract"),"confirm_valid"); print '
'; } @@ -647,15 +637,13 @@ else print ''; } - if ($objp->fk_product > 0) { - print ''; - } else { - // Si non ligne de service (Ne devrait pas arriver) - print ''; - } + // Statut + print ''; + print "\n"; // Dates mise en service @@ -693,9 +681,10 @@ else } else print $langs->trans("Unknown"); } + // Si désactivé if ($objp->date_debut_reelle && $objp->date_fin_reelle) { print $langs->trans("DateEndReal").': '; - dolibarr_print_date($objp->date_fin_reelle); + print dolibarr_print_date($objp->date_fin_reelle); } print ''; print ''; @@ -708,7 +697,10 @@ else print ''; // Ligne carac print ""; - print ''; + print ''; print ''; print ''; print ''; @@ -739,12 +731,8 @@ else /* * Ajouter une ligne produit/service */ - if ($user->rights->contrat->creer) + if ($user->rights->contrat->creer && $contrat->statut == 0) { - print ''; - print ''; - print ''; - print ""; print ''; print ''; @@ -755,30 +743,55 @@ else print ''; print "\n"; - /* - print "".''; - print ''; - print ''; - print ''; - print ''; - - print ''; - */ - $var=false; + + print ''; + print ''; + print ''; + print ''; + print ""; - print ''; - print ''; + print ''; print ''; print ''; - print "\n"; + print ""; - print ''; + print ''; + print ''; + + print ''; + + print ""; + + $var=!$var; + + print ''; + print ''; + print ''; + print ''; + + print ""; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + + print "\n"; + print ''; print ""; @@ -803,37 +816,20 @@ else * Boutons Actions *************************************************************/ - if ($user->societe_id == 0 && $contrat->statut < 3) + if ($user->societe_id == 0) { print '
'; - if ($contrat->statut == 0 && $user->rights->contrat->supprimer) + if ($contrat->statut == 0 && $num) + { + print ''.$langs->trans("Valid").''; + } + + if ($user->rights->contrat->supprimer) { print ''.$langs->trans("Delete").''; } - if ($contrat->statut > 0 && $contrat->statut < 3 && $user->rights->expedition->creer) - { - print ''.$langs->trans("Send").''; - } - - if ($contrat->statut == 0) - { - if ($user->rights->contrat->valider) - { - print ''.$langs->trans("Valid").''; - } - } - - if ($contrat->statut == 1) - { - $nb_expedition = $contrat->nb_expedition(); - if ($user->rights->contrat->valider && $nb_expedition == 0) - { - print ''.$langs->trans("Cancel").''; - } - } - print "
"; } diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 59e7322e9f8..c7215342e27 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -29,6 +29,7 @@ */ require("./pre.inc.php"); +require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); $langs->load("products"); $langs->load("companies"); @@ -67,10 +68,8 @@ print '
 '; - print '';; - print 'statut'; - print ' '; + if ($contrat->statut == 1) print '';; + print 'statut'; + if ($contrat->statut == 1) print ''; + print '
 
'; + print ''; + print img_object($langs->trans("ShowService"),"service").' '.$objp->label.'
'; + print '
%
'.$langs->trans("Service").''.$langs->trans("VAT").' 
'; - print $html->select_tva("tva_tx",$conf->defaulttx); - print ' %
'; - $html->select_produits('','p_idprod'); + print ''; + $html->select_produits('','p_idprod','',0); print ' %
'; + print 'Date prévue mise en service '; + $html->select_date('',"date_start",0,0,1); + print '   Date prévue fin de service '; + $html->select_date('',"date_end",0,0,1); + print '
'; + $html->select_tva("tva_tx",$conf->defaulttx); + print '%
'; print ''; print ''; print '
'.$langs->trans("Legend").'
'; print 'statut Statut initial
'; -print 'statut A commander
'; -print 'statut Commandé chez le fournisseur
'; -print 'statut Activé chez le fournisseur
'; -print 'statut Activé chez le client
'; +print 'statut '.$langs->trans("ContractStatusRunning").'
'; +print 'statut '.$langs->trans("Closed").'
'; print '
'; @@ -92,10 +91,64 @@ if ($conf->contrat->enabled) { print ''; + +// Last contracts +$max=5; +$sql = "SELECT count(cd.rowid) as nb, c.rowid as cid, c.datec, c.statut, s.nom, s.idp as sidp"; +$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; +$sql.= " WHERE c.fk_soc = s.idp "; +if ($socid > 0) $sql .= " AND s.idp = $socid"; +$sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.idp"; +$sql.= " ORDER BY c.date_contrat DESC"; +$sql.= " LIMIT $max"; + +$result=$db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $i = 0; + + print ''; + + print ''; + print "\n"; + + $contratstatic=new Contrat($db); + + $var=True; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var=!$var; + + print ""; + print "'; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $i++; + } + $db->free($result); + + print "
'.$langs->trans("LastContracts",5).'
cid\">"; + print img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.''.$langs->trans("ServicesNomberShort",$obj->nb).''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''.dolibarr_print_date($obj->datec).''.$contratstatic->LibStatut($obj->statut).'
"; + +} +else +{ + dolibarr_print_error($db); +} + +print '
'; + + // Not activated services $sql = "SELECT cd.rowid as cid, cd.statut, cd.label, cd.description as note, cd.fk_contrat, c.fk_soc, s.nom"; $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; -$sql.= " WHERE cd.statut IN (0,3)"; +$sql.= " WHERE c.statut=1 AND cd.statut = 0"; $sql.= " AND cd.fk_contrat = c.rowid AND c.fk_soc = s.idp"; $sql.= " ORDER BY cd.tms DESC"; diff --git a/htdocs/contrat/ligne.php b/htdocs/contrat/ligne.php index 0e18f618d70..d1118b48c40 100644 --- a/htdocs/contrat/ligne.php +++ b/htdocs/contrat/ligne.php @@ -18,14 +18,13 @@ * * $Id$ * $Source$ - * */ /** - \file htdocs/contrat/ligne.php - \ingroup contrat - \brief Fiche contrat - \version $Revision$ + \file htdocs/contrat/ligne.php + \ingroup contrat + \brief Fiche contrat + \version $Revision$ */ require("./pre.inc.php"); @@ -37,7 +36,7 @@ $langs->load("companies"); $user->getrights('contrat'); if (!$user->rights->contrat->lire) - accessforbidden(); +accessforbidden(); require("../project.class.php"); require("../propal.class.php"); @@ -46,16 +45,16 @@ require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); /* * Sécurité accés client */ -if ($user->societe_id > 0) +if ($user->societe_id > 0) { - $action = ''; - $socidp = $user->societe_id; + $action = ''; + $socidp = $user->societe_id; } /* * Actions - */ + */ if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) { $contrat = new Contrat($db); @@ -68,8 +67,29 @@ if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user- Header("Location: fiche.php?id=".$contrat->id); exit; } + else { + $mesg=$contrat->error; + } } +if ($_POST["action"] == 'confirm_close' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer) +{ + $contrat = new Contrat($db); + $contrat->fetch($_GET["id"]); + + $result = $contrat->close_line($user, $_GET["ligne"], $_GET["dateend"]); + + if ($result > 0) + { + Header("Location: fiche.php?id=".$contrat->id); + exit; + } + else { + $mesg=$contrat->error; + } +} + + llxHeader('',$langs->trans("Contract"),"Contrat"); @@ -80,288 +100,340 @@ $html = new Form($db); /* Mode vue et edition */ /* */ /* *************************************************************************** */ - - $id = $_GET["id"]; - if ($id > 0) + +$id = $_GET["id"]; +if ($id > 0) +{ + $contrat = New Contrat($db); + if ( $contrat->fetch($id) > 0) { - $contrat = New Contrat($db); - if ( $contrat->fetch($id) > 0) - { - $author = new User($db); - $author->id = $contrat->user_author_id; - $author->fetch(); + $author = new User($db); + $author->id = $contrat->user_author_id; + $author->fetch(); - $commercial_signature = new User($db); - $commercial_signature->id = $contrat->commercial_signature_id; - $commercial_signature->fetch(); + $commercial_signature = new User($db); + $commercial_signature->id = $contrat->commercial_signature_id; + $commercial_signature->fetch(); - $commercial_suivi = new User($db); - $commercial_suivi->id = $contrat->commercial_suivi_id; - $commercial_suivi->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"); - $h++; + $h = 0; + $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; + $head[$h][1] = $langs->trans("ContractCard"); + $h++; - $head[$h][0] = DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id."&ligne=".$_GET["ligne"]; - $head[$h][1] = $langs->trans($langs->trans("EditServiceLine")); - $hselected = $h; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id); + $head[$h][0] = DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id."&ligne=".$_GET["ligne"]; + $head[$h][1] = $langs->trans($langs->trans("EditServiceLine")); + $hselected = $h; + + dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id); - /* - * Contrat - */ + /* + * Contrat + */ - print ''; + print '
'; - // Reference du contrat - print '"; + // Reference du contrat + print '"; - // Customer - print ""; - print ''; - - // Status - print '"; - - // Date - print ''; - print '\n"; + // Customer + print ""; + print ''; - if ($conf->projet->enabled) - { - print '"; - } + // Status + print '"; - print ''; - print ''; - print "
'.$langs->trans("Ref").''; - print $contrat->ref; - print "
'.$langs->trans("Ref").''; + print $contrat->ref; + print "
".$langs->trans("Customer")."'; - print ''.$contrat->societe->nom.'
'.$langs->trans("Status").''; - print $contrat->statuts[$contrat->statut]; - print "
'.$langs->trans("Date").''.strftime("%A %d %B %Y",$contrat->date_contrat)."
".$langs->trans("Customer")."'; + print ''.$contrat->societe->nom.'
'.$langs->trans("Project").''; - if ($contrat->projet_id > 0) - { - $projet = New Project($db); - $projet->fetch($contrat->projet_id); - print ''.$projet->title.''; - } - else - { - print 'Classer le contrat'; - } - print "
'.$langs->trans("Status").''; + print $contrat->statuts[$contrat->statut]; + print "
'.$langs->trans("SalesRepresentativeFollowUp").''.$commercial_suivi->fullname.''.$langs->trans("SalesRepresentativeSignature").''.$commercial_signature->fullname.'
"; - - - /* - * Confirmation de la validation - * - */ - if ($_GET["action"] == 'active' && $user->rights->contrat->activer) - { - print '
'; - $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - $html->form_confirm("ligne.php?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend,$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",strftime("%A %d %B %Y", $dateactstart)),"confirm_active"); - } + // Date + print ''.$langs->trans("Date").''; + print ''.strftime("%A %d %B %Y",$contrat->date_contrat)."\n"; - - /* - * Lignes de contrats - * - */ - print '
'; + if ($conf->projet->enabled) + { + print '"; + } - $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.= " AND rowid = ".$_GET["ligne"]; - $sql.= " ORDER BY cd.rowid"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $total = 0; - - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($result); + print ''; + print ''; + print "
'.$langs->trans("Project").''; + if ($contrat->projet_id > 0) + { + $projet = New Project($db); + $projet->fetch($contrat->projet_id); + print ''.$projet->title.''; + } + else + { + print 'Classer le contrat'; + } + print "
'.$langs->trans("Service").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("Discount").'  '.$langs->trans("Status").'
'.$langs->trans("SalesRepresentativeFollowUp").''.$commercial_suivi->fullname.''.$langs->trans("SalesRepresentativeSignature").''.$commercial_signature->fullname.'
"; - $var=!$var; - print "\n"; - // Libellé - if ($objp->fk_product > 0) - { - print ''.img_object($langs->trans("ShowService"),"service").' '.$objp->label.''; + /* + * Confirmation de la validation activation + */ + if ($_GET["action"] == 'active' && $user->rights->contrat->activer) + { + print '
'; + $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + $html->form_confirm("ligne.php?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend,$langs->trans("ActivateService"),$langs->trans("ConfirmActivateService",strftime("%A %d %B %Y", $dateactstart)),"confirm_active"); + } - if ($objp->description) - { - print '
'.stripslashes(nl2br($objp->description)); - } + /* + * Confirmation de la validation fermeture + */ + if ($_GET["action"] == 'close' && $user->rights->contrat->activer) + { + print '
'; + $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + $html->form_confirm("ligne.php?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateactstart."&dateend=".$dateactend,$langs->trans("CloseService"),$langs->trans("ConfirmCloseService",strftime("%A %d %B %Y", $dateactstart)),"confirm_close"); + } - print ''; - } - else - { - print ' '.stripslashes(nl2br($objp->description))."\n"; - } - print ''.$objp->tva_tx.'%'; - print ''.price($objp->subprice)."\n"; + /* + * Lignes de contrats + */ + print '
'; - print ''; + $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.= " AND rowid = ".$_GET["ligne"]; + $sql.= " ORDER BY cd.rowid"; - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; $total = 0; - print ''; + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($result); - if ($objp->fk_product > 0) { - print ''; - } else { - print ''; - } + $var=!$var; + print "\n"; - print "\n"; + // Libell + if ($objp->fk_product > 0) + { + print ''; - print ''; + } + else + { + print '\n"; + } + print ''; + + print '\n"; + + print ''; + + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { print ''; - print ''; - + } - $i++; - } - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - - print '
'.$objp->qty.''.$objp->remise_percent."%   
'.$langs->trans("Service").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("Discount").'  '.$langs->trans("Status").'
statut 
'.img_object($langs->trans("ShowService"),"service").' '.$objp->label.''; - if ($objp->date_debut) $dateactstart=$objp->date_debut; - if ($objp->date_fin) $dateactend=$objp->date_fin; - - // Dates mise en service - print '
'; - // 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"); + if ($objp->description) + { + print '
'.stripslashes(nl2br($objp->description)); } - print '  -  '; - - // Si pas encore activé - if (! $objp->date_debut_reelle) { - print $langs->trans("DateEndPlanned").': '; - if ($objp->date_fin) { - print dolibarr_print_date($objp->date_fin); - } - else print $langs->trans("Unknown"); - } - // Si activé - if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { - print $langs->trans("DateEndPlanned").': '; - if ($objp->date_fin) { - print dolibarr_print_date($objp->date_fin); - if ($objp->date_fin < time()) { print " ".img_warning($langs->trans("Late")); } - } - else print $langs->trans("Unknown"); - } - if ($objp->date_debut_reelle && $objp->date_fin_reelle) { - print $langs->trans("DateEndReal").': '; - dolibarr_print_date($objp->date_fin_reelle); - } print '
 '.stripslashes(nl2br($objp->description))."'.$objp->tva_tx.'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."% 

'; - print ''; + print '  '; - if ( $user->rights->contrat->activer && $contrat->statut == 0 && $objp->statut <> 4) - { - /** - * Activer la ligne de contrat - */ - $form = new Form($db); - - print ''; + } + else + { + print ''; + } - print '
'; - - print ''; + if ($objp->fk_product > 0) + { + print 'statut 
'; - print ''; + print "\n"; - // Definie date debut et fin par defaut - if ($_POST["remonth"]) $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - elseif (! $dateactstart) $dateactstart = time(); + if ($objp->date_debut) $dateactstart=$objp->date_debut; + if ($objp->date_fin) $dateactend=$objp->date_fin; - if ($_POST["endmonth"]) $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - elseif (! $dateactend) { - if ($objp->fk_product > 0) { - $product=new Product($db); - $product->fetch($objp->fk_product); - $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); - } - } + // Dates mise en service + print ''; + print ''; + print '  -  '; - print ''; + // Si pas encore activ + if (! $objp->date_debut_reelle) { + print $langs->trans("DateEndPlanned").': '; + if ($objp->date_fin) { + print dolibarr_print_date($objp->date_fin); + } + else print $langs->trans("Unknown"); + } + // Si activ + if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) { + print $langs->trans("DateEndPlanned").': '; + if ($objp->date_fin) { + print dolibarr_print_date($objp->date_fin); + if ($objp->date_fin < time()) { print " ".img_warning($langs->trans("Late")); } + } + else print $langs->trans("Unknown"); + } + if ($objp->date_debut_reelle && $objp->date_fin_reelle) { + print $langs->trans("DateEndReal").': '; + dolibarr_print_date($objp->date_fin_reelle); + } + print ''; + print ''; + print ''; - print ''; - print ''; - print '
'.$langs->trans("ActivateService").'
'; + // 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"); + } - print '
'.$langs->trans("DateServiceActivate").''; - print $form->select_date($dateactstart); - print '
'.$langs->trans("DateEndPlanned").''; - print $form->select_date($dateactend,"end"); - print '
 
'.$langs->trans("Comment").'
'; - - print '
'; - } - } + $i++; + } + $db->free($result); + } + else + { + dolibarr_print_error($db); + } + + print '
'; + print ''; + + if ($user->rights->contrat->activer && $contrat->statut == 1 && $objp->statut <> 4) + { + /** + * Activer la ligne de contrat + */ + $form = new Form($db); + + print '
'; + + print '
'; + + print ''; + print ''; + + // Definie date debut et fin par defaut + if ($_POST["remonth"]) $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + elseif (! $dateactstart) $dateactstart = time(); + + if ($_POST["endmonth"]) $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + elseif (! $dateactend) + { + if ($objp->fk_product > 0) + { + $product=new Product($db); + $product->fetch($objp->fk_product); + $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); + } + } + + print ''; + + print ''; + + print ''; + + print ''; + print '
'.$langs->trans("ActivateService").'
'.$langs->trans("DateServiceActivate").''; + print $form->select_date($dateactstart); + print '
'.$langs->trans("DateEndPlanned").''; + print $form->select_date($dateactend,"end"); + print '
'.$langs->trans("Comment").'
'; + + print '

'; + } + + if ($user->rights->contrat->activer && $contrat->statut == 1 && $objp->statut == 4) + { + /** + * Désactiver la ligne de contrat + */ + $form = new Form($db); + + print '
'; + + print ''; + print ''; + + // Definie date debut et fin par defaut + if ($_POST["remonth"]) $dateactstart = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + elseif (! $dateactstart) $dateactstart = time(); + + if ($_POST["endmonth"]) $dateactend = mktime(12, 0 , 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + elseif (! $dateactend) + { + if ($objp->fk_product > 0) + { + $product=new Product($db); + $product->fetch($objp->fk_product); + $dateactend = dolibarr_time_plus_duree (time(), $product->duration_value, $product->duration_unit); + } + } + + print ''; + + print ''; + print '
'.$langs->trans("CloseService").'
'.$langs->trans("DateEndReal").''; + print $form->select_date($dateactend,"end"); + print '
'; + + print '

'; + } + + } else - { - /* Contrat non trouvée */ - print "Contrat inexistant ou accés refusé"; - } - } + { + /* Contrat non trouvée */ + print "Contrat inexistant ou accés refusé"; + } +} $db->close(); diff --git a/htdocs/contrat/liste.php b/htdocs/contrat/liste.php index 267f701e5e5..30299f2244c 100644 --- a/htdocs/contrat/liste.php +++ b/htdocs/contrat/liste.php @@ -29,6 +29,7 @@ */ require("./pre.inc.php"); +require_once (DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); $langs->load("contracts"); $langs->load("products"); @@ -91,9 +92,12 @@ if ($resql) print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","",'width="50"',$sortfield); print_liste_field_titre($langs->trans("NbOfServices"), $_SERVER["PHP_SELF"], "nb",'','','width="80"',$sortfield); print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"], "s.nom","","","",$sortfield); - print_liste_field_titre($langs->trans("DateCreation"), $_SERVER["PHP_SELF"], "c.datec","","","",$sortfield); + print_liste_field_titre($langs->trans("DateCreation"), $_SERVER["PHP_SELF"], "c.datec","","",'align="center"',$sortfield); + print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "c.statut","","",'align="center"',$sortfield); print "\n"; + $contratstatic=new Contrat($db); + $now=mktime(); $var=True; while ($i < min($num,$limit)) @@ -105,7 +109,8 @@ if ($resql) print img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.''; print ''.$obj->nb.''; print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''; - print ''.dolibarr_print_date($obj->datec).''; + print ''.dolibarr_print_date($obj->datec).''; + print ''.$contratstatic->LibStatut($obj->statut).''; print "\n"; $i++; diff --git a/htdocs/contrat/statut5.png b/htdocs/contrat/statut5.png new file mode 100644 index 0000000000000000000000000000000000000000..671dd99c7b16284fa572768069e72ea8beeb9329 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k_7YEDSN5yyOycZTY+5JPfkK=G z9+AaBEo(rS@jcrycc36kx}&cn1H;CC?mvmFKz_KVi(^Q|t*H|Oxeh4sIA7lIJAUUO z1Ls(+Tk@{=f-kc*9C5Y1mGW+HM@2Z-HAmLhPJQ|onJwxEJ+*C83nra*jk)H3!F-iZ q$%l1