Distingue les dates de mises en services prvues des rels dans la gestion des contrats
This commit is contained in:
parent
3157c28cb0
commit
250718b637
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -120,18 +120,22 @@ 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 d'ouverture
|
||||
*/
|
||||
function active_line($user, $line_id, $date)
|
||||
* \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 d'ouverture
|
||||
* \param date Date fin prévue
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function active_line($user, $line_id, $date, $dateend='')
|
||||
{
|
||||
// statut actif : 4
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4";
|
||||
$sql .= " , date_ouverture = '".$this->db->idate($date)."', fk_user_ouverture = ".$user->id;
|
||||
$sql .= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3) ";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4,";
|
||||
$sql.= " date_ouverture = '".$this->db->idate($date)."',";
|
||||
if ($dateend) $sql.= " date_fin_validite = '".$this->db->idate($dateend)."',";
|
||||
$sql.= " fk_user_ouverture = ".$user->id;
|
||||
$sql.= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3) ";
|
||||
|
||||
$result = $this->db->query($sql) ;
|
||||
|
||||
@ -143,7 +147,7 @@ class Contrat
|
||||
$interface->run_triggers('CONTRACT_SERVICE_ACTIVATE',$this,$user,$lang,$conf);
|
||||
// Fin appel triggers
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -251,10 +255,11 @@ class Contrat
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Crée un contrat vierge
|
||||
* \param user Utilisateur qui crée
|
||||
* \param lang Environnement langue de l'utilisateur
|
||||
* \param conf Environnement de configuration lors de l'opération
|
||||
* \brief Crée un contrat vierge en base
|
||||
* \param user Utilisateur qui crée
|
||||
* \param lang Environnement langue de l'utilisateur
|
||||
* \param conf Environnement de configuration lors de l'opération
|
||||
* \return int < 0 si erreur, id contrat créé sinon
|
||||
*/
|
||||
function create($user,$lang='',$conf='')
|
||||
{
|
||||
@ -271,19 +276,48 @@ class Contrat
|
||||
$interface->run_triggers('CONTRACT_CREATE',$this,$user,$lang,$conf);
|
||||
// Fin appel triggers
|
||||
|
||||
$result = 0 ;
|
||||
$result = $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 1;
|
||||
dolibarr_syslog("Contrat::create - 10");
|
||||
dolibarr_print_error($this->db,"Contrat::create - 10");
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Supprime un contrat de la base
|
||||
* \param user Utilisateur qui supprime
|
||||
* \param lang Environnement langue de l'utilisateur
|
||||
* \param conf Environnement de configuration lors de l'opération
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function delete($user,$lang='',$conf='')
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$interface->run_triggers('CONTRACT_DELETE',$this,$user,$lang,$conf);
|
||||
// Fin appel triggers
|
||||
|
||||
$result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = -1;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Ajoute une ligne de commande
|
||||
* \return int <0 si KO, =0 si OK
|
||||
|
||||
@ -86,7 +86,7 @@ if ($resql)
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Ref"),"enservice.php", "c.rowid","","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Contract"),"enservice.php", "c.rowid","","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),"enservice.php", "cd.statut","","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Service"),"enservice.php", "p.label","","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Company"),"enservice.php", "s.nom","","","",$sortfield);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -62,12 +62,33 @@ print '<table class="noborder" width="100%">';
|
||||
print '<tr><td width="30%" valign="top">';
|
||||
|
||||
// Légende
|
||||
print 'Légende<br />';
|
||||
$var=false;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Legend").'</td></tr>';
|
||||
print '<tr '.$bc[$var].'><td nowrap>';
|
||||
print '<img src="./statut0.png" border="0" alt="statut"> Statut initial<br />';
|
||||
print '<img src="./statut1.png" border="0" alt="statut"> A commander<br />';
|
||||
print '<img src="./statut2.png" border="0" alt="statut"> Commandé chez le fournisseur<br />';
|
||||
print '<img src="./statut3.png" border="0" alt="statut"> Activé chez le fournisseur<br />';
|
||||
print '<img src="./statut4.png" border="0" alt="statut"> Activé chez le client<br />';
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
/*
|
||||
* Recherche Contrat
|
||||
*/
|
||||
if ($conf->contrat->enabled) {
|
||||
$var=false;
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/contrat/liste.php">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAContract").'</td></tr>';
|
||||
print '<tr '.$bc[$var].'><td nowrap>';
|
||||
print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="search_contract" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
|
||||
print "</table></form><br>\n";
|
||||
}
|
||||
|
||||
|
||||
print '</td><td width="70%" valign="top">';
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/contrat/fiche.php
|
||||
\file htdocs/contrat/ligne.php
|
||||
\ingroup contrat
|
||||
\brief Fiche contrat
|
||||
\version $Revision$
|
||||
@ -51,53 +51,23 @@ if ($user->societe_id > 0)
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
if ($_POST["action"] == 'add')
|
||||
{
|
||||
$datecontrat = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
|
||||
$contrat = new Contrat($db);
|
||||
|
||||
$contrat->soc_id = $_POST["soc_id"];
|
||||
$contrat->date_contrat = $datecontrat;
|
||||
$contrat->commercial_id = $_POST["commercial"];
|
||||
$contrat->note = $_POST["note"];
|
||||
$contrat->projetid = $_POST["projetid"];
|
||||
$contrat->remise_percent = $_POST["remise_percent"];
|
||||
|
||||
/*
|
||||
$contrat->add_product($_POST["idprod1"],$_POST["qty1"],$_POST["remise_percent1"]);
|
||||
$contrat->add_product($_POST["idprod2"],$_POST["qty2"],$_POST["remise_percent2"]);
|
||||
$contrat->add_product($_POST["idprod3"],$_POST["qty3"],$_POST["remise_percent3"]);
|
||||
$contrat->add_product($_POST["idprod4"],$_POST["qty4"],$_POST["remise_percent4"]);
|
||||
*/
|
||||
$result = $contrat->create($user);
|
||||
if ($result == 0)
|
||||
{
|
||||
Header("Location: fiche.php?id=".$contrat->id);
|
||||
}
|
||||
|
||||
$_GET["id"] = $contrat->id;
|
||||
|
||||
$action = '';
|
||||
}
|
||||
/*
|
||||
*
|
||||
* Actions
|
||||
*/
|
||||
if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer)
|
||||
{
|
||||
$contrat = new Contrat($db);
|
||||
$contrat->fetch($_GET["id"]);
|
||||
$contrat = new Contrat($db);
|
||||
$contrat->fetch($_GET["id"]);
|
||||
|
||||
$result = $contrat->active_line($user, $_GET["ligne"], $_GET["date"]);
|
||||
$result = $contrat->active_line($user, $_GET["ligne"], $_GET["date"], $_GET["dateend"]);
|
||||
|
||||
if ($result == 0)
|
||||
if ($result > 0)
|
||||
{
|
||||
Header("Location: fiche.php?id=".$contrat->id);
|
||||
Header("Location: fiche.php?id=".$contrat->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -196,8 +166,9 @@ $html = new Form($db);
|
||||
if ($_GET["action"] == 'active' && $user->rights->contrat->activer)
|
||||
{
|
||||
print '<br />';
|
||||
$dateact = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
$html->form_confirm("ligne.php?id=".$contrat->id."&ligne=".$_GET["ligne"]."&date=".$dateact,"Activer le service","Etes-vous sûr de vouloir activer ce service en date du ".strftime("%A %d %B %Y", $dateact)." ?","confirm_active");
|
||||
$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");
|
||||
}
|
||||
|
||||
|
||||
@ -207,17 +178,18 @@ $html = new Form($db);
|
||||
*/
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
|
||||
$sql = "SELECT l.statut, l.label, l.fk_product, l.description, l.price_ht, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as l";
|
||||
$sql .= " WHERE l.fk_contrat = ".$id;
|
||||
$sql .= " AND rowid = ".$_GET["ligne"];
|
||||
$sql .= " ORDER BY l.rowid";
|
||||
$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();
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0; $total = 0;
|
||||
|
||||
if ($num)
|
||||
@ -232,10 +204,10 @@ $html = new Form($db);
|
||||
print '<td> </td><td width="10%"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=True;
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object();
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>\n";
|
||||
@ -270,11 +242,57 @@ $html = new Form($db);
|
||||
print '<td> </td><td> </td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
if ($objp->date_debut) $dateactstart=$objp->date_debut;
|
||||
if ($objp->date_fin) $dateactend=$objp->date_fin;
|
||||
|
||||
// Dates mise en service
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td> </td>';
|
||||
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");
|
||||
}
|
||||
|
||||
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 '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -297,22 +315,30 @@ $html = new Form($db);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ActivateService").'</td></tr>';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("DateServiceActivate").'</td><td>';
|
||||
|
||||
if ($_POST["remonth"])
|
||||
{
|
||||
$dateact = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$dateact = time();
|
||||
}
|
||||
|
||||
print $form->select_date($dateact);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("User").'</td><td>'.$user->fullname.'</td></tr>';
|
||||
|
||||
// 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 '<tr '.$bc[$var].'><td>'.$langs->trans("DateServiceActivate").'</td><td>';
|
||||
print $form->select_date($dateactstart);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("DateEndPlanned").'</td><td>';
|
||||
print $form->select_date($dateactend,"end");
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("Comment").'</td><td><input size="50" type="text" name="commentaire"></td></tr>';
|
||||
|
||||
print '<tr '.$bc[$var].'><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Activate").'"></td></tr>';
|
||||
@ -324,7 +350,7 @@ $html = new Form($db);
|
||||
else
|
||||
{
|
||||
/* Contrat non trouvée */
|
||||
print "Contrat inexistante ou accés refusé";
|
||||
print "Contrat inexistant ou accés refusé";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -62,9 +62,10 @@ if ($user->societe_id > 0)
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT c.rowid as cid, c.statut, ".$db->pdate("c.fin_validite")." as fin_validite, c.fin_validite-sysdate() as delairestant, s.nom, s.idp as sidp";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE c.fk_soc = s.idp ";
|
||||
$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 ($_POST["search_contract"]) {
|
||||
$sql .= " AND c.rowid = ".$_POST["search_contract"];
|
||||
}
|
||||
@ -72,8 +73,9 @@ if ($socid > 0)
|
||||
{
|
||||
$sql .= " AND s.idp = $socid";
|
||||
}
|
||||
$sql .= " ORDER BY $sortfield $sortorder, delairestant";
|
||||
$sql .= $db->plimit($limit + 1 ,$offset);
|
||||
$sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.idp";
|
||||
$sql.= " ORDER BY $sortfield $sortorder";
|
||||
$sql.= $db->plimit($limit + 1 ,$offset);
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
@ -87,7 +89,9 @@ if ($resql)
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("NbOfServices"), $_SERVER["PHP_SELF"], "nb","","","",$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 "</tr>\n";
|
||||
|
||||
$now=mktime();
|
||||
@ -99,7 +103,9 @@ if ($resql)
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td><a href=\"fiche.php?id=$obj->cid\">";
|
||||
print img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.'</a></td>';
|
||||
print '<td>'.$obj->nb.'</td>';
|
||||
print '<td><a href="../comm/fiche.php?socid='.$obj->sidp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
|
||||
print '<td>'.dolibarr_print_date($obj->datec).'</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
@ -117,5 +123,5 @@ else
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user