Distingue les dates de mises en services prévues des réels dans la gestion des contrats
This commit is contained in:
parent
3157c28cb0
commit
250718b637
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Destailleur Laurent <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -124,14 +124,18 @@ class Contrat
|
|||||||
* \param user Objet User qui avtice le contrat
|
* \param user Objet User qui avtice le contrat
|
||||||
* \param line_id Id de la ligne de detail à activer
|
* \param line_id Id de la ligne de detail à activer
|
||||||
* \param date Date d'ouverture
|
* \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)
|
function active_line($user, $line_id, $date, $dateend='')
|
||||||
{
|
{
|
||||||
// statut actif : 4
|
// statut actif : 4
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4,";
|
||||||
$sql .= " , date_ouverture = '".$this->db->idate($date)."', fk_user_ouverture = ".$user->id;
|
$sql.= " date_ouverture = '".$this->db->idate($date)."',";
|
||||||
$sql .= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3) ";
|
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) ;
|
$result = $this->db->query($sql) ;
|
||||||
|
|
||||||
@ -143,7 +147,7 @@ class Contrat
|
|||||||
$interface->run_triggers('CONTRACT_SERVICE_ACTIVATE',$this,$user,$lang,$conf);
|
$interface->run_triggers('CONTRACT_SERVICE_ACTIVATE',$this,$user,$lang,$conf);
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -251,10 +255,11 @@ class Contrat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Crée un contrat vierge
|
* \brief Crée un contrat vierge en base
|
||||||
* \param user Utilisateur qui crée
|
* \param user Utilisateur qui crée
|
||||||
* \param lang Environnement langue de l'utilisateur
|
* \param lang Environnement langue de l'utilisateur
|
||||||
* \param conf Environnement de configuration lors de l'opération
|
* \param conf Environnement de configuration lors de l'opération
|
||||||
|
* \return int < 0 si erreur, id contrat créé sinon
|
||||||
*/
|
*/
|
||||||
function create($user,$lang='',$conf='')
|
function create($user,$lang='',$conf='')
|
||||||
{
|
{
|
||||||
@ -271,13 +276,42 @@ class Contrat
|
|||||||
$interface->run_triggers('CONTRACT_CREATE',$this,$user,$lang,$conf);
|
$interface->run_triggers('CONTRACT_CREATE',$this,$user,$lang,$conf);
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
$result = 0 ;
|
$result = $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result = 1;
|
|
||||||
dolibarr_syslog("Contrat::create - 10");
|
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;
|
return $result;
|
||||||
|
|||||||
@ -86,7 +86,7 @@ if ($resql)
|
|||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
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("Status"),"enservice.php", "cd.statut","","","",$sortfield);
|
||||||
print_liste_field_titre($langs->trans("Service"),"enservice.php", "p.label","","","",$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);
|
print_liste_field_titre($langs->trans("Company"),"enservice.php", "s.nom","","","",$sortfield);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ $langs->load("companies");
|
|||||||
$user->getrights('contrat');
|
$user->getrights('contrat');
|
||||||
|
|
||||||
if (!$user->rights->contrat->lire)
|
if (!$user->rights->contrat->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
require("../project.class.php");
|
require("../project.class.php");
|
||||||
require("../propal.class.php");
|
require("../propal.class.php");
|
||||||
@ -75,7 +75,7 @@ if ($_POST["action"] == 'add')
|
|||||||
$contrat->add_product($_POST["idprod3"],$_POST["qty3"],$_POST["remise_percent3"]);
|
$contrat->add_product($_POST["idprod3"],$_POST["qty3"],$_POST["remise_percent3"]);
|
||||||
$contrat->add_product($_POST["idprod4"],$_POST["qty4"],$_POST["remise_percent4"]);
|
$contrat->add_product($_POST["idprod4"],$_POST["qty4"],$_POST["remise_percent4"]);
|
||||||
*/
|
*/
|
||||||
$result = $contrat->create($user);
|
$result = $contrat->create($user,$lang,$conf);
|
||||||
if ($result == 0)
|
if ($result == 0)
|
||||||
{
|
{
|
||||||
Header("Location: fiche.php?id=".$contrat->id);
|
Header("Location: fiche.php?id=".$contrat->id);
|
||||||
@ -85,20 +85,14 @@ if ($_POST["action"] == 'add')
|
|||||||
|
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if ($_POST["action"] == 'classin')
|
if ($_POST["action"] == 'classin')
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$contrat = new Contrat($db);
|
||||||
$commande->fetch($_GET["id"]);
|
$contrat->fetch($_GET["id"]);
|
||||||
$commande->classin($_POST["projetid"]);
|
$contrat->classin($_POST["projetid"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
|
if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
$result = 0;
|
$result = 0;
|
||||||
@ -172,18 +166,19 @@ if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->r
|
|||||||
|
|
||||||
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes)
|
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes)
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->supprimer )
|
if ($user->rights->contrat->supprimer )
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$contrat = new Contrat($db);
|
||||||
$commande->id = $_GET["id"];
|
$contrat->id = $_GET["id"];
|
||||||
$commande->delete();
|
$contrat->delete($user,$lang,$conf);
|
||||||
Header("Location: index.php");
|
Header("Location: index.php");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if ($action == 'pdf')
|
if ($action == 'pdf')
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -204,8 +199,7 @@ $html = new Form($db);
|
|||||||
*
|
*
|
||||||
* Mode creation
|
* Mode creation
|
||||||
*
|
*
|
||||||
*
|
*********************************************************************/
|
||||||
************************************************************************/
|
|
||||||
if ($_GET["action"] == 'create')
|
if ($_GET["action"] == 'create')
|
||||||
{
|
{
|
||||||
dolibarr_fiche_head($head, $a, $langs->trans("AddContract"));
|
dolibarr_fiche_head($head, $a, $langs->trans("AddContract"));
|
||||||
@ -430,26 +424,25 @@ else
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la suppression de la contrat
|
* Confirmation de la suppression de la contrat
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
$html->form_confirm("fiche.php?id=$id","Supprimer la contrat","Etes-vous sûr de vouloir supprimer cette contrat ?","confirm_delete");
|
$html->form_confirm("fiche.php?id=$id",$langs->trans("DeleteAContract"),$langs->trans("ConfirmDeleteAContract"),"confirm_delete");
|
||||||
|
print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la validation
|
* Confirmation de la validation
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'valid')
|
if ($_GET["action"] == 'valid')
|
||||||
{
|
{
|
||||||
//$numfa = contrat_get_num($soc);
|
//$numfa = contrat_get_num($soc);
|
||||||
$html->form_confirm("fiche.php?id=$id","Valider la contrat","Etes-vous sûr de vouloir valider cette contrat ?","confirm_valid");
|
$html->form_confirm("fiche.php?id=$id",$langs->trans("ValidateAContract"),"Etes-vous sûr de vouloir valider cette contrat ?","confirm_valid");
|
||||||
|
print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de l'annulation
|
* Confirmation de l'annulation
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'annuler')
|
if ($_GET["action"] == 'annuler')
|
||||||
{
|
{
|
||||||
@ -459,7 +452,6 @@ else
|
|||||||
/*
|
/*
|
||||||
* Contrat
|
* Contrat
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($contrat->brouillon == 1 && $user->rights->contrat->creer)
|
if ($contrat->brouillon == 1 && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||||
@ -520,20 +512,21 @@ else
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes de contrats
|
* Lignes de contrats
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
echo '<br><table class="noborder" width="100%">';
|
echo '<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 = "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 .= " FROM ".MAIN_DB_PREFIX."contratdet as l";
|
$sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_debut, ".$db->pdate("cd.date_ouverture")." as date_debut_reelle,";
|
||||||
$sql .= " WHERE l.fk_contrat = ".$id;
|
$sql.= " ".$db->pdate("cd.date_fin_validite")." as date_fin, ".$db->pdate("cd.date_cloture")." as date_fin_reelle";
|
||||||
$sql .= " ORDER BY l.rowid";
|
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
|
||||||
|
$sql.= " WHERE cd.fk_contrat = ".$id;
|
||||||
|
$sql.= " ORDER BY cd .rowid";
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows($result);
|
||||||
$i = 0; $total = 0;
|
$i = 0; $total = 0;
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
@ -548,13 +541,13 @@ else
|
|||||||
print '<td> </td><td> </td>';
|
print '<td> </td><td> </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
$var=True;
|
$var=true;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object();
|
$objp = $db->fetch_object($result);
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]>\n";
|
print '<tr '.$bc[$var].'>';
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<td>';
|
print '<td>';
|
||||||
@ -586,8 +579,9 @@ else
|
|||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Icon delete
|
|
||||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||||
|
|
||||||
|
// Icon delete
|
||||||
if ($contrat->statut == 0 && $objp->statut == 0 && $user->rights->contrat->creer)
|
if ($contrat->statut == 0 && $objp->statut == 0 && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
// print '<td align="right"><a href="fiche.php?id='.$id.'&action=editline&rowid='.$objp->rowid.'">';
|
// print '<td align="right"><a href="fiche.php?id='.$id.'&action=editline&rowid='.$objp->rowid.'">';
|
||||||
@ -603,6 +597,48 @@ else
|
|||||||
}
|
}
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// 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>';
|
||||||
|
|
||||||
if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid)
|
if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid)
|
||||||
{
|
{
|
||||||
@ -631,7 +667,6 @@ else
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Ajouter une ligne produit/service
|
* Ajouter une ligne produit/service
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($user->rights->contrat->creer)
|
if ($user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
@ -681,30 +716,33 @@ else
|
|||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
/*
|
/*
|
||||||
* Fin Ajout ligne
|
* Fin Ajout ligne
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
/*************************************************************
|
||||||
|
* Boutons Actions
|
||||||
|
*************************************************************/
|
||||||
|
|
||||||
if ($user->societe_id == 0 && $contrat->statut < 3)
|
if ($user->societe_id == 0 && $contrat->statut < 3)
|
||||||
{
|
{
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if ($contrat->statut == 0 && $user->rights->contrat->supprimer)
|
if ($contrat->statut == 0 && $user->rights->contrat->supprimer)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contrat->statut > 0 && $contrat->statut < 3 && $user->rights->expedition->creer)
|
if ($contrat->statut > 0 && $contrat->statut < 3 && $user->rights->expedition->creer)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/expedition/contrat.php?id='.$_GET["id"].'">'.$langs->trans("Send").'</a>';
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/contrat.php?id='.$_GET["id"].'">'.$langs->trans("Send").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contrat->statut == 0)
|
if ($contrat->statut == 0)
|
||||||
{
|
{
|
||||||
if ($user->rights->contrat->valider)
|
if ($user->rights->contrat->valider)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,14 +751,12 @@ else
|
|||||||
$nb_expedition = $contrat->nb_expedition();
|
$nb_expedition = $contrat->nb_expedition();
|
||||||
if ($user->rights->contrat->valider && $nb_expedition == 0)
|
if ($user->rights->contrat->valider && $nb_expedition == 0)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=annuler">'.$langs->trans("Cancel").'</a>';
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=annuler">'.$langs->trans("Cancel").'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
}
|
}
|
||||||
print "<p>\n";
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -740,10 +776,7 @@ else
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
print '<tr><td colspan="2" align="center"><input type="submit" value="Envoyer"></td></tr></table></form>';
|
print '<tr><td colspan="2" align="center"><input type="submit" value="Envoyer"></td></tr></table></form>';
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -755,5 +788,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
llxFooter('$Date$ - $Revision$');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -62,12 +62,33 @@ print '<table class="noborder" width="100%">';
|
|||||||
print '<tr><td width="30%" valign="top">';
|
print '<tr><td width="30%" valign="top">';
|
||||||
|
|
||||||
// Légende
|
// 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="./statut0.png" border="0" alt="statut"> Statut initial<br />';
|
||||||
print '<img src="./statut1.png" border="0" alt="statut"> A commander<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="./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="./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 '<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">';
|
print '</td><td width="70%" valign="top">';
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/contrat/fiche.php
|
\file htdocs/contrat/ligne.php
|
||||||
\ingroup contrat
|
\ingroup contrat
|
||||||
\brief Fiche contrat
|
\brief Fiche contrat
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
@ -51,53 +51,23 @@ if ($user->societe_id > 0)
|
|||||||
$action = '';
|
$action = '';
|
||||||
$socidp = $user->societe_id;
|
$socidp = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
* Actions
|
||||||
*/
|
|
||||||
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 = '';
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer)
|
if ($_POST["action"] == 'confirm_active' && $_POST["confirm"] == 'yes' && $user->rights->contrat->activer)
|
||||||
{
|
{
|
||||||
$contrat = new Contrat($db);
|
$contrat = new Contrat($db);
|
||||||
$contrat->fetch($_GET["id"]);
|
$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)
|
if ($_GET["action"] == 'active' && $user->rights->contrat->activer)
|
||||||
{
|
{
|
||||||
print '<br />';
|
print '<br />';
|
||||||
$dateact = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
$dateactstart = 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");
|
$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%">';
|
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 = "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 .= " FROM ".MAIN_DB_PREFIX."contratdet as l";
|
$sql.= " ".$db->pdate("cd.date_ouverture_prevue")." as date_debut, ".$db->pdate("cd.date_ouverture")." as date_debut_reelle,";
|
||||||
$sql .= " WHERE l.fk_contrat = ".$id;
|
$sql.= " ".$db->pdate("cd.date_fin_validite")." as date_fin, ".$db->pdate("cd.date_cloture")." as date_fin_reelle";
|
||||||
$sql .= " AND rowid = ".$_GET["ligne"];
|
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
|
||||||
$sql .= " ORDER BY l.rowid";
|
$sql.= " WHERE cd.fk_contrat = ".$id;
|
||||||
|
$sql.= " AND rowid = ".$_GET["ligne"];
|
||||||
|
$sql.= " ORDER BY cd.rowid";
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows($result);
|
||||||
$i = 0; $total = 0;
|
$i = 0; $total = 0;
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
@ -232,10 +204,10 @@ $html = new Form($db);
|
|||||||
print '<td> </td><td width="10%"> </td>';
|
print '<td> </td><td width="10%"> </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
$var=True;
|
$var=true;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object();
|
$objp = $db->fetch_object($result);
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]>\n";
|
print "<tr $bc[$var]>\n";
|
||||||
@ -271,10 +243,56 @@ $html = new Form($db);
|
|||||||
|
|
||||||
print "</tr>\n";
|
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++;
|
$i++;
|
||||||
}
|
}
|
||||||
$db->free();
|
$db->free($result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -297,22 +315,30 @@ $html = new Form($db);
|
|||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ActivateService").'</td></tr>';
|
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>';
|
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>'.$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>';
|
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
|
else
|
||||||
{
|
{
|
||||||
/* Contrat non trouvée */
|
/* 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 = "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.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s";
|
||||||
$sql .= " WHERE c.fk_soc = s.idp ";
|
$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"]) {
|
if ($_POST["search_contract"]) {
|
||||||
$sql .= " AND c.rowid = ".$_POST["search_contract"];
|
$sql .= " AND c.rowid = ".$_POST["search_contract"];
|
||||||
}
|
}
|
||||||
@ -72,8 +73,9 @@ if ($socid > 0)
|
|||||||
{
|
{
|
||||||
$sql .= " AND s.idp = $socid";
|
$sql .= " AND s.idp = $socid";
|
||||||
}
|
}
|
||||||
$sql .= " ORDER BY $sortfield $sortorder, delairestant";
|
$sql.= " GROUP BY c.rowid, c.datec, c.statut, s.nom, s.idp";
|
||||||
$sql .= $db->plimit($limit + 1 ,$offset);
|
$sql.= " ORDER BY $sortfield $sortorder";
|
||||||
|
$sql.= $db->plimit($limit + 1 ,$offset);
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -87,7 +89,9 @@ if ($resql)
|
|||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","","",$sortfield);
|
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("Company"), $_SERVER["PHP_SELF"], "s.nom","","","",$sortfield);
|
||||||
|
print_liste_field_titre($langs->trans("DateCreation"), $_SERVER["PHP_SELF"], "c.datec","","","",$sortfield);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$now=mktime();
|
$now=mktime();
|
||||||
@ -99,7 +103,9 @@ if ($resql)
|
|||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print "<td><a href=\"fiche.php?id=$obj->cid\">";
|
print "<td><a href=\"fiche.php?id=$obj->cid\">";
|
||||||
print img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.'</a></td>';
|
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><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";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
@ -117,5 +123,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
llxFooter('$Date$ - $Revision$');
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user