diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index 203b06a3b2b..853bc9080ef 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -36,15 +36,42 @@ class Contrat $this->db = $DB ; $this->product = new Product($DB); $this->societe = new Societe($DB); + $this->user_service = new User($DB); + $this->user_cloture = new User($DB); } /* * * * */ - Function fetch ($id) + Function mise_en_service($user) + { + $sql = "UPDATE llx_contrat SET enservice = 1"; + $sql .= " , mise_en_service = now(), fk_user_mise_en_service = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; + + $result = $this->db->query($sql) ; + } + /* + * + * + */ + Function cloture($user) + { + $sql = "UPDATE llx_contrat SET enservice = 2"; + $sql .= " , date_cloture = now(), fk_user_cloture = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; + + $result = $this->db->query($sql) ; + } + /* + * + * + */ Function fetch ($id) { - $sql = "SELECT rowid, enservice, fk_soc, fk_product"; + $sql = "SELECT rowid, enservice, fk_soc, fk_product, ".$this->db->pdate("mise_en_service")." as datemise"; + $sql .= ", fk_user_mise_en_service, ".$this->db->pdate("date_cloture")." as datecloture"; + $sql .= ", fk_user_cloture"; $sql .= " FROM llx_contrat WHERE rowid = $id"; $result = $this->db->query($sql) ; @@ -55,8 +82,12 @@ class Contrat $this->id = $result["rowid"]; $this->enservice = $result["enservice"]; + $this->mise_en_service = $result["datemise"]; + $this->date_cloture = $result["datecloture"]; $this->product->fetch($result["fk_product"]); $this->societe->fetch($result["fk_soc"]); + $this->user_service->id = $result["fk_user_mise_en_service"]; + $this->user_cloture->id = $result["fk_user_cloture"]; $this->db->free(); } else diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index bf0e949d84f..c3f43e86593 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -37,6 +37,20 @@ if ($action == 'add') $action = ''; } +if ($action == 'miseenservice') +{ + $contrat = new Contrat($db); + $contrat->id = $id; + $contrat->mise_en_service($user); +} + +if ($action == 'cloture') +{ + $contrat = new Contrat($db); + $contrat->id = $id; + $contrat->cloture($user); +} + if ($action == 'update' && $cancel <> 'Annuler') { $product = new Product($db); @@ -111,9 +125,9 @@ else print ''; print ""; - print ''; - print ''; + print ''; - print ''; - print ''; + print ''; - print ""; + print ""; + $contrat->user_service->fetch(); + print ''; - if ($product->type == 1) + if ($contrat->enservice == 2) { - print ''; + print ""; + $contrat->user_cloture->fetch(); + print ''; } + print "
Service'.$product->ref.''; - if ($product->enservice) + print 'Service'.$contrat->product->label_url.''; + if ($contrat->enservice) { print "En service"; } @@ -122,36 +136,20 @@ else print "Ce contrat n'est pas en service"; } print '
Société'.$contrat->societe->nom_url.'Statistiques
Société'.$contrat->societe->nom_url.'
Description".nl2br($product->description)."
Mis en service".strftime("%A %e %B %Y à %H:%M",$contrat->mise_en_service)."par'.$contrat->user_service->fullname.'
Durée'.$product->duration_value.' '; - if ($product->duration_value > 1) - { - $plu = "s"; - } - switch ($product->duration_unit) - { - case "d": - print "jour$plu "; - break; - case "w": - print "semaine$plu "; - break; - case "m": - print 'mois '; - break; - case "y": - print "an$plu "; - break; - } - print '
Cloturé".strftime("%A %e %B %Y à %H:%M",$contrat->date_cloture)."par'.$contrat->user_cloture->fullname.'
"; } @@ -218,135 +216,26 @@ else print '
'; print ''; -print ''; -print ''; -if ($action == 'create') +if ($contrat->enservice) { print ''; } else { - print ''; + print ''; } -print ''; -print '
----[Editer][Mise en service]-

'; - -if ($id && $action == '' && $product->envente) +print '-'; +print '-'; +if ($contrat->enservice == 1) { - - $htmls = new Form($db); - $propal = New Propal($db); - - print ''; - - print ''; - print ''; - - print ''; - print '
'; - print_titre("Ajouter ma proposition"); - print ''; - print_titre("Ajouter aux autres propositions"); - print '
'; - $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price - p.remise as price, p.ref,".$db->pdate("p.datep")." as dp"; - $sql .= " FROM llx_societe as s, llx_propal as p"; - $sql .=" WHERE p.fk_soc = s.idp AND p.fk_statut = 0 AND p.fk_user_author = ".$user->id; - $sql .= " ORDER BY p.datec DESC, tms DESC"; - - if ( $db->query($sql) ) - { - $num = $db->num_rows(); - $i = 0; - print ''; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print '"; - print ''; - $i++; - } - print "
propalid\">$objp->refidp\">$objp->nom". strftime("%d %B %Y",$objp->dp)."
'; - print ''; - print ''; - print ''; - print "
"; - $db->free(); - } - - print '
'; - - $otherprop = $propal->liste_array(1, '<>'.$user->id); - if (sizeof($otherprop)) - { - print '
'; - print ''; - print ''; - print ""; - print '
Autres Propositions"; - $htmls->select_array("propalid", $otherprop); - print ''; - print ''; - print ''; - print ''; - print "
'; - } - print '
'; - print_titre("Ajouter ma facture"); - print ''; - print_titre("Ajouter aux autres factures"); - print '
'; - $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; - $sql .= " FROM llx_societe as s, llx_facture as f"; - $sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author = ".$user->id; - $sql .= " ORDER BY f.datec DESC, f.rowid DESC"; - - if ( $db->query($sql) ) - { - $num = $db->num_rows(); - $i = 0; - print ''; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print '"; - print ''; - $i++; - } - print "
factureid\">$objp->facnumberidp\">$objp->nom". strftime("%d %B %Y",$objp->df)."
'; - print ''; - print ''; - print ''; - print "
"; - $db->free(); - } - else - { - print $db->error() . "
" . $sql; - } - print '
'; - print '
'; - + print '[Clôturer]'; } - +else +{ + print '-'; +} +print '
'; $db->close();