New: Ajout gestion tat validation des contrats
This commit is contained in:
parent
bcaf531dc5
commit
61063d7309
@ -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 '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("LastDoneTasks").'</td></tr>';
|
||||
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("LastDoneTasks",$max).'</td></tr>';
|
||||
$var = true;
|
||||
$i = 0;
|
||||
|
||||
|
||||
@ -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"); }
|
||||
}
|
||||
|
||||
|
||||
@ -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 '<form action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="soc_id" value="'.$soc->id.'">' ."\n";
|
||||
print '<input type="hidden" name="soc_id" value="'.$soc->id.'">'."\n";
|
||||
print '<input type="hidden" name="remise_percent" value="0">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
@ -262,7 +251,9 @@ if ($_GET["action"] == 'create')
|
||||
print '<tr><td width="20%" nowrap>'.$langs->trans("SalesRepresentativeFollowUp").'</td><td>';
|
||||
print '<select name="commercial_suivi_id">';
|
||||
print '<option value="-1"> </option>';
|
||||
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user ORDER BY name ";
|
||||
|
||||
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user";
|
||||
$sql.= " ORDER BY name ";
|
||||
$resql=$db->query( $sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -286,7 +277,8 @@ if ($_GET["action"] == 'create')
|
||||
print '<tr><td width="20%" nowrap>'.$langs->trans("SalesRepresentativeSignature").'</td><td>';
|
||||
print '<select name="commercial_signature_id">';
|
||||
print '<option value="-1"> </option>';
|
||||
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user ORDER BY name ";
|
||||
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user";
|
||||
$sql.= " ORDER BY name";
|
||||
$resql=$db->query( $sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -362,11 +354,8 @@ if ($_GET["action"] == 'create')
|
||||
print '</td></tr>';
|
||||
*/
|
||||
print '<tr><td>'.$langs->trans("Comment").'</td><td valign="top">';
|
||||
print '<textarea name="note" wrap="soft" cols="60" rows="4"></textarea></td></tr>';
|
||||
print '<textarea name="note" wrap="soft" cols="60" rows="3"></textarea></td></tr>';
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
|
||||
print "</form>\n";
|
||||
print "</table><br>\n";
|
||||
@ -374,8 +363,8 @@ if ($_GET["action"] == 'create')
|
||||
if ($propalid)
|
||||
{
|
||||
/*
|
||||
* Produits
|
||||
*/
|
||||
* Produits
|
||||
*/
|
||||
print_titre($langs->trans("Products"));
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
@ -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 '<br>';
|
||||
}
|
||||
|
||||
@ -647,15 +637,13 @@ else
|
||||
print '<td colspan="2"> </td>';
|
||||
}
|
||||
|
||||
if ($objp->fk_product > 0) {
|
||||
print '<td align="center">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id.'&ligne='.$objp->rowid.'">';;
|
||||
print '<img src="./statut'.$objp->statut.'.png" border="0" alt="statut"></a>';
|
||||
print '</td>';
|
||||
} else {
|
||||
// Si non ligne de service (Ne devrait pas arriver)
|
||||
print '<td> </td>';
|
||||
}
|
||||
// Statut
|
||||
print '<td align="center">';
|
||||
if ($contrat->statut == 1) print '<a href="'.DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id.'&ligne='.$objp->rowid.'">';;
|
||||
print '<img src="./statut'.$objp->statut.'.png" border="0" alt="statut">';
|
||||
if ($contrat->statut == 1) print '</a>';
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\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 '</td>';
|
||||
print '<td> </td>';
|
||||
@ -708,7 +697,10 @@ else
|
||||
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">';
|
||||
// Ligne carac
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td colspan="2"><textarea name="eldesc" cols="60" rows="2">'.$objp->description.'</textarea></td>';
|
||||
print '<td colspan="2">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
||||
print img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a><br>';
|
||||
print '<textarea name="eldesc" cols="60" rows="1">'.$objp->description.'</textarea></td>';
|
||||
print '<td align="right"><input size="6" type="text" name="elprice" value="'.price($objp->subprice).'"></td>';
|
||||
print '<td align="center"><input size="3" type="text" name="elqty" value="'.$objp->qty.'"></td>';
|
||||
print '<td align="right"><input size="3" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
|
||||
@ -739,12 +731,8 @@ else
|
||||
/*
|
||||
* Ajouter une ligne produit/service
|
||||
*/
|
||||
if ($user->rights->contrat->creer)
|
||||
if ($user->rights->contrat->creer && $contrat->statut == 0)
|
||||
{
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td>'.$langs->trans("Service").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VAT").'</td>';
|
||||
@ -755,30 +743,55 @@ else
|
||||
print '<td> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
/*
|
||||
print "<tr $bc[$var]>".'<td><textarea name="desc" cols="60" rows="1"></textarea></td>';
|
||||
print '<td align="center">';
|
||||
print $html->select_tva("tva_tx",$conf->defaulttx);
|
||||
print '</td>';
|
||||
print '<td align="center"><input type="text" name="qty" value="1" size="2"></td>';
|
||||
print '<td align="right"><input type="text" name="remise_percent" size="4" value="0"> %</td>';
|
||||
print '<td align="right"><input type="text" name="pu" size="8"></td>';
|
||||
|
||||
print '<td align="center" colspan="3"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
|
||||
*/
|
||||
|
||||
$var=false;
|
||||
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
print '<input type="hidden" name="mode" value="predefined">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td colspan="2">';
|
||||
$html->select_produits('','p_idprod');
|
||||
print '<td colspan="3">';
|
||||
$html->select_produits('','p_idprod','',0);
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
|
||||
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>';
|
||||
print '<td align="right" nowrap><input type="text" class="flat" size="2" name="premise" value="0">%</td>';
|
||||
print '<td align="center" colspan="3" rowspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td colspan="7"><textarea name="desc" cols="60" rows="1"></textarea></td>';
|
||||
print '<td colspan="8">';
|
||||
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 '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
print "</form>";
|
||||
|
||||
$var=!$var;
|
||||
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
print '<input type="hidden" name="mode" value="libre">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><textarea name="desc" cols="50" rows="1"></textarea></td>';
|
||||
|
||||
print '<td>';
|
||||
$html->select_tva("tva_tx",$conf->defaulttx);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" class="flat" size="4" name="pu" value=""></td>';
|
||||
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>';
|
||||
print '<td align="right" nowrap><input type="text" class="flat" size="2" name="premise" value="0">%</td>';
|
||||
print '<td align="center" colspan="3" rowspan="2"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
print '</tr>';
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
@ -803,37 +816,20 @@ else
|
||||
* Boutons Actions
|
||||
*************************************************************/
|
||||
|
||||
if ($user->societe_id == 0 && $contrat->statut < 3)
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($contrat->statut == 0 && $user->rights->contrat->supprimer)
|
||||
if ($contrat->statut == 0 && $num)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->contrat->supprimer)
|
||||
{
|
||||
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)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/contrat.php?id='.$_GET["id"].'">'.$langs->trans("Send").'</a>';
|
||||
}
|
||||
|
||||
if ($contrat->statut == 0)
|
||||
{
|
||||
if ($user->rights->contrat->valider)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($contrat->statut == 1)
|
||||
{
|
||||
$nb_expedition = $contrat->nb_expedition();
|
||||
if ($user->rights->contrat->valider && $nb_expedition == 0)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$id.'&action=annuler">'.$langs->trans("Cancel").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
|
||||
@ -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 '<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 '<img src="./statut4.png" border="0" alt="statut"> '.$langs->trans("ContractStatusRunning").'<br />';
|
||||
print '<img src="./statut5.png" border="0" alt="statut"> '.$langs->trans("Closed").'<br />';
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
@ -92,10 +91,64 @@ if ($conf->contrat->enabled) {
|
||||
|
||||
print '</td><td width="70%" valign="top">';
|
||||
|
||||
|
||||
// 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 '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("LastContracts",5).'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$contratstatic=new Contrat($db);
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
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 align="center">'.$langs->trans("ServicesNomberShort",$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 align="center">'.dolibarr_print_date($obj->datec).'</td>';
|
||||
print '<td align="center">'.$contratstatic->LibStatut($obj->statut).'</td>';
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
|
||||
print "</table>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
// 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";
|
||||
|
||||
|
||||
@ -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 '<table class="border" width="100%">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Reference du contrat
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $contrat->ref;
|
||||
print "</td></tr>";
|
||||
// Reference du contrat
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $contrat->ref;
|
||||
print "</td></tr>";
|
||||
|
||||
// Customer
|
||||
print "<tr><td>".$langs->trans("Customer")."</td>";
|
||||
print '<td colspan="3">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$contrat->societe->id.'">'.$contrat->societe->nom.'</a></b></td></tr>';
|
||||
|
||||
// Status
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
|
||||
print $contrat->statuts[$contrat->statut];
|
||||
print "</td></tr>";
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="3">'.strftime("%A %d %B %Y",$contrat->date_contrat)."</td></tr>\n";
|
||||
// Customer
|
||||
print "<tr><td>".$langs->trans("Customer")."</td>";
|
||||
print '<td colspan="3">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$contrat->societe->id.'">'.$contrat->societe->nom.'</a></b></td></tr>';
|
||||
|
||||
if ($conf->projet->enabled)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
|
||||
if ($contrat->projet_id > 0)
|
||||
{
|
||||
$projet = New Project($db);
|
||||
$projet->fetch($contrat->projet_id);
|
||||
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$contrat->projet_id.'">'.$projet->title.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="fiche.php?id='.$id.'&action=classer">Classer le contrat</a>';
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
// Status
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
|
||||
print $contrat->statuts[$contrat->statut];
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("SalesRepresentativeFollowUp").'</td><td>'.$commercial_suivi->fullname.'</td>';
|
||||
print '<td width="25%">'.$langs->trans("SalesRepresentativeSignature").'</td><td>'.$commercial_signature->fullname.'</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'active' && $user->rights->contrat->activer)
|
||||
{
|
||||
print '<br />';
|
||||
$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 '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="3">'.strftime("%A %d %B %Y",$contrat->date_contrat)."</td></tr>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Lignes de contrats
|
||||
*
|
||||
*/
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
if ($conf->projet->enabled)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
|
||||
if ($contrat->projet_id > 0)
|
||||
{
|
||||
$projet = New Project($db);
|
||||
$projet->fetch($contrat->projet_id);
|
||||
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$contrat->projet_id.'">'.$projet->title.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="fiche.php?id='.$id.'&action=classer">Classer le contrat</a>';
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
$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 '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Service").'</td>';
|
||||
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>';
|
||||
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>';
|
||||
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td width="50" align="right">'.$langs->trans("Discount").'</td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="30" align="center">'.$langs->trans("Status").'</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
print '<tr><td width="25%">'.$langs->trans("SalesRepresentativeFollowUp").'</td><td>'.$commercial_suivi->fullname.'</td>';
|
||||
print '<td width="25%">'.$langs->trans("SalesRepresentativeSignature").'</td><td>'.$commercial_signature->fullname.'</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var] valign=\"top\">\n";
|
||||
|
||||
// Libellé
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a>';
|
||||
/*
|
||||
* Confirmation de la validation activation
|
||||
*/
|
||||
if ($_GET["action"] == 'active' && $user->rights->contrat->activer)
|
||||
{
|
||||
print '<br />';
|
||||
$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 '<br />'.stripslashes(nl2br($objp->description));
|
||||
}
|
||||
/*
|
||||
* Confirmation de la validation fermeture
|
||||
*/
|
||||
if ($_GET["action"] == 'close' && $user->rights->contrat->activer)
|
||||
{
|
||||
print '<br />';
|
||||
$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 '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td><td>'.stripslashes(nl2br($objp->description))."</td>\n";
|
||||
}
|
||||
print '<td align="center">'.$objp->tva_tx.'%</td>';
|
||||
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
/*
|
||||
* Lignes de contrats
|
||||
*/
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
|
||||
print '<td align="center">'.$objp->qty.'</td>';
|
||||
$sql = "SELECT cd.statut, cd.label, cd.fk_product, cd.description, cd.price_ht, cd.qty, cd.rowid, cd.tva_tx, cd.remise_percent, cd.subprice,";
|
||||
$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 '<td align="right">'.$objp->remise_percent."%</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0; $total = 0;
|
||||
|
||||
print '<td> </td><td> </td>';
|
||||
if ($num)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Service").'</td>';
|
||||
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>';
|
||||
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>';
|
||||
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td width="50" align="right">'.$langs->trans("Discount").'</td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="30" align="center">'.$langs->trans("Status").'</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
if ($objp->fk_product > 0) {
|
||||
print '<td align="center"><img src="./statut'.$objp->statut.'.png" border="0" alt="statut"></td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var] valign=\"top\">\n";
|
||||
|
||||
print "</tr>\n";
|
||||
// Libell
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a>';
|
||||
|
||||
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 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");
|
||||
if ($objp->description)
|
||||
{
|
||||
print '<br />'.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 '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td><td>'.stripslashes(nl2br($objp->description))."</td>\n";
|
||||
}
|
||||
print '<td align="center">'.$objp->tva_tx.'%</td>';
|
||||
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
|
||||
print '<td align="center">'.$objp->qty.'</td>';
|
||||
|
||||
if ($objp->remise_percent > 0)
|
||||
{
|
||||
print '<td align="right">'.$objp->remise_percent."%</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
print '</div>';
|
||||
print '<td> </td><td> </td>';
|
||||
|
||||
if ( $user->rights->contrat->activer && $contrat->statut == 0 && $objp->statut <> 4)
|
||||
{
|
||||
/**
|
||||
* Activer la ligne de contrat
|
||||
*/
|
||||
$form = new Form($db);
|
||||
|
||||
print '<table class="noborder"><tr><td>';
|
||||
|
||||
print '<form action="ligne.php?id='.$contrat->id.'&ligne='.$_GET["ligne"].'&action=active" method="post">';
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
print '<td align="center"><img src="./statut'.$objp->statut.'.png" border="0" alt="statut"></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ActivateService").'</td></tr>';
|
||||
print "</tr>\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 '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="7">';
|
||||
// Si pas encore activ
|
||||
if (! $objp->date_debut_reelle) {
|
||||
print $langs->trans("DateStartPlanned").': ';
|
||||
if ($objp->date_debut) print dolibarr_print_date($objp->date_debut);
|
||||
else print $langs->trans("Unknown");
|
||||
}
|
||||
// Si activ
|
||||
if ($objp->date_debut_reelle) {
|
||||
print $langs->trans("DateStartReal").': ';
|
||||
if ($objp->date_debut_reelle) print dolibarr_print_date($objp->date_debut_reelle);
|
||||
else print $langs->trans("ContractStatusNotRunning");
|
||||
}
|
||||
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("DateServiceActivate").'</td><td>';
|
||||
print $form->select_date($dateactstart);
|
||||
print '</td></tr>';
|
||||
print ' - ';
|
||||
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("DateEndPlanned").'</td><td>';
|
||||
print $form->select_date($dateactend,"end");
|
||||
print '</td></tr>';
|
||||
// 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 '<td> </td>';
|
||||
print '</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 '</table>';
|
||||
|
||||
print '</form><br></td></tr></table>';
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
print '</div>';
|
||||
|
||||
if ($user->rights->contrat->activer && $contrat->statut == 1 && $objp->statut <> 4)
|
||||
{
|
||||
/**
|
||||
* Activer la ligne de contrat
|
||||
*/
|
||||
$form = new Form($db);
|
||||
|
||||
print '<table class="noborder"><tr><td>';
|
||||
|
||||
print '<form action="ligne.php?id='.$contrat->id.'&ligne='.$_GET["ligne"].'&action=active" method="post">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ActivateService").'</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>';
|
||||
print '</table>';
|
||||
|
||||
print '</form><br></td></tr></table>';
|
||||
}
|
||||
|
||||
if ($user->rights->contrat->activer && $contrat->statut == 1 && $objp->statut == 4)
|
||||
{
|
||||
/**
|
||||
* Désactiver la ligne de contrat
|
||||
*/
|
||||
$form = new Form($db);
|
||||
|
||||
print '<form action="ligne.php?id='.$contrat->id.'&ligne='.$_GET["ligne"].'&action=close" method="post">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("CloseService").'</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("DateEndReal").'</td><td>';
|
||||
print $form->select_date($dateactend,"end");
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Close").'"></td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</form><br></td></tr></table>';
|
||||
}
|
||||
|
||||
}
|
||||
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();
|
||||
|
||||
|
||||
@ -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 "</tr>\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.'</a></td>';
|
||||
print '<td align="center">'.$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 '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
|
||||
print '<td align="center">'.$contratstatic->LibStatut($obj->statut).'</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
|
||||
BIN
htdocs/contrat/statut5.png
Normal file
BIN
htdocs/contrat/statut5.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 200 B |
Loading…
Reference in New Issue
Block a user