mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-15 22:11:36 +01:00
Travail sur les commandes, les stocks, et diverses mises aux normes
This commit is contained in:
@@ -34,20 +34,7 @@ function llxHeader($head = "", $urlp = "") {
|
|||||||
$menu->add("index.php", "Configuration");
|
$menu->add("index.php", "Configuration");
|
||||||
$menu->add_submenu("modules.php", "Modules");
|
$menu->add_submenu("modules.php", "Modules");
|
||||||
|
|
||||||
if(defined("MAIN_MODULE_FACTURE") && MAIN_MODULE_FACTURE)
|
|
||||||
{
|
|
||||||
$menu->add_submenu("facture.php", "Factures");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defined("MAIN_MODULE_PROPALE") && MAIN_MODULE_PROPALE)
|
|
||||||
{
|
|
||||||
$menu->add_submenu("propale.php", "Propositions commerciales");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defined("MAIN_MODULE_FICHEINTER") && MAIN_MODULE_FICHEINTER)
|
|
||||||
{
|
|
||||||
$menu->add_submenu("fichinter.php", "Fiches d'intervention");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defined("MAIN_MODULE_ADHERENT") && MAIN_MODULE_ADHERENT)
|
if(defined("MAIN_MODULE_ADHERENT") && MAIN_MODULE_ADHERENT)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class infoBox
|
|||||||
|
|
||||||
print '<table width="100%" cellpadding="3" cellspacing="0" border="0">';
|
print '<table width="100%" cellpadding="3" cellspacing="0" border="0">';
|
||||||
|
|
||||||
print '<tr class="box_titre"><td>'.$head[0]['text']."</td></tr>";
|
print '<tr class="box_titre"><td colspan="2">'.$head[0]['text']."</td></tr>";
|
||||||
|
|
||||||
for ($i=0, $n=sizeof($contents); $i<$n; $i++)
|
for ($i=0, $n=sizeof($contents); $i<$n; $i++)
|
||||||
{
|
{
|
||||||
@@ -45,6 +45,10 @@ class infoBox
|
|||||||
{
|
{
|
||||||
print ' align="'. $contents[$i][$j]['align'].'"';
|
print ' align="'. $contents[$i][$j]['align'].'"';
|
||||||
}
|
}
|
||||||
|
if (strlen($contents[$i][$j]['width']) > 0)
|
||||||
|
{
|
||||||
|
print ' width="'. $contents[$i][$j]['width'].'"';
|
||||||
|
}
|
||||||
print'>';
|
print'>';
|
||||||
|
|
||||||
if (strlen($contents[$i][$j]['url']) > 0)
|
if (strlen($contents[$i][$j]['url']) > 0)
|
||||||
|
|||||||
@@ -363,7 +363,9 @@ if ($propalid)
|
|||||||
print '<td align="right">'.price($objp->subprice).'</td>';
|
print '<td align="right">'.price($objp->subprice).'</td>';
|
||||||
if ($obj->statut == 0 && $user->rights->propale->creer)
|
if ($obj->statut == 0 && $user->rights->propale->creer)
|
||||||
{
|
{
|
||||||
print '<td align="center"><a href="propal.php?propalid='.$propalid.'&ligne='.$objp->rowid.'&action=del_ligne">Supprimer</a></td>';
|
print '<td align="center"><a href="propal.php?propalid='.$propalid.'&ligne='.$objp->rowid.'&action=del_ligne">';
|
||||||
|
print img_delete();
|
||||||
|
print '</a></td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -482,7 +484,7 @@ if ($propalid)
|
|||||||
{
|
{
|
||||||
if ($user->rights->propale->supprimer)
|
if ($user->rights->propale->supprimer)
|
||||||
{
|
{
|
||||||
print "<td width=\"20%\">[<a href=\"$PHP_SELF?propalid=$propalid&action=delete\">Supprimer</a>]</td>";
|
print "<td width=\"20%\"><a href=\"$PHP_SELF?propalid=$propalid&action=delete\">Supprimer</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -493,7 +495,7 @@ if ($propalid)
|
|||||||
{
|
{
|
||||||
if ($obj->statut == 1 && $user->rights->propale->cloturer)
|
if ($obj->statut == 1 && $user->rights->propale->cloturer)
|
||||||
{
|
{
|
||||||
print "<td width=\"20%\">[<a href=\"$PHP_SELF?propalid=$propalid&action=statut\">Cloturer</a>]</td>";
|
print "<td width=\"20%\"><a href=\"$PHP_SELF?propalid=$propalid&action=statut\">Cloturer</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -506,7 +508,7 @@ if ($propalid)
|
|||||||
*/
|
*/
|
||||||
if ($obj->statut < 2 && $user->rights->propale->creer)
|
if ($obj->statut < 2 && $user->rights->propale->creer)
|
||||||
{
|
{
|
||||||
print '<td width="20%">[<a href="'.$PHP_SELF."?propalid=$propalid&action=pdf\">G<>n<EFBFBD>rer</a>]</td>";
|
print '<td width="20%"><a href="'.$PHP_SELF."?propalid=$propalid&action=pdf\">G<>n<EFBFBD>rer</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -524,7 +526,7 @@ if ($propalid)
|
|||||||
if ($user->rights->propale->envoyer)
|
if ($user->rights->propale->envoyer)
|
||||||
{
|
{
|
||||||
print "<td width=\"20%\">";
|
print "<td width=\"20%\">";
|
||||||
print "[<a href=\"$PHP_SELF?propalid=$propalid&action=presend\">Envoyer la proposition</a>]</td>";
|
print "<a href=\"$PHP_SELF?propalid=$propalid&action=presend\">Envoyer la proposition</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -547,7 +549,7 @@ if ($propalid)
|
|||||||
{
|
{
|
||||||
if ($user->rights->propale->valider)
|
if ($user->rights->propale->valider)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?propalid=$propalid&valid=1\">Valider</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?propalid=$propalid&valid=1\">Valider</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -558,7 +560,7 @@ if ($propalid)
|
|||||||
{
|
{
|
||||||
if ($user->rights->propale->creer)
|
if ($user->rights->propale->creer)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?propalid=$propalid&action=modif\">Modifier</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?propalid=$propalid&action=modif\">Modifier</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ if (!$user->rights->commande->lire)
|
|||||||
require("../project.class.php");
|
require("../project.class.php");
|
||||||
require("../propal.class.php");
|
require("../propal.class.php");
|
||||||
|
|
||||||
llxHeader();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* S<>curit<69> acc<63>s client
|
* S<>curit<69> acc<63>s client
|
||||||
*/
|
*/
|
||||||
@@ -59,7 +57,7 @@ if ($HTTP_POST_VARS["action"] == 'add')
|
|||||||
$commande->soc_id = $HTTP_POST_VARS["soc_id"];
|
$commande->soc_id = $HTTP_POST_VARS["soc_id"];
|
||||||
$commande->date_commande = $datecommande;
|
$commande->date_commande = $datecommande;
|
||||||
$commande->note = $HTTP_POST_VARS["note"];
|
$commande->note = $HTTP_POST_VARS["note"];
|
||||||
|
$commande->source = $HTTP_POST_VARS["source_id"];
|
||||||
$commande->projetid = $HTTP_POST_VARS["projetid"];
|
$commande->projetid = $HTTP_POST_VARS["projetid"];
|
||||||
$commande->remise_percent = $HTTP_POST_VARS["remise_percent"];
|
$commande->remise_percent = $HTTP_POST_VARS["remise_percent"];
|
||||||
|
|
||||||
@@ -140,6 +138,13 @@ if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] =
|
|||||||
$result = $commande->valid($user);
|
$result = $commande->valid($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($HTTP_POST_VARS["action"] == 'confirm_cancel' && $HTTP_POST_VARS["confirm"] == yes && $user->rights->commande->valider)
|
||||||
|
{
|
||||||
|
$commande = new Commande($db);
|
||||||
|
$commande->fetch($_GET["id"]);
|
||||||
|
$result = $commande->cancel($user);
|
||||||
|
}
|
||||||
|
|
||||||
if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] == yes)
|
if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] == yes)
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->supprimer )
|
if ($user->rights->commande->supprimer )
|
||||||
@@ -147,7 +152,7 @@ if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"]
|
|||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->id = $_GET["id"];
|
$commande->id = $_GET["id"];
|
||||||
$commande->delete();
|
$commande->delete();
|
||||||
$id = 0 ;
|
Header("Location: liste.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +168,10 @@ if ($action == 'pdf')
|
|||||||
commande_pdf_create($db, $_GET["id"]);
|
commande_pdf_create($db, $_GET["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
@@ -176,6 +185,8 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
print_titre("Cr<EFBFBD>er une commande");
|
print_titre("Cr<EFBFBD>er une commande");
|
||||||
|
|
||||||
|
$new_commande = new Commande($db);
|
||||||
|
|
||||||
if ($propalid)
|
if ($propalid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.remise_percent, p.tva, p.total, p.ref, ".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst";
|
$sql = "SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.remise_percent, p.tva, p.total, p.ref, ".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst";
|
||||||
@@ -223,7 +234,10 @@ if ($action == 'create')
|
|||||||
print "<tr><td>Num<75>ro :</td><td>Provisoire</td></tr>";
|
print "<tr><td>Num<75>ro :</td><td>Provisoire</td></tr>";
|
||||||
print '<input name="facnumber" type="hidden" value="provisoire">';
|
print '<input name="facnumber" type="hidden" value="provisoire">';
|
||||||
|
|
||||||
|
print "<tr><td>Source :</td><td>";
|
||||||
|
$html->select_array("source_id",$new_commande->sources,2);
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
print "<tr><td>Projet :</td><td>";
|
print "<tr><td>Projet :</td><td>";
|
||||||
$proj = new Project($db);
|
$proj = new Project($db);
|
||||||
$html->select_array("projetid",$proj->liste_array($socidp),0,1);
|
$html->select_array("projetid",$proj->liste_array($socidp),0,1);
|
||||||
@@ -394,11 +408,19 @@ else
|
|||||||
* Confirmation de la validation
|
* Confirmation de la validation
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if ($action == 'valid')
|
if ($_GET["action"] == 'valid')
|
||||||
{
|
{
|
||||||
//$numfa = commande_get_num($soc);
|
//$numfa = commande_get_num($soc);
|
||||||
$html->form_confirm("$PHP_SELF?id=$id","Valider la commande","Etes-vous s<>r de vouloir valider cette commande ?","confirm_valid");
|
$html->form_confirm("$PHP_SELF?id=$id","Valider la commande","Etes-vous s<>r de vouloir valider cette commande ?","confirm_valid");
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Confirmation de l'annulation
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ($_GET["action"] == 'annuler')
|
||||||
|
{
|
||||||
|
$html->form_confirm("$PHP_SELF?id=$id","Annuler la commande","Etes-vous s<>r de vouloir annuler cette commande ?","confirm_cancel");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Commande
|
* Commande
|
||||||
@@ -411,14 +433,28 @@ else
|
|||||||
|
|
||||||
print '<table class="border" cellspacing="0" cellpadding="2" width="100%">';
|
print '<table class="border" cellspacing="0" cellpadding="2" width="100%">';
|
||||||
print "<tr><td>Client</td>";
|
print "<tr><td>Client</td>";
|
||||||
print "<td colspan=\"3\">";
|
print "<td colspan=\"2\">";
|
||||||
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
||||||
|
|
||||||
print "<td>Source : " . $commande->sources[0] ."</td></tr>";
|
print '<td width="50%">';
|
||||||
|
print $commande->statuts[$commande->statut];
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
print "<tr><td>Date</td>";
|
print "<tr><td>Date</td>";
|
||||||
print "<td colspan=\"3\">".strftime("%A %d %B %Y",$commande->date)."</td>\n";
|
print "<td colspan=\"2\">".strftime("%A %d %B %Y",$commande->date)."</td>\n";
|
||||||
|
|
||||||
|
print '<td width="50%">Source : ' . $commande->sources[$commande->source] ;
|
||||||
|
if ($commande->source == 0)
|
||||||
|
{
|
||||||
|
/* Propale */
|
||||||
|
$propal = new Propal($db);
|
||||||
|
$propal->fetch($commande->propale_id);
|
||||||
|
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
|
||||||
|
}
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
|
print "<tr><td>Auteur</td><td colspan=\"2\">$author->fullname</td>";
|
||||||
|
|
||||||
print '<td>Projet : ';
|
print '<td>Projet : ';
|
||||||
if ($commande->projet_id > 0)
|
if ($commande->projet_id > 0)
|
||||||
{
|
{
|
||||||
@@ -431,14 +467,14 @@ else
|
|||||||
print '<a href="fiche.php?id='.$id.'&action=classer">Classer la commande</a>';
|
print '<a href="fiche.php?id='.$id.'&action=classer">Classer la commande</a>';
|
||||||
}
|
}
|
||||||
print " </td></tr>";
|
print " </td></tr>";
|
||||||
|
|
||||||
print "<tr><td>Auteur</td><td colspan=\"3\">$author->fullname</td>";
|
|
||||||
|
|
||||||
print '<tr><td>Montant</td>';
|
print '<tr><td>Montant</td>';
|
||||||
print '<td align="right" colspan="2"><b>'.price($commande->total_ht).'</b></td>';
|
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
|
||||||
print '<td>'.MAIN_MONNAIE.' HT</td></tr>';
|
print '<td>'.MAIN_MONNAIE.' HT</td>';
|
||||||
|
|
||||||
print '<tr><td>Remise</td><td align="right" colspan="2">';
|
print '<td>Note</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>Remise globale</td><td align="right">';
|
||||||
|
|
||||||
if ($commande->brouillon == 1 && $user->rights->commande->creer)
|
if ($commande->brouillon == 1 && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
@@ -451,16 +487,16 @@ else
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>TVA</td><td align="right" colspan="2">'.price($commande->total_tva).'</td>';
|
print '<tr><td>TVA</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||||
print '<td>'.MAIN_MONNAIE.'</td></tr>';
|
print '<td>'.MAIN_MONNAIE.'</td></tr>';
|
||||||
print '<tr><td>Total</td><td align="right" colspan="2">'.price($commande->total_ttc).'</td>';
|
print '<tr><td>Total</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||||
print '<td>'.MAIN_MONNAIE.' TTC</td></tr>';
|
print '<td>'.MAIN_MONNAIE.' TTC</td></tr>';
|
||||||
if ($commande->note)
|
if ($commande->note)
|
||||||
{
|
{
|
||||||
print '<tr><td colspan="5">Note : '.nl2br($commande->note)."</td></tr>";
|
print '<tr><td colspan="5">Note : '.nl2br($commande->note)."</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</table><br>";
|
print "</table>";
|
||||||
|
|
||||||
if ($commande->brouillon == 1 && $user->rights->commande->creer)
|
if ($commande->brouillon == 1 && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
@@ -471,7 +507,7 @@ else
|
|||||||
* Lignes de commandes
|
* Lignes de commandes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
echo '<table border="0" width="100%" cellspacing="0" cellpadding="3">';
|
echo '<br><table border="0" width="100%" cellspacing="0" cellpadding="3">';
|
||||||
|
|
||||||
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
|
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
|
||||||
$sql .= " FROM llx_commandedet as l WHERE l.fk_commande = $id ORDER BY l.rowid";
|
$sql .= " FROM llx_commandedet as l WHERE l.fk_commande = $id ORDER BY l.rowid";
|
||||||
@@ -500,7 +536,8 @@ else
|
|||||||
print "<TR $bc[$var]>";
|
print "<TR $bc[$var]>";
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
print '<td>';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -519,8 +556,12 @@ else
|
|||||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||||
if ($commande->statut == 0 && $user->rights->commande->creer)
|
if ($commande->statut == 0 && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
print '<td align="right"><a href="'.$PHPSELF.'?id='.$id.'&action=deleteline&lineid='.$objp->rowid.'">del</a></td>';
|
print '<td align="right"><a href="'.$PHPSELF.'?id='.$id.'&action=editline&rowid='.$objp->rowid.'">';
|
||||||
print '<td align="right"><a href="'.$PHPSELF.'?id='.$id.'&action=editline&rowid='.$objp->rowid.'">edit</a></td>';
|
print img_edit();
|
||||||
|
print '</a></td>';
|
||||||
|
print '<td align="right"><a href="'.$PHPSELF.'?id='.$id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
||||||
|
print img_delete();
|
||||||
|
print '</a></td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -533,7 +574,7 @@ else
|
|||||||
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">";
|
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">";
|
||||||
print '<input type="hidden" name="action" value="updateligne">';
|
print '<input type="hidden" name="action" value="updateligne">';
|
||||||
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
||||||
print "<TR $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print '<TD colspan="2"><textarea name="desc" cols="60" rows="2">'.stripslashes($objp->description).'</textarea></TD>';
|
print '<TD colspan="2"><textarea name="desc" cols="60" rows="2">'.stripslashes($objp->description).'</textarea></TD>';
|
||||||
print '<TD align="center"><input size="4" type="text" name="qty" value="'.$objp->qty.'"></TD>';
|
print '<TD align="center"><input size="4" type="text" name="qty" value="'.$objp->qty.'"></TD>';
|
||||||
print '<TD align="right"><input size="3" type="text" name="remise_percent" value="'.$objp->remise_percent.'"> %</td>';
|
print '<TD align="right"><input size="3" type="text" name="remise_percent" value="'.$objp->remise_percent.'"> %</td>';
|
||||||
@@ -542,14 +583,10 @@ else
|
|||||||
print '</tr>' . "\n";
|
print '</tr>' . "\n";
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$total = $total + ($objp->qty * $objp->price);
|
|
||||||
$i++;
|
$i++;
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->free();
|
$db->free();
|
||||||
// print "</table>";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -625,11 +662,11 @@ else
|
|||||||
|
|
||||||
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?id=$id&action=delete\">Supprimer</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?id=$id&action=delete\">Supprimer</a></td>";
|
||||||
}
|
}
|
||||||
elseif ($commande->statut == 1 && abs($resteapayer) > 0 && $user->rights->commande->envoyer)
|
elseif ($commande->statut == 1 && abs($resteapayer) > 0 && $user->rights->commande->envoyer)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?id=$id&action=presend\">Envoyer</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?id=$id&action=presend\">Envoyer</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -642,24 +679,24 @@ else
|
|||||||
|
|
||||||
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
print '<td align="center" width="20%">-</td>';
|
||||||
|
print '<td align="center" width="20%">-</td>';
|
||||||
|
|
||||||
if ($commande->statut == 0)
|
if ($commande->statut == 0)
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->valider)
|
if ($user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?id=$id&action=valid\">Valider</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?id=$id&action=valid\">Valider</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<td align="center" width="20%">-</td>';
|
print '<td align="center" width="20%">-</td>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($commande->statut == 1 && $commande->paye == 0)
|
elseif ($commande->statut == 1)
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->creer)
|
if ($user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\"><a href=\"fiche.php?id=$id&action=pdf\">G<EFBFBD>n<EFBFBD>rer la commande</a></td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"fiche.php?id=$id&action=annuler\">Annuler la commande</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -671,10 +708,6 @@ else
|
|||||||
print '<td align="center" width="20%">-</td>';
|
print '<td align="center" width="20%">-</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
|
|
||||||
|
|
||||||
print "</tr></table>";
|
print "</tr></table>";
|
||||||
}
|
}
|
||||||
print "<p>\n";
|
print "<p>\n";
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ function llxHeader($head = "", $urlp = "")
|
|||||||
$menu = new Menu();
|
$menu = new Menu();
|
||||||
|
|
||||||
$menu->add(DOL_URL_ROOT."/commande/", "Commandes");
|
$menu->add(DOL_URL_ROOT."/commande/", "Commandes");
|
||||||
|
$menu->add_submenu(DOL_URL_ROOT."/commande/liste.php", "Liste");
|
||||||
|
|
||||||
|
$menu->add(DOL_URL_ROOT."/commande/stats/", "Statistiques");
|
||||||
|
|
||||||
left_menu($menu->liste);
|
left_menu($menu->liste);
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -871,11 +871,11 @@ else
|
|||||||
|
|
||||||
if ($fac->statut == 0 && $user->rights->facture->supprimer)
|
if ($fac->statut == 0 && $user->rights->facture->supprimer)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?facid=$facid&action=delete\">Supprimer</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$facid&action=delete\">Supprimer</a></td>";
|
||||||
}
|
}
|
||||||
elseif ($fac->statut == 1 && abs($resteapayer) > 0 && $user->rights->facture->envoyer)
|
elseif ($fac->statut == 1 && abs($resteapayer) > 0 && $user->rights->facture->envoyer)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?facid=$facid&action=presend\">Envoyer</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$facid&action=presend\">Envoyer</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -884,7 +884,7 @@ else
|
|||||||
|
|
||||||
if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->paiement)
|
if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->paiement)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"paiement.php?facid=$facid&action=create\">Emettre un paiement</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"paiement.php?facid=$facid&action=create\">Emettre un paiement</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -895,7 +895,7 @@ else
|
|||||||
{
|
{
|
||||||
if ($user->rights->facture->paiement)
|
if ($user->rights->facture->paiement)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?facid=$facid&action=payed\">Classer 'Pay<61>e'</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$facid&action=payed\">Classer 'Pay<61>e'</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -904,7 +904,16 @@ else
|
|||||||
}
|
}
|
||||||
elseif ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer)
|
elseif ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" width=\"20%\">[<a href=\"$PHP_SELF?facid=$facid&action=prerelance\">Envoyer une relance</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$facid&action=prerelance\">Envoyer une relance</a></td>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<td align="center" width="20%">-</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fac->statut > 0)
|
||||||
|
{
|
||||||
|
print '<td align="center" width="20%"><a href="facture/fiche-rec.php?facid='.$facid.'&action=create">R<>currente</a></td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -915,7 +924,7 @@ else
|
|||||||
{
|
{
|
||||||
if ($user->rights->facture->valider)
|
if ($user->rights->facture->valider)
|
||||||
{
|
{
|
||||||
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"20%\">[<a href=\"$PHP_SELF?facid=$facid&action=valid\">Valider</a>]</td>";
|
print "<td align=\"center\" width=\"20%\"><a href=\"$PHP_SELF?facid=$facid&action=valid\">Valider</a></td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -938,17 +947,6 @@ else
|
|||||||
print '<td align="center" width="20%">-</td>';
|
print '<td align="center" width="20%">-</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fac->statut > 0)
|
|
||||||
{
|
|
||||||
//print '<td align="center" width="20%">-</td>';
|
|
||||||
|
|
||||||
print '<td align="center" width="20%"><a href="facture/fiche-rec.php?facid='.$facid.'&action=create">R<>currente</a></td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td align="center" width="20%">-</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</tr></table>";
|
print "</tr></table>";
|
||||||
}
|
}
|
||||||
print "<p>\n";
|
print "<p>\n";
|
||||||
|
|||||||
@@ -204,12 +204,12 @@ if ( $db->query($sql) )
|
|||||||
print '</td><td valign="top" width="70%">';
|
print '</td><td valign="top" width="70%">';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Propales <20> facturer
|
* Commandes <20> facturer
|
||||||
*/
|
*/
|
||||||
if ($user->comm > 0 && $conf->commercial )
|
if ($user->comm > 0 && $conf->commercial )
|
||||||
{
|
{
|
||||||
$sql = "SELECT p.rowid, p.ref, s.nom, s.idp FROM llx_propal as p, llx_societe as s";
|
$sql = "SELECT p.rowid, p.ref, s.nom, s.idp FROM llx_commande as p, llx_societe as s";
|
||||||
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = 2";
|
$sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = 1 AND p.facture = 0";
|
||||||
if ($socidp)
|
if ($socidp)
|
||||||
{
|
{
|
||||||
$sql .= " AND p.fk_soc = $socidp";
|
$sql .= " AND p.fk_soc = $socidp";
|
||||||
@@ -223,13 +223,13 @@ if ($user->comm > 0 && $conf->commercial )
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
print '<table border="0" cellspacing="0" cellpadding="3" width="100%">';
|
print '<table border="0" cellspacing="0" cellpadding="3" width="100%">';
|
||||||
print "<tr class=\"liste_titre\">";
|
print "<tr class=\"liste_titre\">";
|
||||||
print '<td colspan="2">'.translate("Propositions commerciales <20> facturer").'</td></tr>';
|
print '<td colspan="2">'.translate("Commandes <20> facturer").'</td></tr>';
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$obj = $db->fetch_object($i);
|
$obj = $db->fetch_object($i);
|
||||||
print "<tr $bc[$var]><td width=\"20%\"><a href=\"propal.php?propalid=$obj->rowid\">$obj->ref</a></td>";
|
print "<tr $bc[$var]><td width=\"20%\"><a href=\"commande.php?id=$obj->rowid\">$obj->ref</a></td>";
|
||||||
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td></tr>';
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td></tr>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,8 +267,8 @@ class Form {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/**
|
||||||
*
|
* Affiche un select <20> partir d'un tableau
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function select_array($name, $array, $id='', $empty=0)
|
Function select_array($name, $array, $id='', $empty=0)
|
||||||
|
|||||||
@@ -51,10 +51,12 @@ if ($user->rights->facture->lire)
|
|||||||
|
|
||||||
$info_box_contents[$i][0] = array('align' => 'left',
|
$info_box_contents[$i][0] = array('align' => 'left',
|
||||||
'text' => $objp->facnumber,
|
'text' => $objp->facnumber,
|
||||||
|
'width' => '30%',
|
||||||
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);
|
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);
|
||||||
|
|
||||||
$info_box_contents[$i][1] = array('align' => 'left',
|
$info_box_contents[$i][1] = array('align' => 'left',
|
||||||
'text' => $objp->nom,
|
'text' => $objp->nom,
|
||||||
|
'width' => '70%',
|
||||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,10 +49,12 @@ if ($user->rights->facture->lire)
|
|||||||
|
|
||||||
$info_box_contents[$i][0] = array('align' => 'left',
|
$info_box_contents[$i][0] = array('align' => 'left',
|
||||||
'text' => $objp->facnumber,
|
'text' => $objp->facnumber,
|
||||||
|
'width' => '30%',
|
||||||
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);
|
'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);
|
||||||
|
|
||||||
$info_box_contents[$i][1] = array('align' => 'left',
|
$info_box_contents[$i][1] = array('align' => 'left',
|
||||||
'text' => $objp->nom,
|
'text' => $objp->nom,
|
||||||
|
'width' => '70%',
|
||||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@@ -50,10 +50,12 @@ if ($user->rights->propale->lire)
|
|||||||
|
|
||||||
$info_box_contents[$i][0] = array('align' => 'left',
|
$info_box_contents[$i][0] = array('align' => 'left',
|
||||||
'text' => $objp->ref,
|
'text' => $objp->ref,
|
||||||
|
'width' => '30%',
|
||||||
'url' => DOL_URL_ROOT."/comm/propal.php?propalid=".$objp->rowid);
|
'url' => DOL_URL_ROOT."/comm/propal.php?propalid=".$objp->rowid);
|
||||||
|
|
||||||
$info_box_contents[$i][1] = array('align' => 'center',
|
$info_box_contents[$i][1] = array('align' => 'center',
|
||||||
'text' => $objp->nom,
|
'text' => $objp->nom,
|
||||||
|
'width' => '70%',
|
||||||
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->idp);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ for ($ii=0, $ni=sizeof($boxes); $ii<$ni; $ii++)
|
|||||||
print "<tr>\n";
|
print "<tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<td valign="top">';
|
print '<td valign="top" width="50%">';
|
||||||
include($boxes[$ii]);
|
include($boxes[$ii]);
|
||||||
print "</td>";
|
print "</td>";
|
||||||
|
|
||||||
|
|||||||
@@ -104,10 +104,25 @@ class DoliDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Function close()
|
Function close()
|
||||||
{
|
{
|
||||||
$this->ret = mysql_close($this->db);
|
$this->ret = mysql_close($this->db);
|
||||||
return $this->ret;
|
return $this->ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function begin()
|
||||||
|
{
|
||||||
|
return $this->query("BEGIN");
|
||||||
|
}
|
||||||
|
|
||||||
|
Function commit()
|
||||||
|
{
|
||||||
|
return $this->query("COMMIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
Function rollback()
|
||||||
|
{
|
||||||
|
return $this->query("ROLLBACK");
|
||||||
|
}
|
||||||
|
|
||||||
Function query($query, $limit="", $offset="")
|
Function query($query, $limit="", $offset="")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class Product
|
|||||||
var $price;
|
var $price;
|
||||||
var $tva_tx;
|
var $tva_tx;
|
||||||
var $type;
|
var $type;
|
||||||
|
var $seuil_stock_alerte;
|
||||||
var $duration_value;
|
var $duration_value;
|
||||||
var $duration_unit;
|
var $duration_unit;
|
||||||
|
|
||||||
@@ -184,6 +185,7 @@ class Product
|
|||||||
$sql .= ",ref = '" . trim($this->ref) ."'";
|
$sql .= ",ref = '" . trim($this->ref) ."'";
|
||||||
$sql .= ",tva_tx = " . $this->tva_tx ;
|
$sql .= ",tva_tx = " . $this->tva_tx ;
|
||||||
$sql .= ",envente = " . $this->envente ;
|
$sql .= ",envente = " . $this->envente ;
|
||||||
|
$sql .= ",seuil_stock_alerte = " . $this->seuil_stock_alerte ;
|
||||||
$sql .= ",description = '" . trim($this->description) ."'";
|
$sql .= ",description = '" . trim($this->description) ."'";
|
||||||
$sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
|
$sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
|
||||||
|
|
||||||
@@ -211,7 +213,7 @@ class Product
|
|||||||
*/
|
*/
|
||||||
Function fetch ($id)
|
Function fetch ($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente, fk_product_type, duration";
|
$sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente, fk_product_type, duration, seuil_stock_alerte";
|
||||||
$sql .= " FROM llx_product WHERE rowid = $id";
|
$sql .= " FROM llx_product WHERE rowid = $id";
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
$result = $this->db->query($sql) ;
|
||||||
@@ -220,22 +222,49 @@ class Product
|
|||||||
{
|
{
|
||||||
$result = $this->db->fetch_array();
|
$result = $this->db->fetch_array();
|
||||||
|
|
||||||
$this->id = $result["rowid"];
|
$this->id = $result["rowid"];
|
||||||
$this->ref = $result["ref"];
|
$this->ref = $result["ref"];
|
||||||
$this->libelle = stripslashes($result["label"]);
|
$this->libelle = stripslashes($result["label"]);
|
||||||
$this->description = stripslashes($result["description"]);
|
$this->description = stripslashes($result["description"]);
|
||||||
$this->price = $result["price"];
|
$this->price = $result["price"];
|
||||||
$this->tva_tx = $result["tva_tx"];
|
$this->tva_tx = $result["tva_tx"];
|
||||||
$this->type = $result["fk_product_type"];
|
$this->type = $result["fk_product_type"];
|
||||||
$this->nbvente = $result["nbvente"];
|
$this->nbvente = $result["nbvente"];
|
||||||
$this->envente = $result["envente"];
|
$this->envente = $result["envente"];
|
||||||
$this->duration = $result["duration"];
|
$this->duration = $result["duration"];
|
||||||
$this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1);
|
$this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1);
|
||||||
$this->duration_unit = substr($result["duration"],-1);
|
$this->duration_unit = substr($result["duration"],-1);
|
||||||
|
$this->seuil_stock_alerte = $result["seuil_stock_alerte"];
|
||||||
|
|
||||||
$this->label_url = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">'.$this->label.'</a>';
|
$this->label_url = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">'.$this->label.'</a>';
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free();
|
||||||
|
|
||||||
|
|
||||||
|
$sql = "SELECT sum(reel) as reel";
|
||||||
|
$sql .= " FROM llx_product_stock WHERE fk_product = $id";
|
||||||
|
$result = $this->db->query($sql) ;
|
||||||
|
if ( $result )
|
||||||
|
{
|
||||||
|
$num = $this->db->num_rows();
|
||||||
|
if ($num > 0)
|
||||||
|
{
|
||||||
|
$result = $this->db->fetch_array();
|
||||||
|
|
||||||
|
$this->no_stock = 0;
|
||||||
|
|
||||||
|
$this->stock_reel = $result["reel"];
|
||||||
|
$this->stock_proposition = $result["proposition"];
|
||||||
|
$this->stock_commande = $result["commande"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->no_stock = 1;
|
||||||
|
}
|
||||||
|
$this->db->free();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -431,5 +460,108 @@ class Product
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
Function create_stock($id_entrepot, $nbpiece)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "INSERT INTO llx_product_stock ";
|
||||||
|
$sql .= " (fk_product, fk_entrepot, reel, commande, proposition)";
|
||||||
|
$sql .= " VALUES ($this->id, $id_entrepot, $nbpiece, $nbpiece, $nbpiece)";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error() . ' in ' . $sql;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Function correct_stock($user, $id_entrepot, $nbpiece, $mouvement)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "SELECT count(*) FROM llx_product_stock ";
|
||||||
|
$sql .= " WHERE fk_product = $this->id AND fk_entrepot = $id_entrepot";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$row = $this->db->fetch_row(0);
|
||||||
|
if ($row[0] > 0)
|
||||||
|
{
|
||||||
|
return $this->ajust_stock($user, $id_entrepot, $nbpiece, $mouvement);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $this->create_stock($id_entrepot, $nbpiece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error() . ' in ' . $sql;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Function ajust_stock($user, $id_entrepot, $nbpiece, $mouvement)
|
||||||
|
{
|
||||||
|
/* mouvement = 0 -> ajouter
|
||||||
|
* mouvement = 1 -> supprimer
|
||||||
|
*/
|
||||||
|
$op[0] = "+" . trim($nbpiece);
|
||||||
|
$op[1] = "-" . trim($nbpiece);
|
||||||
|
|
||||||
|
if ($this->db->begin())
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "UPDATE llx_product ";
|
||||||
|
$sql .= " SET stock_commande = stock_commande ".$op[$mouvement].", stock_propale = stock_propale ".$op[$mouvement];
|
||||||
|
$sql .= " WHERE rowid = $this->id ";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$sql = "UPDATE llx_product_stock ";
|
||||||
|
$sql .= " SET reel = reel ".$op[$mouvement];
|
||||||
|
$sql .= " WHERE fk_product = $this->id AND fk_entrepot = $id_entrepot";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO llx_stock_mouvement (datem, fk_product, fk_entrepot, value, type_mouvement, fk_user_author)";
|
||||||
|
$sql .= " VALUES (now(), $this->id, $id_entrepot, ".$op[$mouvement].", 0, $user->id)";
|
||||||
|
|
||||||
|
if ($this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error() . ' in ' . $sql;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error() . ' in ' . $sql;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $this->db->error() . ' in ' . $sql;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ if ($action == 'add')
|
|||||||
$product->description = $HTTP_POST_VARS["desc"];
|
$product->description = $HTTP_POST_VARS["desc"];
|
||||||
$product->duration_value = $HTTP_POST_VARS["duration_value"];
|
$product->duration_value = $HTTP_POST_VARS["duration_value"];
|
||||||
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
|
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
|
||||||
|
$product->seuil_stock_alerte = $HTTP_POST_VARS["seuil_stock_alerte"];
|
||||||
|
|
||||||
$id = $product->create($user);
|
$id = $product->create($user);
|
||||||
$action = '';
|
$action = '';
|
||||||
@@ -118,12 +119,13 @@ if ($HTTP_POST_VARS["action"] == 'update' &&
|
|||||||
if ($product->fetch($id))
|
if ($product->fetch($id))
|
||||||
{
|
{
|
||||||
|
|
||||||
$product->ref = $HTTP_POST_VARS["ref"];
|
$product->ref = $HTTP_POST_VARS["ref"];
|
||||||
$product->libelle = $HTTP_POST_VARS["libelle"];
|
$product->libelle = $HTTP_POST_VARS["libelle"];
|
||||||
$product->price = $HTTP_POST_VARS["price"];
|
$product->price = $HTTP_POST_VARS["price"];
|
||||||
$product->tva_tx = $HTTP_POST_VARS["tva_tx"];
|
$product->tva_tx = $HTTP_POST_VARS["tva_tx"];
|
||||||
$product->description = $HTTP_POST_VARS["desc"];
|
$product->description = $HTTP_POST_VARS["desc"];
|
||||||
$product->envente = $HTTP_POST_VARS["statut"];
|
$product->envente = $HTTP_POST_VARS["statut"];
|
||||||
|
$product->seuil_stock_alerte = $HTTP_POST_VARS["seuil_stock_alerte"];
|
||||||
$product->duration_value = $HTTP_POST_VARS["duration_value"];
|
$product->duration_value = $HTTP_POST_VARS["duration_value"];
|
||||||
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
|
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
|
||||||
|
|
||||||
@@ -192,11 +194,21 @@ if ($action == 'create')
|
|||||||
print "<tr>".'<td>Taux TVA</td><TD>';
|
print "<tr>".'<td>Taux TVA</td><TD>';
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
print $html->select_tva("tva_tx");
|
print $html->select_tva("tva_tx");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print "<tr>".'<td valign="top">Description</td><td>';
|
if ($_GET["type"] == 0)
|
||||||
|
{
|
||||||
|
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
|
||||||
|
print '<input name="seuil_stock_alerte" size="4" value="0">';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||||||
|
}
|
||||||
|
print '<tr><td valign="top">Description</td><td>';
|
||||||
print '<textarea name="desc" rows="8" cols="50">';
|
print '<textarea name="desc" rows="8" cols="50">';
|
||||||
print "</textarea></td></tr>";
|
print "</textarea></td></tr>";
|
||||||
if ($type == 1)
|
if ($_GET["type"] == 1)
|
||||||
{
|
{
|
||||||
print "<tr>".'<td>Dur<75>e</td><TD><input name="duration_value" size="6" maxlength="5" value="'.$product->duree.'">';
|
print "<tr>".'<td>Dur<75>e</td><TD><input name="duration_value" size="6" maxlength="5" value="'.$product->duree.'">';
|
||||||
print '<input name="duration_unit" type="radio" value="d">jour ';
|
print '<input name="duration_unit" type="radio" value="d">jour ';
|
||||||
@@ -279,7 +291,24 @@ else
|
|||||||
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print "<tr>".'<td>Taux TVA</td><TD>'.$product->tva_tx.' %</td></tr>';
|
print '<tr><td>Taux TVA</td><TD>'.$product->tva_tx.' %</td></tr>';
|
||||||
|
print '<tr><td><a href="stock/product.php?id='.$product->id.'">Stock</a></td>';
|
||||||
|
if ($product->no_stock)
|
||||||
|
{
|
||||||
|
print "<td>Pas de d<>finition de stock pour ce produit";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($product->stock_reel <= $product->seuil_stock_alerte)
|
||||||
|
{
|
||||||
|
print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<td>".$product->stock_reel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
print "<tr><td valign=\"top\">Description</td><td>".nl2br($product->description)."</td></tr>";
|
print "<tr><td valign=\"top\">Description</td><td>".nl2br($product->description)."</td></tr>";
|
||||||
|
|
||||||
if ($product->type == 1)
|
if ($product->type == 1)
|
||||||
@@ -385,6 +414,16 @@ else
|
|||||||
print '<option value="0" SELECTED>Hors Vente</option>';
|
print '<option value="0" SELECTED>Hors Vente</option>';
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
if ($product->type == 0)
|
||||||
|
{
|
||||||
|
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
|
||||||
|
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||||||
|
}
|
||||||
print "<tr>".'<td valign="top">Description</td><td colspan="2">';
|
print "<tr>".'<td valign="top">Description</td><td colspan="2">';
|
||||||
print '<textarea name="desc" rows="8" cols="50">';
|
print '<textarea name="desc" rows="8" cols="50">';
|
||||||
print $product->description;
|
print $product->description;
|
||||||
@@ -452,7 +491,7 @@ if ($action == '')
|
|||||||
{
|
{
|
||||||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||||||
{
|
{
|
||||||
print '<td width="20%" align="center">[<a href="fiche.php?action=edit_price&id='.$id.'">Changer le prix</a>]</td>';
|
print '<td width="20%" align="center"><a href="fiche.php?action=edit_price&id='.$id.'">Changer le prix</a></td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -464,13 +503,12 @@ else
|
|||||||
print '<td width="20%" align="center">-</td>';
|
print '<td width="20%" align="center">-</td>';
|
||||||
}
|
}
|
||||||
print '<td width="20%" align="center">-</td>';
|
print '<td width="20%" align="center">-</td>';
|
||||||
print '<td width="20%" align="center">-</td>';
|
|
||||||
|
|
||||||
if ($action == '')
|
if ($action == '')
|
||||||
{
|
{
|
||||||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||||||
{
|
{
|
||||||
print '<td width="20%" align="center">[<a href="fiche.php?action=edit&id='.$id.'">Editer</a>]</td>';
|
print '<td width="20%" align="center"><a href="fiche.php?action=edit&id='.$id.'">Editer</a></td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -482,6 +520,9 @@ else
|
|||||||
print '<td width="20%" align="center">-</td>';
|
print '<td width="20%" align="center">-</td>';
|
||||||
}
|
}
|
||||||
print '<td width="20%" align="center">-</td>';
|
print '<td width="20%" align="center">-</td>';
|
||||||
|
|
||||||
|
print '<td width="20%" align="center"><a href="stock/product.php?id='.$id.'&action=correction">Correction stock</a></td>';
|
||||||
|
|
||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
|
|
||||||
if ($id && $action == '' && $product->envente)
|
if ($id && $action == '' && $product->envente)
|
||||||
@@ -524,6 +565,7 @@ if ($id && $action == '' && $product->envente)
|
|||||||
print '<input type="hidden" name="action" value="addinpropal">';
|
print '<input type="hidden" name="action" value="addinpropal">';
|
||||||
print '<td><input type="hidden" name="propalid" value="'.$objp->propalid.'">';
|
print '<td><input type="hidden" name="propalid" value="'.$objp->propalid.'">';
|
||||||
print '<input type="text" name="qty" size="3" value="1">';
|
print '<input type="text" name="qty" size="3" value="1">';
|
||||||
|
print " ".$product->stock_proposition;
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print '<input type="submit" value="Ajouter">';
|
print '<input type="submit" value="Ajouter">';
|
||||||
print "</td>";
|
print "</td>";
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ function llxHeader($head = "", $urlp = "", $title="")
|
|||||||
$menu->add("stats/", "Statistiques");
|
$menu->add("stats/", "Statistiques");
|
||||||
$menu->add_submenu("popuprop.php", "Popularit<EFBFBD>");
|
$menu->add_submenu("popuprop.php", "Popularit<EFBFBD>");
|
||||||
|
|
||||||
|
$menu->add("stock/", "Stock");
|
||||||
|
|
||||||
left_menu($menu->liste);
|
left_menu($menu->liste);
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -325,6 +325,7 @@ class Propal
|
|||||||
$this->total_tva = $obj->tva;
|
$this->total_tva = $obj->tva;
|
||||||
$this->total_ttc = $obj->total;
|
$this->total_ttc = $obj->total;
|
||||||
$this->socidp = $obj->fk_soc;
|
$this->socidp = $obj->fk_soc;
|
||||||
|
$this->soc_id = $obj->fk_soc;
|
||||||
$this->contactid = $obj->fk_soc_contact;
|
$this->contactid = $obj->fk_soc_contact;
|
||||||
$this->modelpdf = $obj->model_pdf;
|
$this->modelpdf = $obj->model_pdf;
|
||||||
$this->note = $obj->note;
|
$this->note = $obj->note;
|
||||||
@@ -474,7 +475,7 @@ class Propal
|
|||||||
print $this->db->error() . ' in ' . $sql;
|
print $this->db->error() . ' in ' . $sql;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -499,20 +500,31 @@ class Propal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/**
|
||||||
*
|
* Cloture de la propale
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function cloture($userid, $statut, $note)
|
Function cloture($user, $statut, $note)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE llx_propal SET fk_statut = $statut, note = '$note', date_cloture=now(), fk_user_cloture=$userid";
|
$sql = "UPDATE llx_propal SET fk_statut = $statut, note = '$note', date_cloture=now(), fk_user_cloture=$user->id";
|
||||||
|
|
||||||
$sql .= " WHERE rowid = $this->id;";
|
$sql .= " WHERE rowid = $this->id;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
return 1;
|
if ($statut == 2)
|
||||||
|
{
|
||||||
|
/* Propale sign<67>e */
|
||||||
|
include_once DOL_DOCUMENT_ROOT . "/commande/commande.class.php";
|
||||||
|
$commande = new Commande($this->db);
|
||||||
|
$commande->create_from_propale($user, $this->id);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Propale non sign<67>e */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user