From 090f38938fa71ca73d7bec29a9b125621d8cc5dd Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 11 Dec 2006 16:03:34 +0000 Subject: [PATCH] Ajout Onglet + nettoyage (plusieurs zones vides de 100 lignes ?????) --- htdocs/fourn/commande/fiche.php | 1719 +++++++++++++------------------ 1 file changed, 709 insertions(+), 1010 deletions(-) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 66c2ab73834..c989b57f38b 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur +/* Copyright (C) 2004-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2006 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * * This program is free software; you can redistribute it and/or modify @@ -22,10 +22,10 @@ */ /** - \file htdocs/fourn/commande/fiche.php - \ingroup commande - \brief Fiche commande - \version $Revision$ + \file htdocs/fourn/commande/fiche.php + \ingroup commande + \brief Fiche commande + \version $Revision$ */ require('./pre.inc.php'); @@ -50,15 +50,15 @@ $comclientid = isset($_GET["comid"])?$_GET["comid"]:''; $socid=0; if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } // Récupération de l'id de projet $projetid = 0; if ($_GET["projetid"]) { - $projetid = $_GET["projetid"]; + $projetid = $_GET["projetid"]; } $mesg=''; @@ -78,10 +78,10 @@ if ($_POST['action'] == 'classin' && $user->rights->fournisseur->commande->creer 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']); - $_GET['id']=$_REQUEST['id']; + $commande = new CommandeFournisseur($db); + $commande->fetch($_REQUEST['id']); + $result = $commande->set_remise($user, $_POST['remise_percent']); + $_GET['id']=$_REQUEST['id']; } /* @@ -89,70 +89,70 @@ if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->fournisseur->com */ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->creer) { - if ($_POST['qty'] && (($_POST['pu'] && $_POST['desc']) || $_POST['idprod'])) + if ($_POST['qty'] && (($_POST['pu'] && $_POST['desc']) || $_POST['idprod'])) + { + $commande = new CommandeFournisseur($db); + $ret=$commande->fetch($_POST["id"]); + + $soc = new Societe($db, $commande->socid); + $soc->fetch($commande->socid); + if ($ret < 0) { - $commande = new CommandeFournisseur($db); - $ret=$commande->fetch($_POST["id"]); - - $soc = new Societe($db, $commande->socid); - $soc->fetch($commande->socid); - if ($ret < 0) - { - dolibarr_print_error($db,$commande->error); - exit; - } - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - if ($_POST["idprod"] > 0) - { - $prod = new Product($db, $_POST['idprod']); - $prod->fetch($_POST['idprod']); - - $libelle = $prod->libelle; - - // La description de la ligne est celle saisie ou - // celle du produit si (non saisi + PRODUIT_CHANGE_PROD_DESC défini) - // \todo Ne faut-il pas rendre $conf->global->PRODUIT_CHANGE_PROD_DESC toujours a on - $desc=$_POST['np_desc']; - if (! $desc && $conf->global->PRODUIT_CHANGE_PROD_DESC) - { - $desc = $prod->description; - } - - $tva_tx = get_default_tva($soc,$mysoc,$prod->tva_tx); - } - else - { - $pu=$_POST['pu']; - $tva_tx=$_POST['tva_tx']; - $desc=$_POST['desc']; - } - - $result=$commande->addline( - $desc, - $pu, - $_POST['qty'], - $tva_tx, - $_POST['idprod'], - $_POST['remise_percent'] - ); - - if ($result > 0) - { - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); - } - else - { - $mesg='
'.$commande->error.'
'; - } + dolibarr_print_error($db,$commande->error); + exit; } + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + if ($_POST["idprod"] > 0) + { + $prod = new Product($db, $_POST['idprod']); + $prod->fetch($_POST['idprod']); + + $libelle = $prod->libelle; + + // La description de la ligne est celle saisie ou + // celle du produit si (non saisi + PRODUIT_CHANGE_PROD_DESC défini) + // \todo Ne faut-il pas rendre $conf->global->PRODUIT_CHANGE_PROD_DESC toujours a on + $desc=$_POST['np_desc']; + if (! $desc && $conf->global->PRODUIT_CHANGE_PROD_DESC) + { + $desc = $prod->description; + } + + $tva_tx = get_default_tva($soc,$mysoc,$prod->tva_tx); + } + else + { + $pu=$_POST['pu']; + $tva_tx=$_POST['tva_tx']; + $desc=$_POST['desc']; + } + + $result=$commande->addline( + $desc, + $pu, + $_POST['qty'], + $tva_tx, + $_POST['idprod'], + $_POST['remise_percent'] + ); + + if ($result > 0) + { + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + } + else + { + $mesg='
'.$commande->error.'
'; + } + } } /* @@ -160,136 +160,136 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree */ if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->creer && $_POST['save'] == $langs->trans('Save')) { - $commande = new CommandeFournisseur($db,"",$_POST["id"]); - if ($commande->fetch($_POST['id']) < 0) dolibarr_print_error($db); + $commande = new CommandeFournisseur($db,"",$_POST["id"]); + if ($commande->fetch($_POST['id']) < 0) dolibarr_print_error($db); - $result = $commande->updateline($_POST['elrowid'], - $_POST['desc'], - $_POST['pu'], - $_POST['qty'], - $_POST['remise_percent'], - $_POST['tva_tx'] - ); + $result = $commande->updateline($_POST['elrowid'], + $_POST['desc'], + $_POST['pu'], + $_POST['qty'], + $_POST['remise_percent'], + $_POST['tva_tx'] + ); - if ($result >= 0) + if ($result >= 0) + { + if ($_REQUEST['lang_id']) { - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); - } - else - { - dolibarr_print_error($db,$commande->error); - exit; + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); } + commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + } + else + { + dolibarr_print_error($db,$commande->error); + exit; + } - $_GET['id']=$_POST['id']; // Pour réaffichage de la fiche en cours d'édition + $_GET['id']=$_POST['id']; // Pour réaffichage de la fiche en cours d'édition } if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->creer && $_POST['cancel'] == $langs->trans('Cancel')) { - Header('Location: fiche.php?id='.$_POST['id']); // Pour réaffichage de la fiche en cours d'édition - exit; + Header('Location: fiche.php?id='.$_POST['id']); // Pour réaffichage de la fiche en cours d'édition + exit; } if ($_GET['action'] == 'deleteline' && $user->rights->fournisseur->commande->creer) { - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET['id']); - $result = $commande->delete_line($_GET['lineid']); - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - commande_supplier_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs); - Header('Location: fiche.php?id='.$_GET['id']); - exit; + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET['id']); + $result = $commande->delete_line($_GET['lineid']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + commande_supplier_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs); + Header('Location: fiche.php?id='.$_GET['id']); + exit; } if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->valider) { - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET['id']); - $soc = new Societe($db); - $soc->fetch($commande->socid); - $result = $commande->valid($user); - if ($result >= 0) - { - Header("Location: fiche.php?id=".$_GET["id"]); - exit; - } + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET['id']); + $soc = new Societe($db); + $soc->fetch($commande->socid); + $result = $commande->valid($user); + if ($result >= 0) + { + Header("Location: fiche.php?id=".$_GET["id"]); + exit; + } } if ($_POST['action'] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver) { - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET['id']); - $result = $commande->approve($user); - if ($result >= 0) - { - Header("Location: fiche.php?id=".$_GET["id"]); - exit; - } + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET['id']); + $result = $commande->approve($user); + if ($result >= 0) + { + Header("Location: fiche.php?id=".$_GET["id"]); + exit; + } } 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); - if ($result >= 0) - { - Header("Location: fiche.php?id=".$_GET["id"]); - exit; - } + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET['id']); + $result = $commande->refuse($user); + if ($result >= 0) + { + Header("Location: fiche.php?id=".$_GET["id"]); + exit; + } } 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"]); - exit; + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET["id"]); + $result = $commande->commande($user, $_GET["datecommande"], $_GET["methode"]); + Header("Location: fiche.php?id=".$_GET["id"]); + exit; } if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->commande->supprimer) { - if ($user->rights->commande->supprimer ) - { - $commande = new CommandeFournisseur($db); - $commande->id = $_GET['id']; - $commande->delete(); - Header('Location: index.php'); - exit; - } + if ($user->rights->commande->supprimer ) + { + $commande = new CommandeFournisseur($db); + $commande->id = $_GET['id']; + $commande->delete(); + Header('Location: index.php'); + exit; + } } if ($_POST["action"] == 'livraison' && $user->rights->fournisseur->commande->receptionner) { - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET["id"]); + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET["id"]); - $date_liv = mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); + $date_liv = mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); - $result = $commande->Livraison($user, $date_liv, $_POST["type"]); - Header("Location: fiche.php?id=".$_GET["id"]); - exit; + $result = $commande->Livraison($user, $date_liv, $_POST["type"]); + Header("Location: fiche.php?id=".$_GET["id"]); + exit; } if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->fournisseur->commande->annuler) { - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET["id"]); - $result = $commande->cancel($user); - Header("Location: fiche.php?id=".$_GET["id"]); - exit; + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET["id"]); + $result = $commande->cancel($user); + Header("Location: fiche.php?id=".$_GET["id"]); + exit; } /* @@ -298,80 +298,80 @@ if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->r if ($_GET['action'] == 'up' && $user->rights->fournisseur->commande->creer) { - $commande = new CommandeFournisseur($db,'',$_GET['id']); - $commande->fetch($_GET['id']); - $commande->line_up($_GET['rowid']); - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); - Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); - exit; + $commande = new CommandeFournisseur($db,'',$_GET['id']); + $commande->fetch($_GET['id']); + $commande->line_up($_GET['rowid']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); + exit; } if ($_GET['action'] == 'down' && $user->rights->fournisseur->commande->creer) { - $commande = new CommandeFournisseur($db,'',$_GET['id']); - $commande->fetch($_GET['id']); - $commande->line_down($_GET['rowid']); - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); - Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); - exit; + $commande = new CommandeFournisseur($db,'',$_GET['id']); + $commande->fetch($_GET['id']); + $commande->line_down($_GET['rowid']); + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); + exit; } if ($_REQUEST['action'] == 'builddoc') // En get ou en post { - /* - * Generation de la commande - * définit dans /includes/modules/commande/modules_commande.php - */ + /* + * Generation de la commande + * définit dans /includes/modules/commande/modules_commande.php + */ - // Sauvegarde le dernier modèle choisi pour générer un document - $commande = new CommandeFournisseur($db, 0, $_REQUEST['id']); - $commande->fetch($_REQUEST['id']); - if ($_REQUEST['model']) - { - $commande->set_pdf_model($user, $_REQUEST['model']); - } + // Sauvegarde le dernier modèle choisi pour générer un document + $commande = new CommandeFournisseur($db, 0, $_REQUEST['id']); + $commande->fetch($_REQUEST['id']); + if ($_REQUEST['model']) + { + $commande->set_pdf_model($user, $_REQUEST['model']); + } - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - $result=commande_supplier_pdf_create($db, $commande->id,$commande->modelpdf,$outputlangs); - if ($result <= 0) - { - dolibarr_print_error($db,$result); - exit; - } - else - { - Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#builddoc'); - exit; - } + if ($_REQUEST['lang_id']) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + $result=commande_supplier_pdf_create($db, $commande->id,$commande->modelpdf,$outputlangs); + if ($result <= 0) + { + dolibarr_print_error($db,$result); + exit; + } + else + { + Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#builddoc'); + exit; + } } // Efface les fichiers if ($action=='remove_file') { - $commande = new CommandeFournisseur($db); + $commande = new CommandeFournisseur($db); - if ($commande->fetch($id)) - { - $upload_dir = $conf->commande->dir_output . "/"; - $file = $upload_dir . '/' . urldecode($_GET['file']); - dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; - } + if ($commande->fetch($id)) + { + $upload_dir = $conf->commande->dir_output . "/"; + $file = $upload_dir . '/' . urldecode($_GET['file']); + dol_delete_file($file); + $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + } } @@ -381,26 +381,26 @@ if ($action=='remove_file') if ($_GET["action"] == 'create') { - $fourn = new Fournisseur($db); - $fourn->fetch($_GET["socid"]); - $commande->modelpdf = 'muscadet'; //test + $fourn = new Fournisseur($db); + $fourn->fetch($_GET["socid"]); + $commande->modelpdf = 'muscadet'; //test - if ($fourn->create_commande($user) > 0) + if ($fourn->create_commande($user) > 0) + { + $idc = $fourn->single_open_commande; + + if ($comclientid != '') { - $idc = $fourn->single_open_commande; - - if ($comclientid != '') - { - $fourn->updateFromCommandeClient($user,$idc,$comclientid); - } - - Header("Location:fiche.php?id=".$idc); - exit; - } - else - { - $mesg=$fourn->error; + $fourn->updateFromCommandeClient($user,$idc,$comclientid); } + + Header("Location:fiche.php?id=".$idc); + exit; + } + else + { + $mesg=$fourn->error; + } } @@ -416,794 +416,493 @@ $html = new Form($db); *********************************************************************/ if ($_GET['action'] == 'create' && $user->rights->fournisseur->commande->creer) { - // Gerer par autre page + // Gerer par autre page } else { - /* *************************************************************************** */ - /* */ - /* Mode vue et edition */ - /* */ - /* *************************************************************************** */ + /* *************************************************************************** */ + /* */ + /* Mode vue et edition */ + /* */ + /* *************************************************************************** */ - $id = $_GET['id']; - if ($id > 0) + $id = $_GET['id']; + if ($id > 0) + { + //if ($mesg) print $mesg.'
'; + + $commande = new CommandeFournisseur($db); + if ( $commande->fetch($_GET['id']) >= 0) { - //if ($mesg) print $mesg.'
'; + $soc = new Societe($db); + $soc->fetch($commande->socid); + + $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++; + + $h = 0; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; + $head[$h][1] = $langs->trans("OrderDispatch"); + $h++; - $commande = new CommandeFournisseur($db); - if ( $commande->fetch($_GET['id']) >= 0) + $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("SupplierOrder"); + dolibarr_fiche_head($head, $a, $title); + + /* + * Confirmation de la suppression de la commande + */ + if ($_GET['action'] == 'delete') + { + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete'); + print '
'; + } + + /* + * Confirmation de la validation + */ + if ($_GET['action'] == 'valid') + { + // on vérifie si la commande est en numérotation provisoire + $ref = substr($commande->ref, 1, 4); + if ($ref == 'PROV') { - $soc = new Societe($db); - $soc->fetch($commande->socid); - - $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++; - - $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("SupplierOrder"); - dolibarr_fiche_head($head, $a, $title); - - /* - * Confirmation de la suppression de la commande - */ - if ($_GET['action'] == 'delete') - { - $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete'); - print '
'; - } - - /* - * Confirmation de la validation - */ - if ($_GET['action'] == 'valid') - { - // on vérifie si la commande est en numérotation provisoire - $ref = substr($commande->ref, 1, 4); - if ($ref == 'PROV') - { - $newref = $commande->getNextNumRef($soc); - } - else - { - $newref = $commande->ref; - } + $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","Approuver la commande","Etes-vous sûr de vouloir approuver cette commande ?","confirm_approve"); - print '
'; - } - /* - * Confirmation de la desapprobation - * - */ - 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 '
'; - } - /* - * 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 '
'; - } - - /* - * 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"], - $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dolibarr_print_date($date_com,'day')),"confirm_commande"); - print '
'; - } - - /* - * Commande - */ - $nbrow=8; - if ($conf->projet->enabled) $nbrow++; - print ''; - - // Ref - print ''; - print ''; - print ''; - - // Fournisseur - print '"; - print ''; - print ''; - - // Statut - print ''; - print ''; - print '"; - - if ($commande->methode_commande_id > 0) - { - print '"; - } - - // Auteur - print ''; - print ''; - print '"; - - // Ligne de 3 colonnes - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - - print "
'.$langs->trans("Ref").''.$commande->ref.'
'.$langs->trans("Supplier")."'; - print ''; - print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'
'.$langs->trans("Status").''; - print $commande->getLibStatut(4); - print "
'.$langs->trans("Date").''; - - if ($commande->date_commande) - { - print dolibarr_print_date($commande->date_commande,"%A %d %B %Y")."\n"; - } - - print ''; - if ($commande->methode_commande) - { - print "Méthode : " .$commande->methode_commande; - } - print "
'.$langs->trans("AuthorRequest").''.$author->getNomUrl(1).''; - print " 
'.$langs->trans("AmountHT").''.price($commande->total_ht).''.$langs->trans("Currency".$conf->monnaie).' 
'.$langs->trans("AmountVAT").''.price($commande->total_tva).''.$langs->trans("Currency".$conf->monnaie).' 
'.$langs->trans("AmountTTC").''.price($commande->total_ttc).''.$langs->trans("Currency".$conf->monnaie).' 
"; - - if ($mesg) print $mesg; - else print '
'; - - /* - * Lignes de commandes - */ - print ''; - - $sql = "SELECT l.ref, l.fk_product, l.description, l.price, l.qty"; - $sql.= ", l.rowid, l.tva_tx, l.remise_percent, l.subprice"; - $sql.= ", p.label"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; - $sql.= " WHERE l.fk_commande = ".$commande->id; - $sql.= " ORDER BY l.rowid"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; $total = 0; - - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=false; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - print ""; - print '"; - print ''; - print ''; - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - print '\n"; - if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && $_GET["action"] <> 'valid' && $_GET["action"] != 'editline') - { - print ''; - - print ''; - } - else - { - print ''; - } - print ""; - - if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) - { - print "id\" method=\"post\">"; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '' . "\n"; - print "\n"; - } - $i++; - $var=!$var; - } - $db->free(); - } - else - { - dolibarr_print_error($db); - } - - /* - * Ajouter une ligne - */ - if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc')) - { - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''."\n"; - - $var=false; - print "".''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - print ""; - } - - print "
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").''.$langs->trans("PriceU").'  
'; - print ''.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.''; - print ' - '.$objp->label; - if ($objp->description) print '
'.nl2br($objp->description); - print "
'.$objp->tva_tx.'%'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice)."rowid.'#'.$objp->rowid.'">'; - print img_edit(); - print 'rowid.'">'; - print img_delete(); - print '  
'; - print ''; - print ''; - print ''; - print ''; - $html->select_tva('tva_tx',$objp->tva_tx); - print '%'; - print '
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").''.$langs->trans("PriceU").'  
'; - $html->select_produits_fournisseurs($commande->fourn_id,'','idprod',$filtre); - print '% 
"; - print ''; - - - /** - * Boutons actions - */ - if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc')) - { - print '
'; - - if ($commande->statut == 0 && $num > 0) - { - if ($user->rights->fournisseur->commande->valider) - - - - - - - - - { - print ''.$langs->trans("Valid").''; - } - - - - - - } - - if ($commande->statut == 1) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - if ($user->rights->fournisseur->commande->approuver) - { - print ''.$langs->trans("ApproveOrder").''; - - print ''.$langs->trans("RefuseOrder").''; - - - - - - - - - - - - - - } - - if ($user->rights->fournisseur->commande->annuler) - { - print ''.$langs->trans("CancelOrder").''; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - } - - - - - - - - - - if ($commande->statut == 2) - - - - - - - - - - - - - - - - - - - - { - if ($user->rights->fournisseur->commande->annuler) - - - - - - - - - - - - - - - - - - - - - - - - { - print ''.$langs->trans("CancelOrder").''; - } - - - - - - } - - - - - if ($commande->statut == 0) - - - - - - - - - - - - - - - - { - if ($user->rights->fournisseur->commande->creer) - - - - - - - - - - { - print ''.$langs->trans("Delete").''; - } - - } - - - // Build PDF - if ($commande->statut > 0) - { - if ($user->rights->fournisseur->commande->creer) - { - print ''.$langs->trans("BuildPDF").''; - } - - } - print "
"; - } - - - print '
'; - - - - /* - * Documents générés - * - */ - $comfournref = sanitize_string($commande->ref); - $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; - - $somethingshown=$html->show_documents('commande_fournisseur',$comfournref,$filedir,$urlsource,$commande->statut>0?1:0,$delallowed,$commande->modelpdf); - - - print ''; - - /* - * - * - */ - if ($_GET["action"] == 'classer') - { - print '
'; - print ''; - print ''; - print '"; - print '
'.$langs->trans("Project").''; - - $proj = new Project($db); - $html->select_array("projetid",$proj->liste_array($commande->socid)); - - print "
'; - } - - /* - * - * - */ - if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2) - { - /** - * Commander - */ - $form = new Form($db); - - print '
'; - print '
'; - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print '
'.$langs->trans("ToOrder").'
'.$langs->trans("OrderDate").''; - print $form->select_date('','','','','',"commande"); - print '
'.$langs->trans("OrderMode").''; - $html->select_methodes_commande('',"methodecommande",1); - print '
'.$langs->trans("Comment").'
'; - print '
'; - } - - /* - * - * - */ - if ( $user->rights->fournisseur->commande->receptionner && ($commande->statut == 3 ||$commande->statut == 4 )) - { - /** - * Réceptionner - */ - $form = new Form($db); - - print '
'; - print '
'; - print ''; - print ''; - print ''; - print '\n"; - - print "'; - print ''; - print ''; - print "
Réceptionner
Date de livraison'; - print $form->select_date('','','','','',"commande"); - print "
Livraison\n"; - $liv = array(); - $liv['par'] = "Partielle"; - $liv['tot'] = "Totale"; - - print $form->select_array("type",$liv); - - - print '
Commentaire
\n"; - print "
\n"; - } - print '
'; - } - else + $text=$langs->trans('ConfirmValidateOrder',$newref); + if ($conf->notification->enabled) { - // Commande non trouvée - dolibarr_print_error($db); + 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","Approuver la commande","Etes-vous sûr de vouloir approuver cette commande ?","confirm_approve"); + print '
'; + } + /* + * Confirmation de la desapprobation + * + */ + 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 '
'; + } + /* + * 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 '
'; + } + + /* + * 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"], + $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dolibarr_print_date($date_com,'day')),"confirm_commande"); + print '
'; + } + + /* + * Commande + */ + $nbrow=8; + if ($conf->projet->enabled) $nbrow++; + print ''; + + // Ref + print ''; + print ''; + print ''; + + // Fournisseur + print '"; + print ''; + print ''; + + // Statut + print ''; + print ''; + print '"; + if ($commande->methode_commande_id > 0) + { + print '"; + } + + // Auteur + print ''; + print ''; + print '"; + + // Ligne de 3 colonnes + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + + print "
'.$langs->trans("Ref").''.$commande->ref.'
'.$langs->trans("Supplier")."'; + print ''; + print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'
'.$langs->trans("Status").''; + print $commande->getLibStatut(4); + print "
'.$langs->trans("Date").''; + + if ($commande->date_commande) + { + print dolibarr_print_date($commande->date_commande,"%A %d %B %Y")."\n"; + } + + print ''; + if ($commande->methode_commande) + { + print "Méthode : " .$commande->methode_commande; + } + print "
'.$langs->trans("AuthorRequest").''.$author->getNomUrl(1).''; + print " 
'.$langs->trans("AmountHT").''.price($commande->total_ht).''.$langs->trans("Currency".$conf->monnaie).' 
'.$langs->trans("AmountVAT").''.price($commande->total_tva).''.$langs->trans("Currency".$conf->monnaie).' 
'.$langs->trans("AmountTTC").''.price($commande->total_ttc).''.$langs->trans("Currency".$conf->monnaie).' 
"; + + if ($mesg) print $mesg; + else print '
'; + + /* + * Lignes de commandes + */ + print ''; + + $sql = "SELECT l.ref, l.fk_product, l.description, l.price, l.qty"; + $sql.= ", l.rowid, l.tva_tx, l.remise_percent, l.subprice"; + $sql.= ", p.label"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; + $sql.= " WHERE l.fk_commande = ".$commande->id; + $sql.= " ORDER BY l.rowid"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=false; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + print ""; + print '"; + print ''; + print ''; + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + print '\n"; + if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && $_GET["action"] <> 'valid' && $_GET["action"] != 'editline') + { + print ''; + + print ''; + } + else + { + print ''; + } + print ""; + + if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) + { + print "id\" method=\"post\">"; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '' . "\n"; + print "\n"; + } + $i++; + $var=!$var; + } + $db->free(); + } + else + { + dolibarr_print_error($db); + } + + /* + * Ajouter une ligne + */ + if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc')) + { + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; + + $var=false; + print "".''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ""; + } + + print "
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").''.$langs->trans("PriceU").'  
'; + print ''.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.''; + print ' - '.$objp->label; + if ($objp->description) print '
'.nl2br($objp->description); + print "
'.$objp->tva_tx.'%'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice)."rowid.'#'.$objp->rowid.'">'; + print img_edit(); + print 'rowid.'">'; + print img_delete(); + print '  
'; + print ''; + print ''; + print ''; + print ''; + $html->select_tva('tva_tx',$objp->tva_tx); + print '%'; + print '
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").''.$langs->trans("PriceU").'  
'; + $html->select_produits_fournisseurs($commande->fourn_id,'','idprod',$filtre); + print '% 
"; + print ''; + + + /** + * Boutons actions + */ + if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc')) + { + print '
'; + + if ($commande->statut == 0 && $num > 0) + { + if ($user->rights->fournisseur->commande->valider) + { + print ''.$langs->trans("Valid").''; + } + } + + if ($commande->statut == 1) + { + if ($user->rights->fournisseur->commande->approuver) + { + print ''.$langs->trans("ApproveOrder").''; + + print ''.$langs->trans("RefuseOrder").''; + } + + if ($user->rights->fournisseur->commande->annuler) + { + print ''.$langs->trans("CancelOrder").''; + } + + } + + if ($commande->statut == 2) + { + if ($user->rights->fournisseur->commande->annuler) + { + print ''.$langs->trans("CancelOrder").''; + } + } + + if ($commande->statut == 0) + { + if ($user->rights->fournisseur->commande->creer) + { + print ''.$langs->trans("Delete").''; + } + } + + + // Build PDF + if ($commande->statut > 0) + { + if ($user->rights->fournisseur->commande->creer) + { + print ''.$langs->trans("BuildPDF").''; + } + } + print "
"; + } + + print '
'; + + /* + * Documents générés + * + */ + $comfournref = sanitize_string($commande->ref); + $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; + + $somethingshown=$html->show_documents('commande_fournisseur',$comfournref,$filedir,$urlsource,$commande->statut>0?1:0,$delallowed,$commande->modelpdf); + + + print ''; + + /* + * + * + */ + if ($_GET["action"] == 'classer') + { + print '
'; + print ''; + print ''; + print '"; + print '
'.$langs->trans("Project").''; + + $proj = new Project($db); + $html->select_array("projetid",$proj->liste_array($commande->socid)); + + print "
'; + } + + /* + * + * + */ + if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2) + { + /** + * Commander + */ + $form = new Form($db); + + print '
'; + print '
'; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print '
'.$langs->trans("ToOrder").'
'.$langs->trans("OrderDate").''; + print $form->select_date('','','','','',"commande"); + print '
'.$langs->trans("OrderMode").''; + $html->select_methodes_commande('',"methodecommande",1); + print '
'.$langs->trans("Comment").'
'; + print '
'; + } + + /* + * + * + */ + if ( $user->rights->fournisseur->commande->receptionner && ($commande->statut == 3 ||$commande->statut == 4 )) + { + /** + * Réceptionner + */ + $form = new Form($db); + + print '
'; + print '
'; + print ''; + print ''; + print ''; + print '\n"; + + print "'; + print ''; + print ''; + print "
Réceptionner
Date de livraison'; + print $form->select_date('','','','','',"commande"); + print "
Livraison\n"; + $liv = array(); + $liv['par'] = "Partielle"; + $liv['tot'] = "Totale"; + + print $form->select_array("type",$liv); + + + print '
Commentaire
\n"; + print "
\n"; + } + print '
'; + } + else + { + // Commande non trouvée + dolibarr_print_error($db); + } + } +} $db->close();