Uniformisation du code des commandes fournisseurs.
Affichage du picto sur le statut
This commit is contained in:
parent
b3bfe260c7
commit
654a897d58
@ -256,453 +256,463 @@ $html = new Form($db);
|
||||
|
||||
if ($_GET["id"] > 0)
|
||||
{
|
||||
if ($mesg) print $mesg;
|
||||
$commande = new CommandeFournisseur($db);
|
||||
|
||||
if ( $commande->fetch($_GET["id"]) == 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->soc_id);
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
$h = 0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderCard");
|
||||
$a = $h;
|
||||
$h++;
|
||||
// if ($mesg) print $mesg;
|
||||
$commande = new CommandeFournisseur($db);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderFollow");
|
||||
$h++;
|
||||
|
||||
$title=$langs->trans("Order").": $commande->ref";
|
||||
dolibarr_fiche_head($head, $a, $title);
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression de la commande
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'delete')
|
||||
if ( $commande->fetch($_GET["id"]) == 0)
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=$commande->id","Supprimer la commande","Etes-vous sûr de vouloir supprimer cette commande ?","confirm_delete");
|
||||
print '<br />';
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'valid')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=$commande->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=$commande->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=$commande->id","Refuser la commande","Etes-vous sûr de vouloir refuser cette commande ?","confirm_refuse");
|
||||
print '<br />';
|
||||
}
|
||||
/*
|
||||
* Confirmation de l'annulation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'cancel')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=$commande->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(0,0,0,$_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 />';
|
||||
}
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->soc_id);
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
/*
|
||||
* Commande
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Supplier")."</td>";
|
||||
print '<td colspan="5">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id.'">';
|
||||
print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'</a></b></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Status").'</td>';
|
||||
print '<td width="50%" colspan="5">';
|
||||
print '<img src="statut'.$commande->statut.'.png"> ';
|
||||
print $commande->statuts[$commande->statut];
|
||||
print "</td></tr>";
|
||||
|
||||
if ($commande->methode_commande_id > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
|
||||
|
||||
if ($commande->date_commande)
|
||||
{
|
||||
print dolibarr_print_date($commande->date_commande,"%A %d %B %Y")."\n";
|
||||
}
|
||||
|
||||
print '</td><td width="50%" colspan="3">';
|
||||
if ($commande->methode_commande)
|
||||
{
|
||||
print "Méthode : " .$commande->methode_commande;
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Auteur
|
||||
print '<tr><td>'.$langs->trans("Author").'</td><td colspan="2">'.$author->fullname.'</td>';
|
||||
print '<td colspan="3" width="50%">';
|
||||
print " </td></tr>";
|
||||
$h = 0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderCard");
|
||||
$a = $h;
|
||||
$h++;
|
||||
|
||||
// Ligne de 3 colonnes
|
||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="3"> </td></tr>';
|
||||
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="3"> </td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="3"> </td></tr>';
|
||||
|
||||
print "</table>";
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$h++;
|
||||
|
||||
if ($mesg) print $mesg;
|
||||
else print '<br>';
|
||||
|
||||
/*
|
||||
* Lignes de commandes
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
$sql = "SELECT l.ref, l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
|
||||
$sql.= " WHERE l.fk_commande = $commande->id";
|
||||
$sql.= " ORDER BY l.rowid";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_lignes = $db->num_rows($resql);
|
||||
$i = 0; $total = 0;
|
||||
|
||||
if ($num_lignes)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$langs->trans("Ref").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</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> </td><td width="10%"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=false;
|
||||
while ($i < $num_lignes)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a></td>';
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/fourn/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
|
||||
}
|
||||
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";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && $_GET["action"] <> 'valid')
|
||||
{
|
||||
print '<td> </td><td align="right"><a href="fiche.php?id='.$commande->id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td><td> </td>';
|
||||
}
|
||||
print "</tr>";
|
||||
|
||||
if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid)
|
||||
{
|
||||
print "<form action=\"fiche.php?id=$commande->id\" method=\"post\">";
|
||||
print '<input type="hidden" name="action" value="updateligne">';
|
||||
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">';
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td colspan="3"><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 align="right"><input size="3" type="text" name="elremise_percent" value="'.$objp->remise_percent.'"> %</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" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
print '</tr>' . "\n";
|
||||
print "</form>\n";
|
||||
}
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajouter une ligne
|
||||
*/
|
||||
if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc'))
|
||||
{
|
||||
print '<form action="fiche.php?id='.$commande->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">'.$langs->trans("Description").'</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> </td><td> </td>'."</tr>\n";
|
||||
|
||||
$var=false;
|
||||
print "<tr $bc[$var]>".'<td colspan="3">';
|
||||
$html->select_produits_fournisseurs($commande->fourn_id,'','p_idprod',$filtre);
|
||||
print '</td>';
|
||||
print '<td align="center"><input type="text" size="2" name="pqty" value="1"></td>';
|
||||
print '<td align="right"><input type="text" size="3" name="premise" value="0">%</td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
|
||||
print "</tr>\n";
|
||||
|
||||
print "</form>";
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderFollow");
|
||||
$h++;
|
||||
|
||||
/**
|
||||
* Boutons actions
|
||||
*/
|
||||
if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc'))
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($commande->statut == 0 && $num_lignes > 0)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->valider)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($commande->statut == 1)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->annuler)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=cancel">'.$langs->trans("CancelOrder").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->fournisseur->commande->approuver)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=approve">'.$langs->trans("ApproveOrder").'</a>';
|
||||
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($commande->statut == 2)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->approuver)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($commande->statut == 0)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
}
|
||||
// Build PDF
|
||||
if ($user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=builddoc">'.$langs->trans("BuildPDF").'</a>';
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
}
|
||||
$title=$langs->trans("SupplierOrder");
|
||||
dolibarr_fiche_head($head, $a, $title);
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression de la commande
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'delete')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=$commande->id","Supprimer la commande","Etes-vous sûr de vouloir supprimer cette commande ?","confirm_delete");
|
||||
print '<br />';
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'valid')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=$commande->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=$commande->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=$commande->id","Refuser la commande","Etes-vous sûr de vouloir refuser cette commande ?","confirm_refuse");
|
||||
print '<br />';
|
||||
}
|
||||
/*
|
||||
* Confirmation de l'annulation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'cancel')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("Cancel"),"Etes-vous sûr de vouloir annuler cette commande ?","confirm_cancel");
|
||||
print '<br />';
|
||||
}
|
||||
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
/*
|
||||
* Documents générés
|
||||
*
|
||||
*/
|
||||
$comfournref = sanitize_string($commande->ref);
|
||||
$comfournref = str_replace("(","",$comfournref);
|
||||
$comfournref = str_replace(")","",$comfournref);
|
||||
$file = $conf->fournisseur->commande->dir_output . '/' . $comfournref . '/' . $comfournref . '.pdf';
|
||||
$relativepath = $comfournref.'/'.$comfournref.'.pdf';
|
||||
$filedir = $conf->fournisseur->commande->dir_output . '/' . $comfournref;
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id;
|
||||
$genallowed=$user->rights->fournisseur->commande->creer;
|
||||
$delallowed=$user->rights->fournisseur->commande->supprimer;
|
||||
/*
|
||||
* Confirmation de l'envoi de la commande
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'commande')
|
||||
{
|
||||
$date_com = mktime(0,0,0,$_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 />';
|
||||
}
|
||||
|
||||
$var=true;
|
||||
/*
|
||||
if (file_exists($file))
|
||||
/*
|
||||
* Commande
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="3">'.$commande->ref.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Fournisseur
|
||||
print '<tr><td width="20%">'.$langs->trans("Supplier")."</td>";
|
||||
print '<td colspan="5">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id.'">';
|
||||
print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'</a></b></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Status").'</td>';
|
||||
print '<td width="50%" colspan="5">';
|
||||
print $commande->getLibStatut(4);
|
||||
print "</td></tr>";
|
||||
|
||||
if ($commande->methode_commande_id > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
|
||||
|
||||
if ($commande->date_commande)
|
||||
{
|
||||
print_titre($langs->trans('Documents'));
|
||||
print '<table width="100%" class="border">';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans('Order').' PDF</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$commande->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>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
print dolibarr_print_date($commande->date_commande,"%A %d %B %Y")."\n";
|
||||
}
|
||||
|
||||
print '</td><td width="50%" colspan="3">';
|
||||
if ($commande->methode_commande)
|
||||
{
|
||||
print "Méthode : " .$commande->methode_commande;
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Auteur
|
||||
print '<tr><td>'.$langs->trans("Author").'</td><td colspan="2">'.$author->fullname.'</td>';
|
||||
print '<td colspan="3" width="50%">';
|
||||
print " </td></tr>";
|
||||
|
||||
// Ligne de 3 colonnes
|
||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="3"> </td></tr>';
|
||||
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="3"> </td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="3"> </td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
if ($mesg) print $mesg;
|
||||
else print '<br>';
|
||||
|
||||
/*
|
||||
* Lignes de commandes
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
$sql = "SELECT l.ref, l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
|
||||
$sql.= " WHERE l.fk_commande = $commande->id";
|
||||
$sql.= " ORDER BY l.rowid";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_lignes = $db->num_rows($resql);
|
||||
$i = 0; $total = 0;
|
||||
|
||||
if ($num_lignes)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$langs->trans("Ref").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</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> </td><td width="10%"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=false;
|
||||
while ($i < $num_lignes)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.'</a></td>';
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/fourn/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
|
||||
}
|
||||
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";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && $_GET["action"] <> 'valid')
|
||||
{
|
||||
print '<td> </td><td align="right"><a href="fiche.php?id='.$commande->id.'&action=deleteline&lineid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td><td> </td>';
|
||||
}
|
||||
print "</tr>";
|
||||
|
||||
if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid)
|
||||
{
|
||||
print "<form action=\"fiche.php?id=$commande->id\" method=\"post\">";
|
||||
print '<input type="hidden" name="action" value="updateligne">';
|
||||
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">';
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td colspan="3"><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 align="right"><input size="3" type="text" name="elremise_percent" value="'.$objp->remise_percent.'"> %</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" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
print '</tr>' . "\n";
|
||||
print "</form>\n";
|
||||
}
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajouter une ligne
|
||||
*/
|
||||
if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc'))
|
||||
{
|
||||
print '<form action="fiche.php?id='.$commande->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">'.$langs->trans("Description").'</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> </td><td> </td>'."</tr>\n";
|
||||
|
||||
$var=false;
|
||||
print "<tr $bc[$var]>".'<td colspan="3">';
|
||||
$html->select_produits_fournisseurs($commande->fourn_id,'','p_idprod',$filtre);
|
||||
print '</td>';
|
||||
print '<td align="center"><input type="text" size="2" name="pqty" value="1"></td>';
|
||||
print '<td align="right"><input type="text" size="3" name="premise" value="0">%</td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
|
||||
print "</tr>\n";
|
||||
|
||||
print "</form>";
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
|
||||
/**
|
||||
* Boutons actions
|
||||
*/
|
||||
if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc'))
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($commande->statut == 0 && $num_lignes > 0)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->valider)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($commande->statut == 1)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->approuver)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=approve">'.$langs->trans("ApproveOrder").'</a>';
|
||||
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->fournisseur->commande->annuler)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=cancel">'.$langs->trans("CancelOrder").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($commande->statut == 2)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->approuver)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($commande->statut == 0)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// Build PDF
|
||||
if ($commande->statut > 0)
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&action=builddoc">'.$langs->trans("BuildPDF").'</a>';
|
||||
}
|
||||
}
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
/*
|
||||
* Documents générés
|
||||
*
|
||||
*/
|
||||
$comfournref = sanitize_string($commande->ref);
|
||||
$comfournref = str_replace("(","",$comfournref);
|
||||
$comfournref = str_replace(")","",$comfournref);
|
||||
$file = $conf->fournisseur->commande->dir_output . '/' . $comfournref . '/' . $comfournref . '.pdf';
|
||||
$relativepath = $comfournref.'/'.$comfournref.'.pdf';
|
||||
$filedir = $conf->fournisseur->commande->dir_output . '/' . $comfournref;
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id;
|
||||
$genallowed=$user->rights->fournisseur->commande->creer;
|
||||
$delallowed=$user->rights->fournisseur->commande->supprimer;
|
||||
|
||||
$var=true;
|
||||
/*
|
||||
if (file_exists($file))
|
||||
{
|
||||
print_titre($langs->trans('Documents'));
|
||||
print '<table width="100%" class="border">';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans('Order').' PDF</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$commande->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>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
}
|
||||
*/
|
||||
//$html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf);
|
||||
$html->show_documents('commande_fournisseur',$comfournref,$filedir,$urlsource,$commande->statut>0?1:0,$delallowed,$commande->modelpdf);
|
||||
|
||||
|
||||
print '</td><td width="50%" valign="top">';
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'classer')
|
||||
{
|
||||
print '<form method="post" action="fiche.php?id='.$commande->id.'">';
|
||||
print '<input type="hidden" name="action" value="classin">';
|
||||
print '<table class="border">';
|
||||
print '<tr><td>Projet</td><td>';
|
||||
|
||||
$proj = new Project($db);
|
||||
$html->select_array("projetid",$proj->liste_array($commande->soc_id));
|
||||
|
||||
print "</td></tr>";
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Send").'"></td></tr></table></form>';
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2)
|
||||
{
|
||||
/**
|
||||
* Commander
|
||||
*/
|
||||
//$html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf);
|
||||
$html->show_documents('commande_fournisseur',$comfournref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf);
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
print '</td><td width="50%" valign="top">';
|
||||
print '<br>';
|
||||
print '<form name="commande" action="fiche.php?id='.$commande->id.'&action=commande" method="post">';
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre"><td colspan="2">Commander</td></tr>';
|
||||
print '<tr><td>Date commande</td><td>';
|
||||
print $form->select_date('','','','','',"commande");
|
||||
print '</td></tr>';
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'classer')
|
||||
{
|
||||
print '<form method="post" action="fiche.php?id='.$commande->id.'">';
|
||||
print '<input type="hidden" name="action" value="classin">';
|
||||
print '<table class="border">';
|
||||
print '<tr><td>Projet</td><td>';
|
||||
|
||||
$proj = new Project($db);
|
||||
$html->select_array("projetid",$proj->liste_array($commande->soc_id));
|
||||
|
||||
print "</td></tr>";
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Send").'"></td></tr></table></form>';
|
||||
$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" class="button" name="'.$langs->trans("Activate").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ( $user->rights->fournisseur->commande->receptionner && ($commande->statut == 3 ||$commande->statut == 4 ))
|
||||
{
|
||||
/**
|
||||
* Réceptionner
|
||||
*/
|
||||
$form = new Form($db);
|
||||
|
||||
print '<br>';
|
||||
print '<form action="fiche.php?id='.$commande->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="livraison">';
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre"><td colspan="2">Réceptionner</td></tr>';
|
||||
print '<tr><td>Date de livraison</td><td>';
|
||||
print $form->select_date('','','','','',"commande");
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr><td>Livraison</td><td>\n";
|
||||
$liv = array();
|
||||
$liv['par'] = "Partielle";
|
||||
$liv['tot'] = "Totale";
|
||||
|
||||
print $form->select_array("type",$liv);
|
||||
|
||||
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" class="button" name="'.$langs->trans("Activate").'"></td></tr>';
|
||||
print "</table>\n";
|
||||
print "</form>\n";
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2)
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Commander
|
||||
*/
|
||||
$form = new Form($db);
|
||||
|
||||
print '<br>';
|
||||
print '<form name="commande" action="fiche.php?id='.$commande->id.'&action=commande" method="post">';
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre"><td colspan="2">Commander</td></tr>';
|
||||
print '<tr><td>Date commande</td><td>';
|
||||
print $form->select_date('','','','','',"commande");
|
||||
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" class="button" name="'.$langs->trans("Activate").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
/* Commande non trouvée */
|
||||
print "Commande inexistante";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ( $user->rights->fournisseur->commande->receptionner && ($commande->statut == 3 ||$commande->statut == 4 ))
|
||||
{
|
||||
/**
|
||||
* Réceptionner
|
||||
*/
|
||||
$form = new Form($db);
|
||||
|
||||
print '<br>';
|
||||
print '<form action="fiche.php?id='.$commande->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="livraison">';
|
||||
print '<table class="noborder">';
|
||||
print '<tr class="liste_titre"><td colspan="2">Réceptionner</td></tr>';
|
||||
print '<tr><td>Date de livraison</td><td>';
|
||||
print $form->select_date('','','','','',"commande");
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr><td>Livraison</td><td>\n";
|
||||
$liv = array();
|
||||
$liv['par'] = "Partielle";
|
||||
$liv['tot'] = "Totale";
|
||||
|
||||
print $form->select_array("type",$liv);
|
||||
|
||||
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" class="button" name="'.$langs->trans("Activate").'"></td></tr>';
|
||||
print "</table>\n";
|
||||
print "</form>\n";
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
print "Commande inexistante";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 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
|
||||
@ -46,124 +46,132 @@ if (!$user->rights->fournisseur->commande->lire) accessforbidden();
|
||||
|
||||
if ($_GET["id"] > 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$soc = new Societe($db);
|
||||
$commande = new CommandeFournisseur($db);
|
||||
|
||||
if ( $commande->fetch($_GET["id"]) == 0)
|
||||
{
|
||||
$soc->fetch($commande->soc_id);
|
||||
if ( $commande->fetch($_GET["id"]) == 0)
|
||||
{
|
||||
$soc->fetch($commande->soc_id);
|
||||
|
||||
$addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id;
|
||||
$addons[0][1] = $soc->nom;
|
||||
$addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id;
|
||||
$addons[0][1] = $soc->nom;
|
||||
|
||||
llxHeader('',$langs->trans("History"),"CommandeFournisseur",$addons);
|
||||
llxHeader('',$langs->trans("History"),"CommandeFournisseur",$addons);
|
||||
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
$h = 0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderCard");
|
||||
$h++;
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$h++;
|
||||
$h = 0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderFollow");
|
||||
$a = $h;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$h++;
|
||||
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderFollow");
|
||||
$a = $h;
|
||||
|
||||
$title=$langs->trans("Order").": $commande->ref";
|
||||
dolibarr_fiche_head($head, $a, $title);
|
||||
$h++;
|
||||
|
||||
|
||||
/*
|
||||
* Commande
|
||||
*/
|
||||
$title=$langs->trans("SupplierOrder");
|
||||
dolibarr_fiche_head($head, $a, $title);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Supplier")."</td>";
|
||||
print '<td colspan="3">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id.'">'.img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'</a></b></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
|
||||
print '<img src="statut'.$commande->statut.'.png"> ';
|
||||
print $commande->statuts[$commande->statut];
|
||||
print "</td></tr>";
|
||||
|
||||
if ($commande->methode_commande_id > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="2">'.dolibarr_print_date($commande->date_commande,"%A %d %B %Y")."</td>\n";
|
||||
print '<td width="50%"> ';
|
||||
print "</td></tr>";
|
||||
/*
|
||||
* Commande
|
||||
*/
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="3">'.$commande->ref.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Fournisseur
|
||||
print '<tr><td width="20%">'.$langs->trans("Supplier")."</td>";
|
||||
print '<td colspan="3">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id.'">'.img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'</a></b></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
|
||||
print $commande->getLibStatut(4);
|
||||
print "</td></tr>";
|
||||
|
||||
if ($commande->methode_commande_id > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="2">'.dolibarr_print_date($commande->date_commande,"%A %d %B %Y")."</td>\n";
|
||||
print '<td width="50%"> ';
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
print "<br>";
|
||||
|
||||
/*
|
||||
* Suivi historique
|
||||
* Date - Statut - Auteur
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Status").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Author").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$sql = "SELECT l.fk_statut, ".$db->pdate("l.datelog") ."as dl, u.rowid, u.code, u.firstname, u.name";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_log as l ";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."user as u ";
|
||||
$sql .= " WHERE l.fk_commande = ".$commande->id." AND u.rowid = l.fk_user";
|
||||
$sql .= " ORDER BY l.rowid DESC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
$obj = $db->fetch_object($resql);
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td width="20%">'.dolibarr_print_date($obj->dl,"%a %d %b %Y %H:%M:%S")."</td>\n";
|
||||
|
||||
// Statut
|
||||
print '<td width="100px">'.$commande->LibStatut($obj->fk_statut,4)."</td>\n";
|
||||
|
||||
// User
|
||||
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
|
||||
print img_object($langs->trans("ShowUser"),'user').' '.$obj->code.'</a></td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
print "Commande inexistante ou accés refusé";
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
print "<br>";
|
||||
|
||||
/*
|
||||
* Suivi historique
|
||||
* Date - Statut - Auteur
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Status").'</td><td>'.$langs->trans("Author").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$sql = "SELECT l.fk_statut, ".$db->pdate("l.datelog") ."as dl, u.rowid, u.code, u.firstname, u.name";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_log as l ";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."user as u ";
|
||||
$sql .= " WHERE l.fk_commande = ".$commande->id." AND u.rowid = l.fk_user";
|
||||
$sql .= " ORDER BY l.rowid DESC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
$obj = $db->fetch_object($resql);
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td width="20%">'.dolibarr_print_date($obj->dl,"%a %d %b %Y %H:%M:%S")."</td>\n";
|
||||
|
||||
print '<td width="100px"><img src="statut'.$obj->fk_statut.'.png"> ';
|
||||
|
||||
print $commande->statuts[$obj->fk_statut]."</td>\n";
|
||||
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
|
||||
print img_object($langs->trans("ShowUser"),'user').' '.$obj->code.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
print "Commande inexistante ou accés refusé";
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 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
|
||||
@ -69,87 +69,93 @@ $html = new Form($db);
|
||||
|
||||
if ($_GET["id"] > 0)
|
||||
{
|
||||
$commande = new CommandeFournisseur($db);
|
||||
if ( $commande->fetch($_GET["id"]) == 0)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->soc_id);
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
$h = 0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$a = $h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderFollow");
|
||||
$h++;
|
||||
|
||||
$title=$langs->trans("Order").": $commande->ref";
|
||||
dolibarr_fiche_head($head, $a, $title);
|
||||
|
||||
|
||||
/*
|
||||
* Commande
|
||||
*/
|
||||
print '<form action="note.php?id='.$commande->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="updatenote">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Supplier").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print '<b><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id.'">'.img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'</a></b></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print '<img src="statut'.$commande->statut.'.png"> ';
|
||||
print $commande->statuts[$commande->statut];
|
||||
print "</td></tr>";
|
||||
|
||||
if ($commande->methode_commande_id > 0)
|
||||
$commande = new CommandeFournisseur($db);
|
||||
if ( $commande->fetch($_GET["id"]) == 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="2">';
|
||||
|
||||
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>";
|
||||
}
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->soc_id);
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
$h = 0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderCard");
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$a = $h;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("OrderFollow");
|
||||
$h++;
|
||||
|
||||
$title=$langs->trans("SupplierOrder");
|
||||
dolibarr_fiche_head($head, $a, $title);
|
||||
|
||||
|
||||
/*
|
||||
* Commande
|
||||
*/
|
||||
print '<form action="note.php?id='.$commande->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="updatenote">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="3">'.$commande->ref.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Fournisseur
|
||||
print '<tr><td width="20%">'.$langs->trans("Supplier").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id.'">'.img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'</a></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $commande->getLibStatut(4);
|
||||
print "</td></tr>";
|
||||
|
||||
if ($commande->methode_commande_id > 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="2">';
|
||||
|
||||
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>";
|
||||
}
|
||||
|
||||
// Auteur
|
||||
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 width="50%">';
|
||||
print " </td></tr>";
|
||||
|
||||
|
||||
// Ligne de 3 colonnes
|
||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td>';
|
||||
print '<td valign="top"> </td></tr>';
|
||||
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td> </td></tr>';
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td> </td></tr>';
|
||||
|
||||
|
||||
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td colspan="3">';
|
||||
if ($user->rights->fournisseur->commande->creer) print '<textarea cols="60" rows="'.ROWS_4.'" name="note">';
|
||||
@ -166,17 +172,17 @@ if ($_GET["id"] > 0)
|
||||
|
||||
if ($user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
print '<tr><td colspan="4" align="center"><input type="submit" class="button"></td></tr>';
|
||||
print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
|
||||
}
|
||||
|
||||
|
||||
print "</table></form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
print "Commande inexistante";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
print "Commande inexistante";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
|
||||
|
||||
/**
|
||||
@ -35,7 +36,7 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
\brief Classe de gestion de commande fournisseur
|
||||
*/
|
||||
|
||||
class CommandeFournisseur
|
||||
class CommandeFournisseur extends Commande
|
||||
{
|
||||
var $db ;
|
||||
var $id ;
|
||||
@ -48,7 +49,6 @@ class CommandeFournisseur
|
||||
{
|
||||
$this->db = $DB;
|
||||
|
||||
$this->statuts[-1]= "Annulée";
|
||||
$this->statuts[0] = "Brouillon";
|
||||
$this->statuts[1] = "Validée";
|
||||
$this->statuts[2] = "Approuvée";
|
||||
@ -314,11 +314,25 @@ class CommandeFournisseur
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
return $this->statuts[$statut];
|
||||
if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$this->statuts[$statut];
|
||||
if ($statut==1) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$this->statuts[$statut];
|
||||
if ($statut==2) return img_picto($langs->trans('StatusOrderApproved'),'statut3').' '.$this->statuts[$statut];
|
||||
if ($statut==3) return img_picto($langs->trans('StatusOrderOnProcess'),'statut3').' '.$this->statuts[$statut];
|
||||
if ($statut==4) return img_picto($langs->trans('StatusOrderReceivedPartially'),'statut3').' '.$this->statuts[$statut];
|
||||
if ($statut==5) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$this->statuts[$statut];
|
||||
if ($statut==6) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$this->statuts[$statut];
|
||||
if ($statut==9) return img_picto($langs->trans('StatusOrderRefused'),'statut5').' '.$this->statuts[$statut];
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
return $this->statuts[$statut];
|
||||
if ($statut==0) return $this->statuts[$statut].' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
|
||||
if ($statut==1) return $this->statuts[$statut].' '.img_picto($langs->trans('StatusOrderValidated'),'statut1');
|
||||
if ($statut==2) return $this->statuts[$statut].' '.img_picto($langs->trans('StatusOrderApproved'),'statut3');
|
||||
if ($statut==3) return $this->statuts[$statut].' '.img_picto($langs->trans('StatusOrderOnProcess'),'statut3');
|
||||
if ($statut==4) return $this->statuts[$statut].' '.img_picto($langs->trans('StatusOrderReceivedPartially'),'statut3');
|
||||
if ($statut==5) return $this->statuts[$statut].' '.img_picto($langs->trans('StatusOrderProcessed'),'statut6');
|
||||
if ($statut==6) return $this->statuts[$statut].' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
|
||||
if ($statut==9) return $this->statuts[$statut].' '.img_picto($langs->trans('StatusOrderRefused'),'statut5');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1029,7 +1043,7 @@ class CommandeFournisseur
|
||||
}
|
||||
}
|
||||
|
||||
class CommandeLigne
|
||||
class CommandeFournisseurLigne extends CommandeLigne
|
||||
{
|
||||
// From llx_propaldet
|
||||
var $qty;
|
||||
@ -1044,7 +1058,8 @@ class CommandeLigne
|
||||
var $libelle; // Label produit
|
||||
var $product_desc; // Description produit
|
||||
var $ref;
|
||||
function CommandeLigne()
|
||||
|
||||
function CommandeFournisseurLigne()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user