Ajout date de fin de validite

This commit is contained in:
Rodolphe Quiedeville 2003-11-19 14:52:09 +00:00
parent 65e53099d3
commit 5cf44a9bbd
3 changed files with 119 additions and 31 deletions

View File

@ -80,11 +80,12 @@ if ($action == 'create')
print_date_select();
print "</td>";
print '<td rowspan="4" colspan="2" valign="top">';
print '<td rowspan="5" colspan="2" valign="top">';
print '<textarea name="note" wrap="soft" cols="40" rows="6"></textarea>';
print '<tr><td>Auteur</td><td>'.$user->fullname.'</td></tr>';
print "<tr><td>Numéro</td><td><input name=\"ref\" value=\"$numpr\"></td></tr>\n";
print '<tr><td>Numéro</td><td><input name="ref" value="'.$numpr.'"></td></tr>'."\n";
print '<tr><td>Validité</td><td><input name="duree_validite" size="5" value="15"> jours</td></tr>';
/*
*
* Destinataire de la propale

View File

@ -67,14 +67,16 @@ if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"]
}
if ($action == 'add')
if ($HTTP_POST_VARS["action"] == 'add')
{
$propal = new Propal($db, $socidp);
$propal->datep = $db->idate(mktime(12, 1 , 1,
$HTTP_POST_VARS["remonth"],
$HTTP_POST_VARS["reday"],
$HTTP_POST_VARS["reyear"]));
$propal->datep = mktime(12, 1 , 1,
$HTTP_POST_VARS["remonth"],
$HTTP_POST_VARS["reday"],
$HTTP_POST_VARS["reyear"]);
$propal->duree_validite = $HTTP_POST_VARS["duree_validite"];
$propal->contactid = $HTTP_POST_VARS["contactidp"];
$propal->projetidp = $HTTP_POST_VARS["projetidp"];
@ -122,6 +124,17 @@ if ($HTTP_POST_VARS["action"] == 'setstatut' && $user->rights->propale->cloturer
$propal->cloture($user, $statut, $note);
}
if ($_GET["action"] == 'commande')
{
/*
* Cloture de la propale
*/
$propal = new Propal($db);
$propal->fetch($propalid);
$propal->create_commande($user);
}
if ($action == 'modif' && $user->rights->propale->creer)
{
/*
@ -263,7 +276,12 @@ if ($propalid)
print '<tr><td>Société</td><td colspan="3"><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
print '<td>Statut</td><td align="center"><b>'.$obj->lst.'</b></td></tr>';
print '<tr><td>Date</td><td colspan="3">'.strftime("%A %d %B %Y",$obj->dp).'</td>';
print '<tr><td>Date</td><td colspan="3">'.strftime("%A %d %B %Y",$obj->dp);
if ($propal->fin_validite)
{
print " (".strftime("%d %B %Y",$propal->fin_validite).")";
}
print '</td>';
print '<td>Auteur</td><td>';
$author = new User($db, $obj->fk_user_author);
@ -396,7 +414,9 @@ if ($propalid)
print "<TD align=\"right\">".price($objp->subprice)."</td>";
if ($obj->statut == 0 && $user->rights->propale->creer)
{
print '<td align="center"><a href="propal.php?propalid='.$propalid.'&amp;ligne='.$objp->rowid.'&amp;action=del_ligne">Supprimer</a></td>';
print '<td align="center"><a href="propal.php?propalid='.$propalid.'&amp;ligne='.$objp->rowid.'&amp;action=del_ligne">';
print img_delete();
print '</a></td>';
}
else
{
@ -502,7 +522,7 @@ if ($propalid)
print "<td width=\"20%\">-</td>";
}
}
print "<td width=\"20%\">-</td>";
print '<td width="20%">-</td>';
/*
*
*/
@ -535,7 +555,7 @@ if ($propalid)
}
else
{
print '<td bgcolor="#e0e0e0" align="center" width="20%">! Propale non generee !</td>';
print '<td bgcolor="#e0e0e0" align="center" width="20%">! Proposition non génerée !</td>';
}
}
else
@ -632,7 +652,7 @@ if ($propalid)
$file = PROPALE_OUTPUTDIR . "/$obj->ref/$obj->ref.pdf";
if (file_exists($file))
{
print "<tr $bc[0]><td>Propale PDF</td>";
print "<tr $bc[0]><td>PDF</td>";
print '<td><a href="'.PROPALE_OUTPUT_URL.'/'.$propal->ref.'/'.$propal->ref.'.pdf">'.$propal->ref.'.pdf</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td></tr>';
@ -648,6 +668,24 @@ if ($propalid)
print '</td></tr>';
}
print "</table>\n";
/*
*
*/
$nb_commande = sizeof($propal->commande_liste_array());
if ($nb_commande > 0)
{
$coms = $propal->commande_liste_array();
print '<br><table class="border" width="100%" cellspacing="0" cellpadding="3">';
print "<tr><td>Commande Num.</td></tr>\n";
for ($i = 0 ; $i < $nb_commande ; $i++)
{
print '<tr><td><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$coms[$i].'">'.$coms[$i]."</a></td>\n";
print "</tr>\n";
}
print "</table>";
}
// print '<a href="'.$PHP_SELF."?propalid=$propalid&amp;action=commande\">Générer</a>";
/*
*
*/
@ -667,7 +705,7 @@ if ($propalid)
{
print_titre("Propale envoyée");
print "<TABLE class=\"border\" border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"3\">";
print '<table class="border" width="100%" cellspacing="0" cellpadding="3">';
print "<tr><td>Date</td><td>Auteur</td></TR>\n";
@ -802,7 +840,7 @@ if ($propalid)
$pageprev = $page - 1;
$pagenext = $page + 1;
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid";
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp,".$db->pdate("p.fin_validite")." as dfv, c.label as statut, c.id as statutid";
$sql .= " FROM llx_societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id";
if ($socidp)
@ -857,18 +895,15 @@ if ($propalid)
while ($i < min($num,$limit))
{
$objp = $db->fetch_object( $i);
$now = time();
$var=!$var;
print "<TR $bc[$var]>";
print "<TD><a href=\"$PHP_SELF?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
print "<TD><a href=\"fiche.php?socid=$objp->idp\">$objp->nom</a></TD>\n";
$now = time();
$lim = 3600 * 24 * 15 ;
if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 )
if ( $now > $objp->dfv && $objp->dfv > 0 )
{
print "<td><b> &gt; 15 jours</b></td>";
print "<td>".strftime("%d %b %Y",$objp->dfv)."</td>";
}
else
{

View File

@ -103,7 +103,7 @@ class Propal
}
}
}
/*
/**
*
*
*/
@ -181,7 +181,7 @@ class Propal
}
}
}
/*
/**
*
*
*
@ -191,8 +191,10 @@ class Propal
/*
* Insertion dans la base
*/
$sql = "INSERT INTO llx_propal (fk_soc, fk_soc_contact, price, remise, tva, total, datep, datec, ref, fk_user_author, note, model_pdf) ";
$sql .= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0, $this->datep, now(), '$this->ref', $this->author, '$this->note','$this->modelpdf')";
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
$sql = "INSERT INTO llx_propal (fk_soc, fk_soc_contact, price, remise, tva, total, datep, datec, ref, fk_user_author, note, model_pdf, fin_validite) ";
$sql .= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0,".$this->db->idate($this->datep).", now(), '$this->ref', $this->author, '$this->note','$this->modelpdf',".$this->db->idate($this->fin_validite).")";
$sqlok = 0;
if ( $this->db->query($sql) )
@ -304,7 +306,7 @@ class Propal
Function fetch($rowid)
{
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact,".$this->db->pdate(datep)."as dp, model_pdf, note, fk_statut, remise_percent";
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact,".$this->db->pdate("datep")."as dp,".$this->db->pdate("fin_validite")."as dfv, model_pdf, note, fk_statut, remise_percent";
$sql .= " FROM llx_propal WHERE rowid=$rowid;";
if ($this->db->query($sql) )
@ -315,6 +317,7 @@ class Propal
$this->id = $rowid;
$this->datep = $obj->dp;
$this->fin_validite = $obj->dfv;
$this->date = $obj->dp;
$this->ref = $obj->ref;
$this->price = $obj->price;
@ -329,7 +332,7 @@ class Propal
$this->contactid = $obj->fk_soc_contact;
$this->modelpdf = $obj->model_pdf;
$this->note = $obj->note;
$this->statut = $obj->fk_statut;
if ($obj->fk_statut == 0)
{
$this->brouillon = 1;
@ -503,10 +506,12 @@ class Propal
/**
* Cloture de la propale
*
*
*/
Function cloture($user, $statut, $note)
{
$this->statut = $statut;
$sql = "UPDATE llx_propal SET fk_statut = $statut, note = '$note', date_cloture=now(), fk_user_cloture=$user->id";
$sql .= " WHERE rowid = $this->id;";
@ -516,8 +521,9 @@ class Propal
{
/* Propale signée */
include_once DOL_DOCUMENT_ROOT . "/commande/commande.class.php";
$commande = new Commande($this->db);
$commande->create_from_propale($user, $this->id);
$this->create_commande($user);
return 1;
}
else
@ -531,8 +537,22 @@ class Propal
print $this->db->error() . ' in ' . $sql;
}
}
/*
/**
*
*
*/
Function create_commande($user)
{
if ($this->statut == 2)
{
/* Propale signée */
include_once DOL_DOCUMENT_ROOT . "/commande/commande.class.php";
$commande = new Commande($this->db);
$commande->create_from_propale($user, $this->id);
return 1;
}
}
/**
*
*
*/
@ -551,7 +571,7 @@ class Propal
print $this->db->error() . ' in ' . $sql;
}
}
/*
/**
*
*
*/
@ -600,6 +620,38 @@ class Propal
print $this->db->error();
}
}
/**
* Renvoie un tableau contenant les numéros de commandes associées
*
*/
Function commande_liste_array ()
{
$ga = array();
$sql = "SELECT fk_commande FROM llx_co_pr";
$sql .= " WHERE fk_propale = " . $this->id;
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($i);
$ga[$i] = $obj->fk_commande;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*