diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index c5e63fc7457..1d306975533 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1573,6 +1573,22 @@ else */ if ($_GET['action'] == 'presend') { + $orderref = sanitize_string($commande->ref); + $file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf'; + + // Construit PDF si non existant + if (! is_readable($file)) + { + $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + $result=commande_pdf_create($db, $_REQUEST['id'], '', $_REQUEST['model'], $outputlangs); + if ($result <= 0) + { + dolibarr_print_error($db,$result); + exit; + } + } + print '
'; print_titre($langs->trans('SendOrderByMail')); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 122c64eecf2..05336643551 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -56,15 +56,6 @@ if ($_POST["action"] == 'classin') $commande->fetch($_GET["id"]); $commande->classin($_POST["projetid"]); } -/* - * - */ -if ($_GET["action"] == 'pdf') -{ - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET["id"]); - $commande->generate_pdf(); -} if ($_POST["action"] == 'setremise' && $user->rights->commande->creer) { @@ -558,9 +549,9 @@ if ($_GET["id"] > 0) if ($commande->statut == 2) { - if ($user->rights->fournisseur->commande->approuver) + if ($user->rights->fournisseur->commande->annuler) { - print ''.$langs->trans("RefuseOrder").''; + print ''.$langs->trans("CancelOrder").''; } } @@ -631,7 +622,7 @@ if ($_GET["id"] > 0) print '
'; print ''; print ''; - print '
Projet'; + print '
'.$langs->trans("Project").''; $proj = new Project($db); $html->select_array("projetid",$proj->liste_array($commande->soc_id)); @@ -653,20 +644,17 @@ if ($_GET["id"] > 0) print '
'; print ''; - print ''; - print ''; - print '
Commander
Date commande'; + print ''; + print ''; + print ''; - $commande->get_methodes_commande(); - - print ''; - print ''; + + print ''; print ''; print '
'.$langs->trans("ToOrder").'
'.$langs->trans("OrderDate").''; print $form->select_date('','','','','',"commande"); print '
Méthode de commande'; - - print $form->select_array("methodecommande",$commande->methodes_commande); - + print '
'.$langs->trans("OrderMode").''; + $html->select_methodes_commande('',"methodecommande",1); print '
Commentaire
'.$langs->trans("Comment").'
'; print ''; diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 9a2b3b6bf3c..7ab2476b540 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -400,45 +400,46 @@ class CommandeFournisseur extends Commande } } } - /** - * Approuve une commande - * - * - */ - function approve($user) - { - dolibarr_syslog("CommandeFournisseur::Approve"); - $result = 0; - if ($user->rights->fournisseur->commande->approuver) + + /** + * \brief Approuve une commande + * + */ + function approve($user) { - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 2"; - $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 1 ;"; - - if ($this->db->query($sql) ) - { - $result = 0; - $this->log($user, 2, time()); - - $subject = "Votre commande ".$this->ref." a été approuvée"; - $message = "Bonjour,\n\n"; - $message .= "Votre commande ".$this->ref." a été approuvée, par $user->fullname"; - $message .= "\n\nCordialement,\n\n"; - - $this->_NotifyCreator($user, $subject, $message); - - } - else - { - dolibarr_syslog("CommandeFournisseur::Approve Error -1"); - $result = -1; - } + dolibarr_syslog("CommandeFournisseur::Approve"); + $result = 0; + if ($user->rights->fournisseur->commande->approuver) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 2"; + $sql .= " WHERE rowid = ".$this->id." AND fk_statut = 1 ;"; + + if ($this->db->query($sql) ) + { + $result = 0; + $this->log($user, 2, time()); + + $subject = "Votre commande ".$this->ref." a été approuvée"; + $message = "Bonjour,\n\n"; + $message .= "Votre commande ".$this->ref." a été approuvée, par $user->fullname"; + $message .= "\n\nCordialement,\n\n"; + + $this->_NotifyCreator($user, $subject, $message); + + } + else + { + dolibarr_syslog("CommandeFournisseur::Approve Error -1"); + $result = -1; + } + } + else + { + dolibarr_syslog("CommandeFournisseur::Approve Not Authorized"); + } + return $result ; } - else - { - dolibarr_syslog("CommandeFournisseur::Approve Not Authorized"); - } - return $result ; - } + /** * Refuse une commande * diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 8b807d0a634..644810a1955 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -250,9 +250,46 @@ class Form print ''; print ''; } - - + + /** + * + * + */ + function select_methodes_commande($selected='',$htmlname='source_id',$addempty=0) + { + global $conf,$langs; + $listemethodes=array(); + + $sql = "SELECT rowid, libelle "; + $sql.= " FROM ".MAIN_DB_PREFIX."c_methode_commande_fournisseur"; + $sql.= " WHERE active = 1"; + + $resql=$this->db->query($sql); + if ($resql) + { + $i = 0; + $num = $this->db->num_rows(); + while ($i < $num) + { + $row = $this->db->fetch_row(); + + $listemethodes[$row[0]] = $row[1]; + + $i++; + } + } + else + { + dolibarr_print_error($this->db); + return -1; + } + + print $this->select_array($htmlname,$listemethodes,$selected,$addempty); + return 1; + } + + /** * \brief Retourne la liste déroulante des pays actifs, dans la langue de l'utilisateur * \param selected Code pays pré-sélectionné * \param htmlname Nom de la liste deroulante @@ -2070,7 +2107,7 @@ class Form \param htmlname Nom de la zone select \param array Tableau de key+valeur \param id Key pré-sélectionnée - \param show_empty 1 si il faut un valeur " " dans la liste, 0 sinon + \param show_empty 1 si il faut ajouter une valeur " " dans la liste, 0 sinon \param key_in_label 1 pour afficher la key dans la valeur "[key] value" \param value_as_key 1 pour utiliser la valeur comme clé */ @@ -2078,15 +2115,9 @@ class Form { print '