Fix: Debuggage des contrats, traductions et amliorations mineures.

This commit is contained in:
Laurent Destailleur 2005-04-22 22:39:11 +00:00
parent 1bfd900de0
commit ec78498e2f
8 changed files with 406 additions and 315 deletions

View File

@ -29,7 +29,8 @@
*/
/** \class Contrat
/**
\class Contrat
\brief Classe permettant la gestion des contrats
*/
@ -158,47 +159,50 @@ class Contrat
/**
* \brief Charge de la base les données du contrat
* \param id id du contrat à charger
* \return int <0 si KO, >0 si OK
*/
function fetch ($id)
{
$sql = "SELECT rowid, statut, fk_soc, ".$this->db->pdate("mise_en_service")." as datemise";
$sql .= ", fk_user_mise_en_service, ".$this->db->pdate("date_contrat")." as datecontrat";
$sql .= " , fk_user_author";
$sql .= ", fk_commercial_signature, fk_commercial_suivi ";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat WHERE rowid = $id";
$sql = "SELECT rowid, statut, fk_soc, ".$this->db->pdate("mise_en_service")." as datemise";
$sql .= ", fk_user_mise_en_service, ".$this->db->pdate("date_contrat")." as datecontrat";
$sql .= " , fk_user_author";
$sql .= ", fk_commercial_signature, fk_commercial_suivi ";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat WHERE rowid = $id";
$resql = $this->db->query($sql) ;
if ($resql)
{
$result = $this->db->fetch_array($resql);
$this->id = $result["rowid"];
$this->statut = $result["statut"];
$this->factureid = $result["fk_facture"];
$this->facturedetid = $result["fk_facturedet"];
$this->mise_en_service = $result["datemise"];
$this->date_fin_validite = $result["datefin"];
$this->date_contrat = $result["datecontrat"];
$this->user_author_id = $result["fk_user_author"];
$this->commercial_signature_id = $result["fk_commercial_signature"];
$this->commercial_suivi_id = $result["fk_commercial_suivi"];
$this->user_service->id = $result["fk_user_mise_en_service"];
$this->user_cloture->id = $result["fk_user_cloture"];
$this->societe->fetch($result["fk_soc"]);
$this->db->free($resql);
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
$result = $this->db->query($sql) ;
if ( $result )
{
$result = $this->db->fetch_array();
$this->id = $result["rowid"];
$this->statut = $result["statut"];
$this->factureid = $result["fk_facture"];
$this->facturedetid = $result["fk_facturedet"];
$this->mise_en_service = $result["datemise"];
$this->date_fin_validite = $result["datefin"];
$this->date_contrat = $result["datecontrat"];
$this->user_author_id = $result["fk_user_author"];
$this->commercial_signature_id = $result["fk_commercial_signature"];
$this->commercial_suivi_id = $result["fk_commercial_suivi"];
$this->user_service->id = $result["fk_user_mise_en_service"];
$this->user_cloture->id = $result["fk_user_cloture"];
$this->societe->fetch($result["fk_soc"]);
$this->db->free();
}
else
{
dolibarr_print_error($this->db);
}
return $result;
}
/**
@ -282,58 +286,63 @@ class Contrat
/**
* \brief Ajoute une ligne de commande
*
* \return int <0 si KO, =0 si OK
*/
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0)
{
global $langs;
$qty = ereg_replace(",",".",$qty);
$pu = ereg_replace(",",".",$pu);
if (strlen(trim($desc)))
{
if (strlen(trim($qty))==0)
{
$qty=1;
}
if ($fk_product > 0)
{
$prod = new Product($this->db, $fk_product);
if ($prod->fetch($fk_product) > 0)
{
$label = $prod->libelle;
$pu = $prod->price;
$txtva = $prod->tva_tx;
}
}
$remise = 0;
$price = round(ereg_replace(",",".",$pu), 2);
$subprice = $price;
if (trim(strlen($remise_percent)) > 0)
{
$remise = round(($pu * $remise_percent / 100), 2);
$price = $pu - $remise;
}
// 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 .= " VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',$fk_product,".ereg_replace(",",".",$price).", '$qty', $txtva, $remise_percent,'".ereg_replace(",",".",$subprice)."','".ereg_replace(",",".", $remise)."') ;";
// Retour
if ( $this->db->query( $sql) )
{
//$this->update_price();
return 0;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
if (! trim($desc))
{
$this->error=$langs->trans("ErrorDescRequired");
return -1;
}
if (strlen(trim($qty))==0)
{
$qty=1;
}
if ($fk_product > 0)
{
$prod = new Product($this->db, $fk_product);
if ($prod->fetch($fk_product) > 0)
{
$label = $prod->libelle;
$pu = $prod->price;
$txtva = $prod->tva_tx;
}
}
$remise = 0;
$price = round(ereg_replace(",",".",$pu), 2);
$subprice = $price;
if (trim(strlen($remise_percent)) > 0)
{
$remise = round(($pu * $remise_percent / 100), 2);
$price = $pu - $remise;
}
// 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 .= " VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',$fk_product,".ereg_replace(",",".",$price).", '$qty', $txtva, $remise_percent,'".ereg_replace(",",".",$subprice)."','".ereg_replace(",",".", $remise)."') ;";
// Retour
if ( $this->db->query( $sql) )
{
//$this->update_price();
return 0;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
/**

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2005 Laurent Destailleur <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
@ -21,7 +21,7 @@
*
*/
/*!
/**
\file htdocs/contrat/enservice.php
\ingroup contrat
\brief Page liste des contrats en service
@ -57,18 +57,12 @@ if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if ($sortfield == "")
{
$sortfield="cd.date_ouverture";
}
if (! $sortfield) $sortfield="cd.date_ouverture";
if (! $sortorder) $sortorder="DESC";
if ($sortorder == "")
{
$sortorder="DESC";
}
$sql = "SELECT s.nom, c.rowid as cid, p.rowid as pid, s.idp as sidp, cd.label, cd.statut";
$sql .= " ,".$db->pdate("cd.date_ouverture")." as date_ouverture";
$sql = "SELECT s.nom, c.rowid as cid, s.idp as sidp, cd.rowid, cd.label, cd.statut, p.rowid as pid,";
$sql .= " ".$db->pdate("cd.date_ouverture")." as date_ouverture";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product as p";
$sql .= " , ".MAIN_DB_PREFIX."contratdet as cd";
@ -81,40 +75,41 @@ if ($socid > 0)
$sql .= " ORDER BY $sortfield $sortorder";
$sql .= $db->plimit($limit + 1 ,$offset);
if ( $db->query($sql) )
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows();
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste("Liste des contrats en service", $page, "enservice.php", "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
print_barre_liste($langs->trans("ListOfRunningContractsLines"), $page, "enservice.php", "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
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("Label"),"enservice.php", "p.label","","","",$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);
print '<td align="center">Date mise en service</td>';
print_liste_field_titre($langs->trans("Date"),"enservice.php", "cd.date_ouverture",'','',' align="center"',$sortfield);
print "</tr>\n";
$now=mktime();
$var=True;
while ($i < min($num,$limit))
{
$obj = $db->fetch_object();
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$obj->cid\">";
print '<img src="./statut'.$obj->statut.'.png" border="0" alt="statut">';
print "</a>&nbsp;<a href=\"fiche.php?id=$obj->cid\">$obj->cid</a></td>\n";
print "<td><a href=\"../product/fiche.php?id=$obj->pid\">$obj->label</a></td>\n";
print "<td><a href=\"../comm/fiche.php?socid=$obj->sidp\">$obj->nom</a></td>\n";
print '<td align="center">'.strftime("%d/%m/%y",$obj->date_ouverture)."</td>\n";
print '<td><a href="fiche.php?id='.$obj->cid.'">'.img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.'</a></td>';
print '<td><img src="./statut'.$obj->statut.'.png" border="0" alt="statut"></td>';
print '<td><a href="../product/fiche.php?id='.$obj->pid.'">'.img_object($langs->trans("ShowService"),"service").' '.$obj->label.'</a></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->date_ouverture).'</td>';
print "</tr>\n";
$i++;
}
$db->free();
$db->free($resql);
print "</table>";
@ -127,5 +122,5 @@ else
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
llxFooter('$Date$ - $Revision$');
?>

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2005 Laurent Destailleur <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
@ -21,9 +21,10 @@
*
*/
/*! \file htdocs/commande/fiche.php
\ingroup commande
\brief Fiche commande
/**
\file htdocs/contrat/fiche.php
\ingroup contrat
\brief Fiche contrat
\version $Revision$
*/
@ -50,8 +51,10 @@ if ($user->societe_id > 0)
$action = '';
$socidp = $user->societe_id;
}
/*
*
* Actions
*/
if ($_POST["action"] == 'add')
{
@ -96,25 +99,29 @@ if ($_POST["action"] == 'classin')
*
*/
if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
{
$result = 0;
$contrat = new Contrat($db);
$contrat->fetch($_GET["id"]);
if ($_POST["p_idprod"] > 0)
$result = 0;
$contrat = new Contrat($db);
$result=$contrat->fetch($_GET["id"]);
if ($_POST["p_idprod"] > 0)
{
$result = $contrat->addline($_POST["desc"],
$_POST["pu"],
$_POST["pqty"],
$_POST["tva_tx"],
$_POST["p_idprod"],
$_POST["premise"]);
//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"]);
}
if ($result == 0)
{
Header("Location: fiche.php?id=".$contrat->id);
if ($result >= 0)
{
Header("Location: fiche.php?id=".$contrat->id);
}
else
{
$mesg='<div class="error">'.$contrat->error.'</div>';
}
}
@ -192,16 +199,18 @@ llxHeader('',$langs->trans("OrderCard"),"Commande");
$html = new Form($db);
/*********************************************************************
*
* Mode creation
*
*
*
************************************************************************/
if ($_GET["action"] == 'create')
{
dolibarr_fiche_head($head, $a, "Création d'un nouveau contrat");
dolibarr_fiche_head($head, $a, $langs->trans("AddContract"));
if ($mesg) print $mesg;
$new_contrat = new Contrat($db);
@ -225,13 +234,13 @@ if ($_GET["action"] == 'create')
print '<input type="hidden" name="soc_id" value="'.$soc->id.'">' ."\n";
print '<input type="hidden" name="remise_percent" value="0">';
print '<table class="border" cellspacing="0" cellpadding="3" width="100%">';
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Customer").' :</td><td>'.$obj->nom.'</td></tr>';
print '<tr><td>'.$langs->trans("Customer").' :</td><td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$obj->nom.'</a></td></tr>';
print '<tr><td width="20%">'.$langs->trans("Commercial").'</td><td>';
print '<select name="commercial">';
print '<select name="commercial">';
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user ORDER BY name ";
if ( $db->query( $sql) )
{
@ -255,13 +264,15 @@ if ($_GET["action"] == 'create')
$html->select_date();
print "</td></tr>";
print '<tr><td>'.$langs->trans("Project").' :</td><td>';
$proj = new Project($db);
$html->select_array("projetid",$proj->liste_array($soc->id),0,1);
print "</td></tr>";
if ($conf->projet->enabled)
{
print '<tr><td>'.$langs->trans("Project").' :</td><td>';
$proj = new Project($db);
$html->select_array("projetid",$proj->liste_array($soc->id),0,1);
print "</td></tr>";
}
/*
*
*
* Liste des elements
*
@ -304,26 +315,26 @@ if ($_GET["action"] == 'create')
print '</table>';
print '</td></tr>';
*/
print '<tr><td>Commentaires</td><td valign="top">';
print '<tr><td>'.$langs->trans("Comment").'</td><td valign="top">';
print '<textarea name="note" wrap="soft" cols="60" rows="4"></textarea></td></tr>';
/*
*
*/
print '<tr><td colspan="3" align="center"><input type="submit" value="Créer"></td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
print "</form>\n";
print "</table>\n";
print "</table><br>\n";
if ($propalid)
{
/*
* Produits
*/
print_titre("Produits");
print_titre($langs->trans("Products"));
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="3">';
print '<tr class="liste_titre"><td>'.$langs->trans("Ref").'</td><td>Produit</td>';
print '<td align="right">'.$langs->trans("Price").'</td><td align="center">Remise</td><td align="center">Qté.</td></tr>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Ref").'</td><td>'.$langs->trans("Product").'</td>';
print '<td align="right">'.$langs->trans("Price").'</td><td align="center">'.$langs->trans("Discount").'</td><td align="center">'.$langs->trans("Qty").'</td></tr>';
$sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.remise_percent";
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pt, ".MAIN_DB_PREFIX."product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = $propalid";
@ -340,7 +351,7 @@ if ($_GET["action"] == 'create')
$var=!$var;
print "<tr $bc[$var]><td>[$objp->ref]</td>\n";
print '<td>'.$objp->product.'</td>';
print "<td align=\"right\">".price($objp->price)."</TD>";
print "<td align=\"right\">".price($objp->price)."</td>";
print '<td align="center">'.$objp->remise_percent.' %</td>';
print "<td align=\"center\">".$objp->qty."</td></tr>\n";
$i++;
@ -367,7 +378,7 @@ if ($_GET["action"] == 'create')
}
else
{
print $sql;
dolibarr_print_error($db);
}
print '</table>';
@ -376,7 +387,7 @@ if ($_GET["action"] == 'create')
}
else
{
print $db->error() . "<br>$sql";;
dolibarr_print_error($db);
}
}
else
@ -393,6 +404,8 @@ else
if ( $contrat->fetch($id) > 0)
{
if ($mesg) print $mesg;
$author = new User($db);
$author->id = $contrat->user_author_id;
$author->fetch();
@ -407,13 +420,13 @@ else
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id;
$head[$h][1] = $langs->trans("Contract");
$head[$h][1] = $langs->trans("ContractCard");
$hselected = $h;
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id);
dolibarr_fiche_head($head, $hselected, $contrat->societe->nom);
/*
* Confirmation de la suppression de la contrat
@ -445,39 +458,43 @@ else
/*
* Contrat
*/
if ($contrat->brouillon == 1 && $user->rights->contrat->creer)
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="setremise">';
}
print '<table class="border" cellspacing="0" cellpadding="2" width="100%">';
print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="2">';
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$contrat->societe->id.'">'.$contrat->societe->nom.'</a></b></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>';
print '<td width="50%" colspan="2">';
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
print $contrat->statuts[$contrat->statut];
print "</td></tr>";
print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td colspan=\"2\">".strftime("%A %d %B %Y",$contrat->date_contrat)."</td>\n";
print '<td colspan="3">'.strftime("%A %d %B %Y",$contrat->date_contrat)."</td></tr>\n";
print '<td>Projet</td><td>';
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.'&amp;action=classer">Classer le contrat</a>';
}
print "&nbsp;</td></tr>";
print '<tr><td>'.$langs->trans("Commercial suivi").'</td><td colspan="2">'.$commercial_suivi->fullname.'</td>';
print '<td>'.$langs->trans("Commercial signature").'</td><td colspan="2">'.$commercial_signature->fullname.'</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.'&amp;action=classer">Classer le contrat</a>';
}
print "</td></tr>";
}
print '<tr><td width="25%">'.$langs->trans("Commercial suivi").'</td><td>'.$commercial_suivi->fullname.'</td>';
print '<td width="25%">'.$langs->trans("Commercial signature").'</td><td>'.$commercial_signature->fullname.'</td></tr>';
print "</table>";
if ($contrat->brouillon == 1 && $user->rights->contrat->creer)
@ -489,7 +506,7 @@ else
* Lignes de contrats
*
*/
echo '<br><table border="0" width="100%" cellspacing="0" cellpadding="3">';
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 .= " FROM ".MAIN_DB_PREFIX."contratdet as l";
@ -506,25 +523,29 @@ else
if ($num)
{
print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>';
print '<td width="8%" align="center">Tva</td>';
print '<td width="8%" align="center">Quantité</td>';
print '<td width="8%" align="right">Remise</td>';
print '<td width="12%" align="right">P.U.</td>';
print '<td width="10%">&nbsp;</td><td width="10%">&nbsp;</td>';
print '<td width="30">'.$langs->trans("Status").'</td>';
print '<td>'.$langs->trans("Service").'</td>';
print '<td align="center">'.$langs->trans("VAT").'</td>';
print '<td align="center">'.$langs->trans("Qty").'</td>';
print '<td align="right">'.$langs->trans("Discount").'</td>';
print '<td align="right">'.$langs->trans("PriceU").'</td>';
print '<td>&nbsp;</td><td>&nbsp;</td>';
print "</tr>\n";
}
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>\n";
if ($objp->fk_product > 0)
{
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id.'&amp;ligne='.$objp->rowid.'">';;
print '<img src="./statut'.$objp->statut.'.png" border="0" alt="statut"></a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->label)).'</a>';
print '<img src="./statut'.$objp->statut.'.png" border="0" alt="statut"></a></td><td>';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
print img_object($langs->trans("ShowProduct"),"product").' '.$objp->label.'</a>';
if ($objp->description)
{
@ -536,10 +557,10 @@ else
}
else
{
print "<td>".stripslashes(nl2br($objp->description))."</TD>\n";
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
}
print '<td align="center">'.$objp->tva_tx.' %</TD>';
print '<td align="center">'.$objp->qty.'</TD>';
print '<td align="center">'.$objp->tva_tx.' %</td>';
print '<td align="center">'.$objp->qty.'</td>';
if ($objp->remise_percent > 0)
{
print '<td align="right">'.$objp->remise_percent." %</td>\n";
@ -563,6 +584,7 @@ else
print '<td colspan="2">&nbsp;</td>';
}
print "</tr>\n";
if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid)
{
@ -570,8 +592,9 @@ else
print '<input type="hidden" name="action" value="updateligne">';
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">';
print "<tr $bc[$var]>";
print '<td colspan="2"><textarea name="eldesc" cols="60" rows="2">'.stripslashes($objp->description).'</textarea></TD>';
print '<td align="center"><input size="4" type="text" name="elqty" value="'.$objp->qty.'"></TD>';
print '<td>&nbsp;</td>';
print '<td colspan="2"><textarea name="eldesc" cols="60" rows="2">'.$objp->description.'</textarea></td>';
print '<td align="center"><input size="4" type="text" name="elqty" value="'.$objp->qty.'"></td>';
print '<td align="right"><input size="3" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">&nbsp;%</td>';
print '<td align="right"><input size="8" type="text" name="elprice" value="'.price($objp->subprice).'"></td>';
print '<td align="right" colspan="2"><input type="submit" value="'.$langs->trans("Save").'"></td>';
@ -579,14 +602,14 @@ else
print "</form>\n";
}
$i++;
$var=!$var;
}
$db->free();
}
else
{
print $db->error();
dolibarr_print_error($db);
}
/*
* Ajouter une ligne produit/service
@ -615,21 +638,22 @@ else
}
else
{
print $db->error();
dolibarr_print_error($db);
}
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 width="54%">'.$langs->trans("Description").'</td>';
print '<td width="8%" align="center">'.$langs->trans("VAT").'</td>';
print '<td width="8%" align="center">'.$langs->trans("Qty").'</td>';
print '<td width="8%" align="right">Remise</td>';
print '<td width="12%" align="right">P.U.</TD>';
print '<td>&nbsp;</td>';
print '<td>'.$langs->trans("Service").'</td>';
print '<td align="center">'.$langs->trans("VAT").'</td>';
print '<td align="center">'.$langs->trans("Qty").'</td>';
print '<td align="right">'.$langs->trans("Discount").'</td>';
print '<td align="right">'.$langs->trans("PriceU").'</td>';
print '<td>&nbsp;</td><td>&nbsp;</td>'."</tr>\n";
/*
print "<tr $bc[$var]>".'<td><textarea name="desc" cols="60" rows="1"></textarea></td>';
print '<td align="center">';
@ -644,13 +668,17 @@ else
$var=!$var;
print "<tr $bc[$var]>";
print '<td>&nbsp;</td>';
print '<td colspan="2"><select name="p_idprod">'.$opt.'</select></td>';
print '<td align="center"><input type="text" size="2" name="pqty" value="1"></td>';
print '<td align="right"><input type="text" size="4" name="premise" value="0"> %</td>';
print '<td align="center"><input type="text" class="flat" size="2" name="pqty" value="1"></td>';
print '<td align="right"><input type="text" class="flat" size="2" name="premise" value="0">%</td>';
print '<td>&nbsp;</td>';
print '<td align="center" colspan="3"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
print '<td align="center" colspan="3" rowspan="2"><input type="submit" class="buttton" value="'.$langs->trans("Add").'"></td></tr>';
print "</tr>\n";
print "<tr $bc[$var]>".'<td colspan="7"><textarea name="desc" cols="60" rows="1"></textarea></td></tr>';
print "<tr $bc[$var]>";
print '<td>&nbsp;</td>';
print '<td colspan="6"><textarea name="desc" cols="60" rows="1"></textarea></td>';
print '</tr>';
print "</form>";
}
@ -673,9 +701,8 @@ else
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"].'">Expédier</a>';
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/expedition/contrat.php?id='.$_GET["id"].'">'.$langs->trans("Send").'</a>';
}
if ($contrat->statut == 0)
{

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2005 Laurent Destailleur <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
@ -21,8 +21,8 @@
*
*/
/*!
\file htdocs/contrat/contrat.class.php
/**
\file htdocs/contrat/index.php
\ingroup contrat
\brief Page liste des contrats
\version $Revision$
@ -53,11 +53,16 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
print_barre_liste("Contrats", $page, "index.php", "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
print_barre_liste($langs->trans("ContractsArea"), $page, "index.php", "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="30%" valign="top">Légende<br />';
print '<table class="noborder" width="100%">';
print '<tr><td width="30%" valign="top">';
// Légende
print 'Légende<br />';
print '<img src="./statut0.png" border="0" alt="statut">&nbsp;Statut initial<br />';
print '<img src="./statut1.png" border="0" alt="statut">&nbsp;A commander<br />';
print '<img src="./statut2.png" border="0" alt="statut">&nbsp;Commandé chez le fournisseur<br />';
@ -66,6 +71,7 @@ print '<img src="./statut4.png" border="0" alt="statut">&nbsp;Activ
print '</td><td width="70%" valign="top">';
// Not activated services
$sql = "SELECT cd.rowid as cid, cd.statut, cd.label, cd.fk_contrat ";
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql .= " WHERE cd.statut IN (0,3)";
@ -73,38 +79,80 @@ $sql .= " ORDER BY cd.tms DESC";
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>Service</td>';
print "</tr>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print "<td>";
print '<img src="./statut'.$obj->statut.'.png" border="0" alt="statut"></a>&nbsp;';
print "</a>&nbsp;<a href=\"fiche.php?id=$obj->fk_contrat\">$obj->label</a></td>\n";
$num = $db->num_rows();
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("NotActivatedServices").'</td>';
print "</tr>\n";
$i++;
}
$db->free();
print "</table>";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print "<td>";
print '<img src="./statut'.$obj->statut.'.png" border="0" alt="statut">';
print '&nbsp;<a href="ligne.php?id='.$obj->fk_contrat.'&ligne='.$obj->cid.'">'.$obj->label.'</a></td>';
print '<td><a href="fiche.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.'</td>';
print "</tr>\n";
$i++;
}
$db->free();
print "</table>";
}
else
{
dolibarr_print_error($db);
dolibarr_print_error($db);
}
print '<br>';
// Last activated services
$max=10;
$sql = "SELECT cd.rowid as cid, cd.statut, cd.label, cd.fk_contrat ";
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql .= " WHERE cd.statut = 4";
$sql .= " ORDER BY cd.tms DESC";
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("LastActivatedServices",min($num,$max)).'</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$max))
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print "<td>";
print '<img src="./statut'.$obj->statut.'.png" border="0" alt="statut"></a>&nbsp;';
print "</a>&nbsp;<a href=\"fiche.php?id=$obj->fk_contrat\">$obj->label</a></td>\n";
print '<td><a href="fiche.php?id='.$obj->fk_contrat.'">'.img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.'</td>';
print "</tr>\n";
$i++;
}
$db->free();
print "</table>";
}
else
{
dolibarr_print_error($db);
}
print '</td></tr></table>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2005 Laurent Destailleur <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
@ -21,9 +21,10 @@
*
*/
/*! \file htdocs/commande/fiche.php
\ingroup commande
\brief Fiche commande
/**
\file htdocs/contrat/fiche.php
\ingroup contrat
\brief Fiche contrat
\version $Revision$
*/
@ -134,11 +135,11 @@ $html = new Form($db);
$head[$h][1] = $langs->trans("Contract");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id;
$head[$h][1] = $langs->trans("Edition de la ligne");
$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, $contrat->societe->nom);
dolibarr_fiche_head($head, $hselected, $langs->trans("Contract").': '.$contrat->id);
@ -146,37 +147,38 @@ $html = new Form($db);
* Contrat
*/
print '<table class="border" cellspacing="0" cellpadding="2" width="100%">';
print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="2">';
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$contrat->societe->id.'">'.$contrat->societe->nom.'</a></b></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>';
print '<td width="50%" colspan="2">';
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
print $contrat->statuts[$contrat->statut];
print "</td></tr>";
print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td colspan=\"2\">".strftime("%A %d %B %Y",$contrat->date_contrat)."</td>\n";
print '<td colspan="3">'.strftime("%A %d %B %Y",$contrat->date_contrat)."</td></tr>\n";
print '<td>Projet</td><td>';
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.'&amp;action=classer">Classer le contrat</a>';
}
print "&nbsp;</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.'&amp;action=classer">Classer le contrat</a>';
}
print "</td></tr>";
}
print '<tr><td>'.$langs->trans("Commercial suivi").'</td><td colspan="2">'.$commercial_suivi->fullname.'</td>';
print '<td>'.$langs->trans("Commercial signature").'</td><td colspan="2">'.$commercial_signature->fullname.'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("Commercial suivi").'</td><td>'.$commercial_suivi->fullname.'</td>';
print '<td width="25%">'.$langs->trans("Commercial signature").'</td><td>'.$commercial_signature->fullname.'</td></tr>';
print "</table>";
/*
* Confirmation de la validation
@ -189,13 +191,12 @@ $html = new Form($db);
$html->form_confirm("ligne.php?id=".$contrat->id."&amp;ligne=".$_GET["ligne"]."&amp;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");
}
/*
* Lignes de contrats
*
*/
echo '<br><table border="0" width="100%" cellspacing="0" cellpadding="3">';
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";
@ -213,24 +214,26 @@ $html = new Form($db);
if ($num)
{
print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>';
print '<td width="8%" align="center">'.$langs->trans("VAT").'</td>';
print '<td width="8%" align="center">'.$langs->trans("Qty").'</td>';
print '<td width="8%" align="right">'.$langs->trans("Discount").'</td>';
print '<td width="12%" align="right">P.U.</td>';
print '<td width="10%">&nbsp;</td><td width="10%">&nbsp;</td>';
print '<td width="20">'.$langs->trans("Status").'</td>';
print '<td>'.$langs->trans("Service").'</td>';
print '<td align="center">'.$langs->trans("VAT").'</td>';
print '<td align="center">'.$langs->trans("Qty").'</td>';
print '<td align="right">'.$langs->trans("Discount").'</td>';
print '<td align="right">'.$langs->trans("PriceU").'</td>';
print '<td>&nbsp;</td><td width="10%">&nbsp;</td>';
print "</tr>\n";
}
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>\n";
if ($objp->fk_product > 0)
{
print '<td>';
print '<img src="./statut'.$objp->statut.'.png" border="0" alt="statut">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->label)).'</a>';
print '<td><img src="./statut'.$objp->statut.'.png" border="0" alt="statut"></td>';
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->description)
{
@ -241,10 +244,10 @@ $html = new Form($db);
}
else
{
print "<td>".stripslashes(nl2br($objp->description))."</TD>\n";
print '<td>&nbsp;</td><td>'.stripslashes(nl2br($objp->description))."</td>\n";
}
print '<td align="center">'.$objp->tva_tx.' %</TD>';
print '<td align="center">'.$objp->qty.'</TD>';
print '<td align="center">'.$objp->tva_tx.' %</td>';
print '<td align="center">'.$objp->qty.'</td>';
if ($objp->remise_percent > 0)
{
print '<td align="right">'.$objp->remise_percent." %</td>\n";
@ -261,23 +264,17 @@ $html = new Form($db);
$i++;
$var=!$var;
}
$db->free();
}
else
{
print $db->error();
dolibarr_print_error($db);
}
print '</table><br>';
print '</div>';
print "<p>\n";
if ( $user->rights->contrat->activer && $contrat->statut == 0 && $objp->statut <> 4)
{
/**
@ -285,12 +282,12 @@ $html = new Form($db);
*/
$form = new Form($db);
print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>';
print '<table class="noborder"><tr><td>';
print '<form action="ligne.php?id='.$contrat->id.'&amp;ligne='.$_GET["ligne"].'&amp;action=active" method="post">';
print '<table class="noborder" cellpadding="2" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">Activer le service</td><td>';
print '<tr><td>Date d\'activation</td><td>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ActivateService").'</td><td>';
print '<tr '.$bc[$var].'><td>'.$langs->trans("DateServiceActivate").'</td><td>';
if ($_POST["remonth"])
{
@ -304,16 +301,14 @@ $html = new Form($db);
print $form->select_date($dateact);
print '</td>';
print '<tr><td>Intervenant</td><td>'.$user->fullname.'</td></tr>';
print '<tr '.$bc[$var].'><td>'.$langs->trans("User").'</td><td>'.$user->fullname.'</td></tr>';
print '<tr><td>Commentaire</td><td><input size="30" 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><td colspan="2" align="center"><input type="submit" name="Activer"></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></td><td>';
print '&nbsp;</td></tr></table>';
print '</form><br></td></tr></table>';
}
}
else
@ -325,5 +320,5 @@ $html = new Form($db);
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
llxFooter('$Date$ - $Revision$');
?>

View File

@ -21,7 +21,8 @@
*
*/
/** \file htdocs/contrat/contrat.class.php
/**
\file htdocs/contrat/liste.php
\ingroup contrat
\brief Page liste des contrats
\version $Revision$
@ -29,6 +30,7 @@
require("./pre.inc.php");
$langs->load("contracts");
$langs->load("products");
$langs->load("companies");
@ -38,10 +40,16 @@ llxHeader();
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$page = isset($_GET["page"])?$_GET["page"]:$_POST["page"];
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$statut=isset($_GET["statut"])?$_GET["statut"]:1;
$socid=$_GET["socid"];
if (! $sortfield) $sortfield="c.rowid";
if (! $sortorder) $sortorder="DESC";
/*
* Sécurité accés client
@ -53,21 +61,6 @@ if ($user->societe_id > 0)
}
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if ($sortfield == "")
{
$sortfield="c.rowid";
}
if ($sortorder == "")
{
$sortorder="DESC";
}
$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";
@ -88,7 +81,7 @@ if ( $db->query($sql) )
$i = 0;
print_barre_liste("Liste des contrats", $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
print '<table class="noborder" width="100%">';
@ -105,9 +98,8 @@ if ( $db->query($sql) )
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$obj->cid\">";
print img_file();
print "</a>&nbsp;<a href=\"fiche.php?id=$obj->cid\">$obj->cid</a></td>\n";
print "<td><a href=\"../comm/fiche.php?socid=$obj->sidp\">$obj->nom</a></td>\n";
print img_object($langs->trans("ShowContract"),"contract").' '.$obj->cid.'</a></td>';
print '<td><a href="../comm/fiche.php?socid="'.$obj->sidp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.'</a></td>';
print "</tr>\n";
$i++;

View File

@ -1,5 +1,9 @@
# Dolibarr language file - en_US - contracts
ContractsArea=Contrats area
ListOfContracts=List of contracts
ListOfRunningContracts=List of contracts (Running)
LastContracts=Last %s modifed contracts
ContractCard=Contract card
ContractStatus=Contract status
ContractStatusNotRunning=Not running
ContractStatusRunning=Running
@ -8,4 +12,13 @@ Contracts=Contracts
Contract=Contract
NewContract=New contract
AddContract=Add contract
SearchAContract=Search a contract
SearchAContract=Search a contract
ActivateService=Activate service
DateServiceActivate=Date of service activation
DateServiceStart=Date for beginning of service
DateServiceEnd=Date for end of service
ShowContract=Show contract
ListOfRunningContractsLines=List of running contract lines
NotActivatedServices=Not activated services
LastActivatedServices=Last %s activated services
EditServiceLine=Edit service line

View File

@ -1,5 +1,8 @@
# Dolibarr language file - fr_FR - contracts
ContractsArea=Espace contrats
ListOfContracts=Liste des contrats
LastContracts=Les %s derniers contrats modifiés
ContractCard=Fiche contrat
ContractStatus=État du contrat
ContractStatusNotRunning=Hors service
ContractStatusRunning=En service
@ -9,3 +12,12 @@ Contract=Contrat
NewContract=Nouveau contrat
AddContract=Créer contrat
SearchAContract=Rechercher un contrat
ActivateService=Activer le service
DateServiceActivate=Date activation du service
DateServiceStart=Date début du service
DateServiceEnd=Date fin du service
ShowContract=Afficher contrat
ListOfRunningContractsLines=Liste des lignes de contrats en service
NotActivatedServices=Services non activés
LastActivatedServices=Les %s derniers services activés
EditServiceLine=Edition ligne du service