Mise en facteur de la liste des mthodes de commandes
This commit is contained in:
parent
7f829e3760
commit
abb2e8d0d2
@ -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 '<br>';
|
||||
print_titre($langs->trans('SendOrderByMail'));
|
||||
|
||||
|
||||
@ -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 '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&action=cancel">'.$langs->trans("CancelOrder").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -631,7 +622,7 @@ if ($_GET["id"] > 0)
|
||||
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>';
|
||||
print '<tr><td>'.$langs->trans("Project").'</td><td>';
|
||||
|
||||
$proj = new Project($db);
|
||||
$html->select_array("projetid",$proj->liste_array($commande->soc_id));
|
||||
@ -653,20 +644,17 @@ if ($_GET["id"] > 0)
|
||||
|
||||
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 '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ToOrder").'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("OrderDate").'</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 '<tr><td>'.$langs->trans("OrderMode").'</td><td>';
|
||||
$html->select_methodes_commande('',"methodecommande",1);
|
||||
print '</td></tr>';
|
||||
print '<tr><td>Commentaire</td><td><input size="30" type="text" name="commentaire"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Comment").'</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>';
|
||||
|
||||
@ -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
|
||||
*
|
||||
|
||||
@ -250,9 +250,46 @@ class Form
|
||||
print '<option value="6"'.($selected=='6'?' selected="true"':'').'>'.$langs->trans('OrderSource6').'</option>';
|
||||
print '</select>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
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 '<select class="flat" name="'.$htmlname.'">';
|
||||
|
||||
$i = 0;
|
||||
|
||||
if (strlen($id))
|
||||
if ($show_empty)
|
||||
{
|
||||
if ($show_empty == 1)
|
||||
{
|
||||
$array[0] = " ";
|
||||
}
|
||||
reset($array);
|
||||
print '<option value="-1"'.($id==-1?' selected="true"':'').'> </option>'."\n";
|
||||
}
|
||||
|
||||
while (list($key, $value) = each ($array))
|
||||
|
||||
@ -63,6 +63,8 @@ RefCdeClient=Ref. customer order
|
||||
RefCdeClientShort=Ref. cust. order
|
||||
SendPropalByMail=Send order by mail
|
||||
ActionsOnOrder=Actions on order
|
||||
NoArticleOfTypeProduct=No article of type 'product' so no shippable article for this order
|
||||
OrderMode=Order method
|
||||
# Sources
|
||||
OrderSource0=Commercial proposal
|
||||
OrderSource1=Internet
|
||||
|
||||
@ -64,6 +64,7 @@ RefCdeClientShort=R
|
||||
SendOrderByMail=Envoi commande par mail
|
||||
ActionsOnOrder=Actions sur la commande
|
||||
NoArticleOfTypeProduct=Pas d'article de type 'produit' et donc expédiable dans cette commande
|
||||
OrderMode=Méthode de commande
|
||||
# Sources
|
||||
OrderSource0=Proposition commerciale
|
||||
OrderSource1=Internet
|
||||
|
||||
Loading…
Reference in New Issue
Block a user