GEstion de la suppression
This commit is contained in:
parent
9863191ff3
commit
95d95a34e9
@ -33,16 +33,15 @@ $langs->load("orders");
|
|||||||
$langs->load("suppliers");
|
$langs->load("suppliers");
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
|
|
||||||
$user->getrights('commande');
|
|
||||||
$user->getrights('expedition');
|
|
||||||
|
|
||||||
if (!$user->rights->commande->lire)
|
$user->getrights('fournisseur');
|
||||||
|
|
||||||
|
if (!$user->rights->fournisseur->commande->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
require_once "../../project.class.php";
|
require_once "../../project.class.php";
|
||||||
require_once "../../propal.class.php";
|
require_once "../../propal.class.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/fournisseur.class.php";
|
require_once DOL_DOCUMENT_ROOT."/fournisseur.class.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/fournisseur.commande.class.php";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sécurité accés client
|
* Sécurité accés client
|
||||||
@ -76,7 +75,7 @@ if ($_POST["action"] == 'setremise' && $user->rights->commande->creer)
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if ($_POST["action"] == 'addligne' && $user->rights->commande->creer)
|
if ($_POST["action"] == 'addligne' && $user->rights->fournisseur->commande->creer)
|
||||||
{
|
{
|
||||||
$comf = new CommandeFournisseur($db);
|
$comf = new CommandeFournisseur($db);
|
||||||
$comf->fetch($_GET["id"]);
|
$comf->fetch($_GET["id"]);
|
||||||
@ -119,38 +118,55 @@ if ($_POST["action"] == 'updateligne' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer)
|
if ($_GET["action"] == 'deleteline' && $user->rights->fournisseur->commande->creer)
|
||||||
{
|
{
|
||||||
$comf = new CommandeFournisseur($db);
|
$comf = new CommandeFournisseur($db);
|
||||||
$comf->fetch($_GET["id"]);
|
$comf->fetch($_GET["id"]);
|
||||||
$result = $comf->delete_line($_GET["lineid"]);
|
$result = $comf->delete_line($_GET["lineid"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->rights->commande->valider)
|
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->valider)
|
||||||
{
|
{
|
||||||
$commande = new CommandeFournisseur($db);
|
$commande = new CommandeFournisseur($db);
|
||||||
$commande->fetch($_GET["id"]);
|
$commande->fetch($_GET["id"]);
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($commande->soc_id);
|
$soc->fetch($commande->soc_id);
|
||||||
$result = $commande->valid($user);
|
$result = $commande->valid($user);
|
||||||
|
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->commande->valider)
|
if ($_POST["action"] == 'confirm_approve' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->approuver)
|
||||||
{
|
{
|
||||||
$commande = new CommandeFournisseur($db);
|
$commande = new CommandeFournisseur($db);
|
||||||
$commande->fetch($_GET["id"]);
|
$commande->fetch($_GET["id"]);
|
||||||
$result = $commande->cancel($user);
|
$result = $commande->approve($user);
|
||||||
|
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes)
|
if ($_POST["action"] == 'confirm_refuse' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->approuver)
|
||||||
|
{
|
||||||
|
$commande = new CommandeFournisseur($db);
|
||||||
|
$commande->fetch($_GET["id"]);
|
||||||
|
$result = $commande->refuse($user);
|
||||||
|
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_POST["action"] == 'confirm_commande' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->commander)
|
||||||
|
{
|
||||||
|
$commande = new CommandeFournisseur($db);
|
||||||
|
$commande->fetch($_GET["id"]);
|
||||||
|
$result = $commande->commande($user, $_GET["datecommande"], $_GET["methode"]);
|
||||||
|
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->creer )
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->supprimer )
|
|
||||||
{
|
|
||||||
$commande = new CommandeFournisseur($db);
|
$commande = new CommandeFournisseur($db);
|
||||||
$commande->id = $_GET["id"];
|
$commande->id = $_GET["id"];
|
||||||
$commande->delete();
|
$commande->delete();
|
||||||
Header("Location: index.php");
|
Header("Location: index.php");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET["action"] == 'pdf')
|
if ($_GET["action"] == 'pdf')
|
||||||
@ -200,11 +216,16 @@ if ($id > 0)
|
|||||||
$author->id = $commande->user_author_id;
|
$author->id = $commande->user_author_id;
|
||||||
$author->fetch();
|
$author->fetch();
|
||||||
|
|
||||||
|
$h = 0;
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
|
||||||
|
$head[$h][1] = $langs->trans("Order").": $commande->ref";
|
||||||
|
$a = $h;
|
||||||
|
$h++;
|
||||||
|
|
||||||
$head[0][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
|
|
||||||
$head[0][1] = $langs->trans("Order").": $commande->ref";
|
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
|
||||||
$h = 1;
|
$head[$h][1] = $langs->trans("History");
|
||||||
$a = 0;
|
$h++;
|
||||||
|
|
||||||
dolibarr_fiche_head($head, $a, $soc->nom);
|
dolibarr_fiche_head($head, $a, $soc->nom);
|
||||||
|
|
||||||
@ -215,6 +236,7 @@ if ($id > 0)
|
|||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
$html->form_confirm("fiche.php?id=$id","Supprimer la commande","Etes-vous sûr de vouloir supprimer cette commande ?","confirm_delete");
|
$html->form_confirm("fiche.php?id=$id","Supprimer la commande","Etes-vous sûr de vouloir supprimer cette commande ?","confirm_delete");
|
||||||
|
print '<br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -223,8 +245,26 @@ if ($id > 0)
|
|||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'valid')
|
if ($_GET["action"] == 'valid')
|
||||||
{
|
{
|
||||||
//$numfa = commande_get_num($soc);
|
|
||||||
$html->form_confirm("fiche.php?id=$id","Valider la commande","Etes-vous sûr de vouloir valider cette commande ?","confirm_valid");
|
$html->form_confirm("fiche.php?id=$id","Valider la commande","Etes-vous sûr de vouloir valider cette commande ?","confirm_valid");
|
||||||
|
print '<br />';
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Confirmation de l'approbation
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ($_GET["action"] == 'approve')
|
||||||
|
{
|
||||||
|
$html->form_confirm("fiche.php?id=$id","Approuver la commande","Etes-vous sûr de vouloir approuver cette commande ?","confirm_approve");
|
||||||
|
print '<br />';
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Confirmation de l'approbation
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ($_GET["action"] == 'refuse')
|
||||||
|
{
|
||||||
|
$html->form_confirm("fiche.php?id=$id","Refuser la commande","Etes-vous sûr de vouloir refuser cette commande ?","confirm_refuse");
|
||||||
|
print '<br />';
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Confirmation de l'annulation
|
* Confirmation de l'annulation
|
||||||
@ -233,16 +273,26 @@ if ($id > 0)
|
|||||||
if ($_GET["action"] == 'annuler')
|
if ($_GET["action"] == 'annuler')
|
||||||
{
|
{
|
||||||
$html->form_confirm("fiche.php?id=$id",$langs->trans("Cancel"),"Etes-vous sûr de vouloir annuler cette commande ?","confirm_cancel");
|
$html->form_confirm("fiche.php?id=$id",$langs->trans("Cancel"),"Etes-vous sûr de vouloir annuler cette commande ?","confirm_cancel");
|
||||||
|
print '<br />';
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Confirmation de l'envoi de la commande
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ($_GET["action"] == 'commande')
|
||||||
|
{
|
||||||
|
$date_com = mktime(12,12,12,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
|
||||||
|
$html->form_confirm("fiche.php?id=".$commande->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"],
|
||||||
|
"Envoi de la commande","Etes-vous sûr de vouloir confirmer cette commande en date du ".strftime("%d/%m/%Y",$date_com)." ?","confirm_commande");
|
||||||
|
print '<br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Commande
|
* Commande
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print "<tr><td>".$langs->trans("Supplier")."</td>";
|
print "<tr><td>".$langs->trans("Supplier")."</td>";
|
||||||
print '<td colspan="2">';
|
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.'/fourn/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
||||||
|
|
||||||
print '<td width="50%">';
|
print '<td width="50%">';
|
||||||
print '<img src="statut'.$commande->statut.'.png"> ';
|
print '<img src="statut'.$commande->statut.'.png"> ';
|
||||||
@ -250,13 +300,20 @@ if ($id > 0)
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||||
print "<td colspan=\"2\">".strftime("%A %d %B %Y",$commande->date)."</td>\n";
|
print '<td colspan="2">';
|
||||||
|
|
||||||
print '<td width="50%"> ';
|
if ($commande->date_commande)
|
||||||
|
{
|
||||||
|
print strftime("%A %d %B %Y",$commande->date_commande)."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print ' </td><td width="50%">';
|
||||||
|
if ($commande->methode_commande)
|
||||||
|
{
|
||||||
|
print "Méthode : " .$commande->methode_commande;
|
||||||
|
}
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Author").'</td><td colspan="2">'.$author->fullname.'</td>';
|
print '<tr><td>'.$langs->trans("Author").'</td><td colspan="2">'.$author->fullname.'</td>';
|
||||||
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print " </td></tr>";
|
print " </td></tr>";
|
||||||
|
|
||||||
@ -292,10 +349,10 @@ if ($id > 0)
|
|||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num_lignes = $db->num_rows();
|
||||||
$i = 0; $total = 0;
|
$i = 0; $total = 0;
|
||||||
|
|
||||||
if ($num)
|
if ($num_lignes)
|
||||||
{
|
{
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td width="8%" align="left">'.$langs->trans("Ref").'</td>';
|
print '<td width="8%" align="left">'.$langs->trans("Ref").'</td>';
|
||||||
@ -308,7 +365,7 @@ if ($id > 0)
|
|||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
$var=True;
|
$var=True;
|
||||||
while ($i < $num)
|
while ($i < $num_lignes)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object();
|
$objp = $db->fetch_object();
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
@ -333,12 +390,13 @@ if ($id > 0)
|
|||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
}
|
}
|
||||||
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->fournisseur->commande->creer)
|
||||||
{
|
{/*
|
||||||
print '<td align="right"><a href="fiche.php?id='.$id.'&action=editline&rowid='.$objp->rowid.'">';
|
print '<td align="right"><a href="fiche.php?id='.$id.'&action=editline&rowid='.$objp->rowid.'">';
|
||||||
print img_edit();
|
print img_edit();
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
print '<td align="right"><a href="fiche.php?id='.$id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
*/
|
||||||
|
print '<td> </td><td align="right"><a href="fiche.php?id='.$id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
||||||
print img_delete();
|
print img_delete();
|
||||||
print '</a></td>';
|
print '</a></td>';
|
||||||
}
|
}
|
||||||
@ -376,7 +434,7 @@ if ($id > 0)
|
|||||||
* Ajouter une ligne
|
* Ajouter une ligne
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if ($commande->statut == 0 && $user->rights->commande->creer)
|
if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer)
|
||||||
{
|
{
|
||||||
$sql = "SELECT p.rowid,p.label,p.ref,p.price ";
|
$sql = "SELECT p.rowid,p.label,p.ref,p.price ";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."product as p ";
|
$sql .= " FROM ".MAIN_DB_PREFIX."product as p ";
|
||||||
@ -414,6 +472,7 @@ if ($id > 0)
|
|||||||
print '<td width="12%" align="right">P.U.</TD>';
|
print '<td width="12%" align="right">P.U.</TD>';
|
||||||
print '<td> </td><td> </td>'."</tr>\n";
|
print '<td> </td><td> </td>'."</tr>\n";
|
||||||
|
|
||||||
|
/*
|
||||||
print "<tr $bc[$var]>".'<td colspan="2"><textarea name="desc" cols="60" rows="1"></textarea></td>';
|
print "<tr $bc[$var]>".'<td colspan="2"><textarea name="desc" cols="60" rows="1"></textarea></td>';
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
print $html->select_tva("tva_tx",$conf->defaulttx);
|
print $html->select_tva("tva_tx",$conf->defaulttx);
|
||||||
@ -423,6 +482,7 @@ if ($id > 0)
|
|||||||
print '<td align="right"><input type="text" name="pu" size="8"></td>';
|
print '<td align="right"><input type="text" name="pu" size="8"></td>';
|
||||||
|
|
||||||
print '<td align="center" colspan="3"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
|
print '<td align="center" colspan="3"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
|
||||||
|
*/
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]>".'<td colspan="3"><select name="p_idprod">'.$opt.'</select></td>';
|
print "<tr $bc[$var]>".'<td colspan="3"><select name="p_idprod">'.$opt.'</select></td>';
|
||||||
@ -446,20 +506,17 @@ if ($id > 0)
|
|||||||
{
|
{
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
if ($commande->statut == 0)
|
||||||
|
{
|
||||||
|
if ($user->rights->fournisseur->commande->creer)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
|
|
||||||
{
|
|
||||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$_GET["id"].'">Expédier</a>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($commande->statut == 0 && $num_lignes > 0)
|
||||||
if ($commande->statut == 0)
|
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->valider)
|
if ($user->rights->fournisseur->commande->valider)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||||
}
|
}
|
||||||
@ -467,10 +524,19 @@ if ($id > 0)
|
|||||||
|
|
||||||
if ($commande->statut == 1)
|
if ($commande->statut == 1)
|
||||||
{
|
{
|
||||||
$nb_expedition = $commande->nb_expedition();
|
if ($user->rights->fournisseur->commande->approuver)
|
||||||
if ($user->rights->commande->valider && $nb_expedition == 0)
|
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=annuler">'.$langs->trans("Cancel").'</a>';
|
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=approve">'.$langs->trans("ApproveOrder").'</a>';
|
||||||
|
|
||||||
|
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($commande->statut == 2)
|
||||||
|
{
|
||||||
|
if ($user->rights->fournisseur->commande->approuver)
|
||||||
|
{
|
||||||
|
print '<a class="tabAction" href="fiche.php?id='.$id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +591,7 @@ if ($id > 0)
|
|||||||
$sql .= " WHERE f.rowid = cf.fk_facture AND cf.fk_commande = ". $commande->id;
|
$sql .= " WHERE f.rowid = cf.fk_facture AND cf.fk_commande = ". $commande->id;
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result && 0)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows();
|
||||||
if ($num)
|
if ($num)
|
||||||
@ -562,7 +628,6 @@ if ($id > 0)
|
|||||||
|
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
|
|
||||||
print_titre("Documents");
|
print_titre("Documents");
|
||||||
print '<table width="100%" class="border">';
|
print '<table width="100%" class="border">';
|
||||||
|
|
||||||
@ -596,6 +661,32 @@ if ($id > 0)
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Commander
|
||||||
|
*/
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
print '<form action="fiche.php?id='.$commande->id.'&action=commande" method="post">';
|
||||||
|
print '<table class="noborder" cellpadding="4" cellspacing="0">';
|
||||||
|
print '<tr class="liste_titre"><td colspan="2">Commander</td></tr>';
|
||||||
|
print '<tr><td>Date commande</td><td>';
|
||||||
|
print $form->select_date();
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
$commande->get_methodes_commande();
|
||||||
|
|
||||||
|
print '<tr><td>Méthode de commande</td><td>';
|
||||||
|
|
||||||
|
print $form->select_array("methodecommande",$commande->methodes_commande);
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
print '<tr><td>Commentaire</td><td><input size="30" type="text" name="commentaire"></td></tr>';
|
||||||
|
print '<tr><td align="center" colspan="2"><input type="submit" name="Activer"></td></tr>';
|
||||||
|
print '</table>';
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user