diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php
index 38e91bb24eb..0d707cc454b 100644
--- a/htdocs/admin/fournisseur.php
+++ b/htdocs/admin/fournisseur.php
@@ -215,12 +215,13 @@ if ($handle)
print '';
$commande=new CommandeFournisseur($db);
-
+ $commande->initAsSpecimen();
+
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
';
$facture->type=0;
- $nextval=$module->getNextValue($mysoc,$propale);
+ $nextval=$module->getNextValue($mysoc,$commande);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 633a9faf611..28873f461d3 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -20,11 +20,11 @@
*/
/**
- \file htdocs/fourn/commande/fiche.php
- \ingroup commande
- \brief Fiche commande
- \version $Id$
-*/
+ \file htdocs/fourn/commande/fiche.php
+ \ingroup commande
+ \brief Fiche commande
+ \version $Id$
+ */
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
@@ -50,15 +50,15 @@ $id = isset($_GET["id"])?$_GET["id"]:$_POST["id"];
$socid=0;
if ($user->societe_id > 0)
{
- $action = '';
- $socid = $user->societe_id;
+ $action = '';
+ $socid = $user->societe_id;
}
// Recuperation de l'id de projet
$projetid = 0;
if ($_GET["projetid"])
{
- $projetid = $_GET["projetid"];
+ $projetid = $_GET["projetid"];
}
$mesg='';
@@ -71,17 +71,17 @@ $mesg='';
// Set project
if ($_POST['action'] == 'classin')
{
- $commande = new CommandeFournisseur($db);
- $commande->fetch($id);
- $commande->setProject($_POST["projetid"]);
+ $commande = new CommandeFournisseur($db);
+ $commande->fetch($id);
+ $commande->setProject($_POST["projetid"]);
}
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->fournisseur->commande->creer)
{
- $commande = new CommandeFournisseur($db);
- $commande->fetch($_REQUEST['id']);
- $result = $commande->set_remise($user, $_POST['remise_percent']);
- $id=$_REQUEST['id'];
+ $commande = new CommandeFournisseur($db);
+ $commande->fetch($_REQUEST['id']);
+ $result = $commande->set_remise($user, $_POST['remise_percent']);
+ $id=$_REQUEST['id'];
}
/*
@@ -90,72 +90,72 @@ if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->fournisseur->com
if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->creer)
{
if ($_POST['qty'] && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice']))
- {
- $commande = new CommandeFournisseur($db);
- $ret=$commande->fetch($id);
- if ($ret < 0)
- {
- dolibarr_print_error($db,$commande->error);
- exit;
- }
-
- $soc = new Societe($db, $commande->socid);
- $result=$soc->fetch($commande->socid);
- //print $result;
-
- // Ecrase $pu par celui du produit
- // Ecrase $desc par celui du produit
- // Ecrase $txtva par celui du produit
- if ($_POST["idprodfournprice"] > 0)
- {
- $prodfournprice = new ProductFournisseur($db);
- $prodfournprice->fetch_product_fournisseur_price($_POST["idprodfournprice"]);
-
- $prod = new Product($db, $prodfournprice->product_id);
- $prod->fetch($prodfournprice->product_id);
-
- $libelle = $prod->libelle;
-
- $desc = $prod->description;
- $desc.= $prod->description && $_POST['np_desc'] ? "\n" : "";
- $desc.= $_POST['np_desc'];
-
- $tva_tx = get_default_tva($soc,$mysoc,$prod->tva_tx,$prodfournprice->product_id);
- }
- else
{
- $pu=$_POST['pu'];
- $tva_tx=$_POST['tva_tx'];
- $desc=$_POST['dp_desc'];
- }
- //print "xx".$tva_tx; exit;
-
- $result=$commande->addline(
- $desc,
- $pu,
- $_POST['qty'],
- $tva_tx,
- $prodfournprice->product_id,
- $_POST['idprodfournprice'],
- $prodfournprice->fourn_ref,
- $_POST['remise_percent'],
+ $commande = new CommandeFournisseur($db);
+ $ret=$commande->fetch($id);
+ if ($ret < 0)
+ {
+ dolibarr_print_error($db,$commande->error);
+ exit;
+ }
+
+ $soc = new Societe($db, $commande->socid);
+ $result=$soc->fetch($commande->socid);
+ //print $result;
+
+ // Ecrase $pu par celui du produit
+ // Ecrase $desc par celui du produit
+ // Ecrase $txtva par celui du produit
+ if ($_POST["idprodfournprice"] > 0)
+ {
+ $prodfournprice = new ProductFournisseur($db);
+ $prodfournprice->fetch_product_fournisseur_price($_POST["idprodfournprice"]);
+
+ $prod = new Product($db, $prodfournprice->product_id);
+ $prod->fetch($prodfournprice->product_id);
+
+ $libelle = $prod->libelle;
+
+ $desc = $prod->description;
+ $desc.= $prod->description && $_POST['np_desc'] ? "\n" : "";
+ $desc.= $_POST['np_desc'];
+
+ $tva_tx = get_default_tva($soc,$mysoc,$prod->tva_tx,$prodfournprice->product_id);
+ }
+ else
+ {
+ $pu=$_POST['pu'];
+ $tva_tx=$_POST['tva_tx'];
+ $desc=$_POST['dp_desc'];
+ }
+ //print "xx".$tva_tx; exit;
+
+ $result=$commande->addline(
+ $desc,
+ $pu,
+ $_POST['qty'],
+ $tva_tx,
+ $prodfournprice->product_id,
+ $_POST['idprodfournprice'],
+ $prodfournprice->fourn_ref,
+ $_POST['remise_percent'],
'HT'
);
- if ($result > 0)
- {
- if ($_REQUEST['lang_id'])
- {
+ if ($result > 0)
+ {
+ if ($_REQUEST['lang_id'])
+ {
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
- }
- supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
- }
- else
- {
- $mesg='
| '.$langs->trans("Ref").' | '; - print ''.$commande->ref.' | '; - print '||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '.$langs->trans("Supplier")." | "; - print ''; - print ''; - print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.' | '; - print '||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '.$langs->trans("Status").' | '; - print ''; - print $commande->getLibStatut(4); - print " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '.$langs->trans("Date").' | ';
-
- if ($commande->date_commande)
+ /*
+ * Confirmation de la validation
+ */
+ if ($_GET['action'] == 'valid')
{
+ $commande->date_commande=time();
+
+ // on verifie si la commande est en numerotation provisoire
+ $ref = substr($commande->ref, 1, 4);
+ if ($ref == 'PROV')
+ {
+ $newref = $commande->getNextNumRef($soc);
+ }
+ else
+ {
+ $newref = $commande->ref;
+ }
+
+ $text=$langs->trans('ConfirmValidateOrder',$newref);
+ if ($conf->notification->enabled)
+ {
+ require_once(DOL_DOCUMENT_ROOT ."/notify.class.php");
+ $notify=new Notify($db);
+ $text.=' '; + $text.=$notify->confirmMessage(3,$commande->socid); + } + + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_valid'); + print ' '; + } + /* + * Confirmation de l'approbation + * + */ + if ($_GET['action'] == 'approve') + { + $html->form_confirm("fiche.php?id=$commande->id",$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder"),"confirm_approve"); + print ' '; + } + /* + * Confirmation de la desapprobation + * + */ + if ($_GET['action'] == 'refuse') + { + $html->form_confirm("fiche.php?id=$commande->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder"),"confirm_refuse"); + print ' '; + } + /* + * Confirmation de l'annulation + */ + if ($_GET['action'] == 'cancel') + { + $html->form_confirm("fiche.php?id=$commande->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder"),"confirm_cancel"); + print ' '; + } + + /* + * Confirmation de l'envoi de la commande + */ + if ($_GET["action"] == 'commande') + { + $date_com = dolibarr_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); + $html->form_confirm("fiche.php?id=".$commande->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"], + $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dolibarr_print_date($date_com,'day')),"confirm_commande"); + print ' '; + } + + /* + * Confirmation de la suppression d'une ligne produit + */ + if ($_GET['action'] == 'delete_product_line' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE) + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$commande->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline'); + print ' '; + } + + /* + * Commande + */ + $nbrow=8; + if ($conf->projet->enabled) $nbrow++; + print '
'; - - /* - * Lignes de commandes - */ - print '
'; + + /* + * Lignes de commandes + */ + print '
';
-
- if ($commande->statut == 0 && $num > 0)
+ }
+ print ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||