Quelques amliorations diverses sur gestion des xpditions
This commit is contained in:
parent
7facc82362
commit
1b6d7d5de4
@ -943,9 +943,8 @@ class Commande extends CommonObject
|
||||
{
|
||||
if ($user->rights->commande->creer)
|
||||
{
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET model_pdf = '$modelpdf'";
|
||||
$sql .= " WHERE rowid = $this->id AND fk_statut < 2 ;";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
@ -970,7 +969,7 @@ class Commande extends CommonObject
|
||||
$this->lignes = array();
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,';
|
||||
$sql.= ' l.remise_percent, l.subprice, l.rang, l.coef, l.label,';
|
||||
$sql.= ' p.ref as product_ref, p.description as product_desc';
|
||||
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
|
||||
$sql.= ' WHERE l.fk_commande = '.$this->id;
|
||||
@ -1001,9 +1000,10 @@ class Commande extends CommonObject
|
||||
$ligne->coef = $objp->coef;
|
||||
$ligne->rang = $objp->rang;
|
||||
|
||||
$ligne->libelle = $objp->label; // Label produit
|
||||
$ligne->product_desc = $objp->product_desc; // Description produit
|
||||
$ligne->ref = $objp->product_ref;
|
||||
$ligne->ref = $objp->product_ref;
|
||||
$ligne->libelle = $objp->label; // Label produit
|
||||
$ligne->product_desc = $objp->product_desc; // Description produit
|
||||
$ligne->fk_product_type= $objp->fk_product_type; // Produit ou service
|
||||
|
||||
$this->lignes[$i] = $ligne;
|
||||
$i++;
|
||||
@ -1012,14 +1012,27 @@ class Commande extends CommonObject
|
||||
}
|
||||
return $this->lignes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoie nombre de lignes de type produits. Doit etre appelé après fetch_lignes
|
||||
* \return int <0 si ko, Nbre de lignes produits sinon
|
||||
*/
|
||||
function getNbOfProductsLines()
|
||||
{
|
||||
$nb=0;
|
||||
foreach($this->lignes as $ligne)
|
||||
{
|
||||
if ($ligne->fk_product_type == 0) $nb++;
|
||||
}
|
||||
return $nb;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function fetch_adresse_livraison($id)
|
||||
*
|
||||
*
|
||||
*/
|
||||
function fetch_adresse_livraison($id)
|
||||
{
|
||||
$idadresse = $id;
|
||||
$adresse = new Societe($this->db);
|
||||
@ -1414,7 +1427,7 @@ class Commande extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi la liste des propal (éventuellement filtrée sur un user) dans un tableau
|
||||
* \brief Renvoi la liste des commandes (éventuellement filtrée sur un user) dans un tableau
|
||||
* \param brouillon 0=non brouillon, 1=brouillon
|
||||
* \param user Objet user de filtre
|
||||
* \return int -1 si erreur, tableau résultat si ok
|
||||
|
||||
@ -234,7 +234,7 @@ if ($id > 0)
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print '<tr><td width="18%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $commande->ref;
|
||||
print "</td></tr>";
|
||||
|
||||
|
||||
@ -1600,7 +1600,8 @@ else
|
||||
}
|
||||
|
||||
// Ship
|
||||
if ($commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
|
||||
if ($commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer
|
||||
&& $commande->getNbOfProductsLines() > 0)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$_GET['id'].'">'.$langs->trans('ShipProduct').'</a>';
|
||||
}
|
||||
@ -1690,59 +1691,8 @@ else
|
||||
}
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
/*
|
||||
* Liste des expéditions
|
||||
*/
|
||||
$sql = 'SELECT e.rowid as expedition_id, e.ref,'.$db->pdate('e.date_expedition').' as de';
|
||||
if ($conf->livraison->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref";
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e';
|
||||
if ($conf->livraison->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid";
|
||||
$sql .= ' WHERE e.fk_commande = '. $commande->id;
|
||||
// Rien a droite
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
if ($num)
|
||||
{
|
||||
print_titre($langs->trans('Sendings'));
|
||||
$i = 0; $total = 0;
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans('Sendings').'</td>';
|
||||
if ($conf->livraison->enabled)
|
||||
{
|
||||
print '<td>'.$langs->trans("DeliveryOrder").'</td>';
|
||||
}
|
||||
print '<td>'.$langs->trans('Date').'</td></tr>';
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="../expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans('ShowSending'),'sending').' '.$objp->ref.'</a></td>';
|
||||
if ($conf->livraison->enabled)
|
||||
{
|
||||
if ($objp->livraison_id)
|
||||
{
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/livraison/fiche.php?id='.$objp->livraison_id.'">'.img_object($langs->trans("ShowSending"),'generic').' '.$objp->livraison_ref.'<a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'&action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'<a></td>';
|
||||
}
|
||||
}
|
||||
print '<td>'.dolibarr_print_date($objp->de).'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
|
||||
/*
|
||||
|
||||
@ -111,7 +111,7 @@ if ($_GET["id"])
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print '<tr><td width="18%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $commande->ref;
|
||||
print "</td></tr>";
|
||||
|
||||
|
||||
@ -538,22 +538,22 @@ if ($_GET["id"] > 0)
|
||||
}
|
||||
|
||||
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
|
||||
/*
|
||||
* Documents générés
|
||||
*
|
||||
*/
|
||||
$comref = sanitize_string($commande->ref);
|
||||
$file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf';
|
||||
$relativepath = $comref.'/'.$comref.'.pdf';
|
||||
$filedir = $conf->commande->dir_output . '/' . $comref;
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id;
|
||||
$genallowed=0;
|
||||
$delallowed=0;
|
||||
|
||||
$somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf);
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
|
||||
/*
|
||||
* Documents générés
|
||||
*
|
||||
*/
|
||||
$comref = sanitize_string($commande->ref);
|
||||
$file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf';
|
||||
$relativepath = $comref.'/'.$comref.'.pdf';
|
||||
$filedir = $conf->commande->dir_output . '/' . $comref;
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id;
|
||||
$genallowed=0;
|
||||
$delallowed=0;
|
||||
|
||||
$somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf);
|
||||
|
||||
/*
|
||||
* Liste des factures
|
||||
@ -598,38 +598,73 @@ if ($_GET["id"] > 0)
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
/*
|
||||
* Liste des expéditions
|
||||
*/
|
||||
$sql = "SELECT e.rowid as expedition_id, e.ref,".$db->pdate("e.date_expedition")." as de";
|
||||
if ($conf->livraison->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||
if ($conf->livraison->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid";
|
||||
$sql .= " WHERE e.fk_commande = ". $commande->id;
|
||||
// Rien a droite
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
print "</td></tr></table>";
|
||||
|
||||
|
||||
/*
|
||||
* Liste des expéditions
|
||||
*/
|
||||
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande";
|
||||
$sql .= " , ed.qty as qty_livre, e.ref, ed.fk_expedition as expedition_id";
|
||||
$sql .= ",".$db->pdate("e.date_expedition")." as date_expedition";
|
||||
if ($conf->livraison->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
|
||||
if ($conf->livraison->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid";
|
||||
$sql .= " WHERE cd.fk_commande = ".$commande->id;
|
||||
$sql .= " AND cd.rowid = ed.fk_commande_ligne";
|
||||
$sql .= " AND ed.fk_expedition = e.rowid";
|
||||
$sql .= " ORDER BY cd.fk_product";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
if ($num)
|
||||
{
|
||||
print_titre($langs->trans("Sendings"));
|
||||
$i = 0; $total = 0;
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr $bc[$var]><td>".$langs->trans("Sendings")."</td>";
|
||||
if ($somethingshown) print '<br>';
|
||||
|
||||
print_titre($langs->trans("SendingsForSameOrder"));
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$langs->trans("Sending").'</td>';
|
||||
print '<td>'.$langs->trans("Product").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Date").'</td>';
|
||||
if ($conf->livraison->enabled)
|
||||
{
|
||||
print '<td>'.$langs->trans("DeliveryOrder").'</td>';
|
||||
}
|
||||
print "<td>".$langs->trans("Date")."</td></tr>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
$objp = $db->fetch_object($resql);
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="../../expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),"sending").' '.$objp->ref.'</a></td>';
|
||||
print '<td align="left"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>';
|
||||
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($objp->fk_product);
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
|
||||
if ($objp->description) print '<br>'.nl2br($objp->description);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
|
||||
}
|
||||
print '<td align="center">'.$objp->qty_livre.'</td>';
|
||||
print '<td align="center">'.dolibarr_print_date($objp->date_expedition).'</td>';
|
||||
if ($conf->livraison->enabled)
|
||||
{
|
||||
if ($objp->livraison_id)
|
||||
@ -641,19 +676,20 @@ if ($_GET["id"] > 0)
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'&action=create_delivery">'.$langs->trans("CreateDeliveryOrder").'<a></td>';
|
||||
}
|
||||
}
|
||||
print "<td>".dolibarr_print_date($objp->de)."</td></tr>\n";
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print "</td></tr></table>";
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -422,9 +422,33 @@ if ($_GET["id"] > 0)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
/*
|
||||
* Documents générés
|
||||
*
|
||||
*/
|
||||
$comref = sanitize_string($commande->ref);
|
||||
$file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf';
|
||||
$relativepath = $comref.'/'.$comref.'.pdf';
|
||||
$filedir = $conf->commande->dir_output . '/' . $comref;
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id;
|
||||
$genallowed=0;
|
||||
$delallowed=0;
|
||||
|
||||
$somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf);
|
||||
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
|
||||
// Bouton expedier avec gestion des stocks
|
||||
if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
|
||||
{
|
||||
print_titre($langs->trans("NewSending"));
|
||||
|
||||
print '<form method="GET" action="'.DOL_URL_ROOT.'/expedition/fiche.php">';
|
||||
print '<input type="hidden" name="action" value="create">';
|
||||
print '<input type="hidden" name="id" value="'.$commande->id.'">';
|
||||
@ -454,12 +478,17 @@ if ($_GET["id"] > 0)
|
||||
print '<input type="submit" class="button" named="save" value="'.$langs->trans("NewSending").'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table><br>";
|
||||
print "</table>";
|
||||
print "</form>\n";
|
||||
|
||||
$somethingshown=1;
|
||||
}
|
||||
|
||||
print "</td></tr></table>";
|
||||
|
||||
|
||||
/*
|
||||
* Déjà livré
|
||||
* Liste des expéditions
|
||||
*/
|
||||
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande";
|
||||
$sql .= " , ed.qty as qty_livre, e.ref, ed.fk_expedition as expedition_id";
|
||||
@ -471,7 +500,6 @@ if ($_GET["id"] > 0)
|
||||
$sql .= " WHERE cd.fk_commande = ".$commande->id;
|
||||
$sql .= " AND cd.rowid = ed.fk_commande_ligne";
|
||||
$sql .= " AND ed.fk_expedition = e.rowid";
|
||||
$sql .= " AND e.fk_statut > 0";
|
||||
$sql .= " ORDER BY cd.fk_product";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -482,9 +510,9 @@ if ($_GET["id"] > 0)
|
||||
|
||||
if ($num)
|
||||
{
|
||||
print '<br>';
|
||||
if ($somethingshown) print '<br>';
|
||||
|
||||
print_titre($langs->trans("OtherSendingsForSameOrder"));
|
||||
print_titre($langs->trans("SendingsForSameOrder"));
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$langs->trans("Sending").'</td>';
|
||||
|
||||
@ -40,6 +40,7 @@ class Expedition extends CommonObject
|
||||
var $id;
|
||||
var $brouillon;
|
||||
var $entrepot_id;
|
||||
var $modelpdf;
|
||||
|
||||
|
||||
/**
|
||||
@ -192,11 +193,12 @@ class Expedition extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT e.rowid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut, e.fk_commande, e.fk_entrepot";
|
||||
$sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, c.fk_adresse_livraison";
|
||||
$sql = "SELECT e.rowid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut, e.fk_commande, e.fk_entrepot,";
|
||||
$sql.= " ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf,";
|
||||
$sql.= " c.fk_adresse_livraison";
|
||||
if ($conf->livraison->enabled) $sql.=", l.rowid as livraison_id";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."expedition as e";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."expedition as e";
|
||||
if ($conf->livraison->enabled) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON e.rowid = l.fk_expedition";
|
||||
$sql.= " WHERE e.rowid = ".$id;
|
||||
$sql.= " AND e.fk_commande = c.rowid";
|
||||
@ -219,6 +221,7 @@ class Expedition extends CommonObject
|
||||
$this->date = $obj->date_expedition;
|
||||
$this->entrepot_id = $obj->fk_entrepot;
|
||||
$this->adresse_livraison_id = $obj->fk_adresse_livraison;
|
||||
$this->modelpdf = $obj->model_pdf;
|
||||
$this->db->free($result);
|
||||
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
@ -519,6 +522,8 @@ class Expedition extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Classe la commande
|
||||
*
|
||||
@ -540,6 +545,32 @@ class Expedition extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Positionne modele derniere generation
|
||||
* \param user Objet use qui modifie
|
||||
* \param modelpdf Nom du modele
|
||||
*/
|
||||
function set_pdf_model($user, $modelpdf)
|
||||
{
|
||||
if ($user->rights->expedition->creer)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET model_pdf = '$modelpdf'";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->modelpdf=$modelpdf;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Lit la commande associée
|
||||
*
|
||||
@ -588,22 +619,39 @@ class Expedition extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne le libellé du statut d'un entrepot (ouvert, fermé)
|
||||
* \brief Retourne le libellé du statut d'une expedition
|
||||
* \return string Libellé
|
||||
*/
|
||||
function getLibStatut()
|
||||
function getLibStatut($mode=0)
|
||||
{
|
||||
return $this->LibStatut($this->statut);
|
||||
return $this->LibStatut($this->statut,$mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi le libellé d'un statut donné
|
||||
* \param statut id statut
|
||||
* \return string Libellé
|
||||
*/
|
||||
function LibStatut($statut)
|
||||
/**
|
||||
* \brief Renvoi le libellé d'un statut donné
|
||||
* \param statut Id statut
|
||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
|
||||
* \return string Libellé
|
||||
*/
|
||||
function LibStatut($statut,$mode)
|
||||
{
|
||||
return $this->statuts[$statut];
|
||||
global $langs;
|
||||
|
||||
if ($mode==0)
|
||||
{
|
||||
if ($statut==0) return $this->statuts[$statut];
|
||||
if ($statut==1) return $this->statuts[$statut];
|
||||
}
|
||||
if ($mode==1)
|
||||
{
|
||||
if ($statut==0) return $this->statuts[$statut];
|
||||
if ($statut==1) return $this->statuts[$statut];
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if ($statut==0) return img_picto($langs->trans('StatusSendingDraft'),'statut0').' '.$langs->trans('StatusSendingDraft');
|
||||
if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -139,12 +139,20 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||
*/
|
||||
if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||
{
|
||||
// Sauvegarde le dernier modèle choisi pour générer un document
|
||||
$expedition = new Expedition($db, 0, $_REQUEST['id']);
|
||||
$expedition->fetch($_REQUEST['id']);
|
||||
if ($_REQUEST['model'])
|
||||
{
|
||||
$expedition->set_pdf_model($user, $_REQUEST['model']);
|
||||
}
|
||||
|
||||
if ($_REQUEST['lang_id'])
|
||||
{
|
||||
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
$result=expedition_pdf_create($db, $_REQUEST['id'],$_REQUEST['model'],$outputlangs);
|
||||
$result=expedition_pdf_create($db, $expedition->id,$expedition->modelpdf,$outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dolibarr_print_error($db,$result);
|
||||
@ -513,7 +521,7 @@ else
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td>';
|
||||
print '<td colspan="3">'.$expedition->getLibStatut()."</td>\n";
|
||||
print '<td colspan="3">'.$expedition->getLibStatut(4)."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
if (!$conf->expedition->enabled && $conf->stock->enabled)
|
||||
@ -617,8 +625,11 @@ else
|
||||
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>';
|
||||
}
|
||||
|
||||
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&action=builddoc">'.$langs->trans('BuildPDF').'</a>';
|
||||
|
||||
if ($user->rights->expedition->lire && ($expedition->statut > 0))
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&action=builddoc">'.$langs->trans('BuildPDF').'</a>';
|
||||
}
|
||||
|
||||
if ($expedition->brouillon && $user->rights->expedition->supprimer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?id='.$expedition->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
@ -639,7 +650,7 @@ else
|
||||
|
||||
$urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id;
|
||||
|
||||
$genallowed=$user->rights->expedition->creer && ($expedition->statut > 0);
|
||||
$genallowed=$user->rights->expedition->lire && ($expedition->statut > 0);
|
||||
$delallowed=$user->rights->expedition->supprimer;
|
||||
//$genallowed=1;
|
||||
//$delallowed=0;
|
||||
@ -648,7 +659,7 @@ else
|
||||
if ($genallowed && ! $somethingshown) $somethingshown=1;
|
||||
|
||||
/*
|
||||
* Déjà livre
|
||||
* Autres expeditions
|
||||
*/
|
||||
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande";
|
||||
$sql .= " , ed.qty as qty_livre, e.ref, ed.fk_expedition as expedition_id";
|
||||
@ -659,7 +670,6 @@ else
|
||||
$sql .= " AND e.rowid <> ".$expedition->id;
|
||||
$sql .= " AND cd.rowid = ed.fk_commande_ligne";
|
||||
$sql .= " AND ed.fk_expedition = e.rowid";
|
||||
$sql .= " AND e.fk_statut > 0";
|
||||
$sql .= " ORDER BY cd.fk_product";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
@ -716,102 +726,11 @@ else
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Commandes associées
|
||||
*
|
||||
*/
|
||||
$file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf";
|
||||
$relativepath = $commande->ref . "/" . $commande->ref . ".pdf";
|
||||
|
||||
$var=true;
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
print '<br>';
|
||||
print_titre("Orders");
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
print "<tr $bc[$true]><td>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>\n";
|
||||
}
|
||||
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
|
||||
/*
|
||||
* Liste des actions
|
||||
*
|
||||
*/
|
||||
print_titre("Actions");
|
||||
|
||||
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql .= " WHERE a.fk_soc = ".$commande->socidp." AND a.fk_action in (9,10)";
|
||||
$sql .= " AND a.fk_commande = ".$expedition->id;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
$i = 0;
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr $bc[$var]><td>".$langs->trans("Date")."</td><td>".$langs->trans("Action")."</td></tr>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td>".strftime("%d %B %Y",$objp->da)."</td>\n";
|
||||
print '<td>'.stripslashes($objp->note).'</td>';
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
if ($action == 'presend')
|
||||
{
|
||||
$replytoname = $user->fullname;
|
||||
$from_name = $replytoname;
|
||||
|
||||
$replytomail = $user->email;
|
||||
$from_mail = $replytomail;
|
||||
|
||||
print "<form method=\"post\" action=\"fiche.php?id=$expedition->id&action=send\">\n";
|
||||
print '<input type="hidden" name="replytoname" value="'.$replytoname.'">';
|
||||
print '<input type="hidden" name="replytomail" value="'.$replytomail.'">';
|
||||
|
||||
print "<p><b>Envoyer la commande par mail</b>";
|
||||
print "<table cellspacing=0 border=1 cellpadding=3>";
|
||||
print '<tr><td>Destinataire</td><td colspan="5">';
|
||||
|
||||
$form = new Form($db);
|
||||
$form->select_array("destinataire",$soc->contact_email_array());
|
||||
|
||||
print "</td><td><input size=\"30\" name=\"sendto\" value=\"$commande->email\"></td></tr>";
|
||||
print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>";
|
||||
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td>";
|
||||
print "<td>$replytomail</td></tr></table>";
|
||||
|
||||
print "<input type=\"submit\" value=\"Envoyer\"></form>";
|
||||
}
|
||||
|
||||
// Rien a droite
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
}
|
||||
|
||||
@ -87,6 +87,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$outputlangs->load("bills");
|
||||
$outputlangs->load("propal");
|
||||
$outputlangs->load("products");
|
||||
$outputlangs->load("sendings");
|
||||
|
||||
$outputlangs->setPhpLang();
|
||||
|
||||
@ -171,7 +172,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
//Generation du tableau
|
||||
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
|
||||
//Recuperation des produits de la commande.
|
||||
$this->expe->commande->fetch_lignes();
|
||||
$this->expe->commande->fetch_lignes(1);
|
||||
$Produits = $this->expe->commande->lignes;
|
||||
$nblignes = sizeof($Produits);
|
||||
for ($i = 0 ; $i < $nblignes ; $i++){
|
||||
@ -188,7 +189,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
//Insertion du libelle
|
||||
$pdf->SetFont('Arial','', 7);
|
||||
$pdf->SetXY (50, $curY );
|
||||
$pdf->MultiCell(130, 5, stripslashes($Prod->libelle), 0, 'L', 0);
|
||||
$pdf->MultiCell(130, 5, $Prod->libelle, 0, 'L', 0);
|
||||
//Insertion de la quantite
|
||||
$pdf->SetFont('Arial','', 7);
|
||||
$pdf->SetXY (180, $curY );
|
||||
@ -319,7 +320,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$pdf->SetXY(60,7);
|
||||
$pdf->SetFont('Arial','B',14);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(0, 8, "BON DE LIVRAISON", '' , 'L');
|
||||
$pdf->MultiCell(0, 8, $langs->trans("SendingSheet"), '' , 'L');
|
||||
//Num Expedition
|
||||
$Yoff = $Yoff+7;
|
||||
$Xoff = 115;
|
||||
@ -327,10 +328,10 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$pdf->SetXY($Xoff,$Yoff);
|
||||
$pdf->SetFont('Arial','',8);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(0, 8, $langs->trans("Ref: ").$exp->ref, '' , 'L');
|
||||
$pdf->MultiCell(0, 8, $langs->trans("RefSending").': '.$exp->ref, '' , 'L');
|
||||
//$this->Code39($Xoff+43, $Yoff+1, $this->expe->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
|
||||
//Num Commande
|
||||
$Yoff = $Yoff+10;
|
||||
$Yoff = $Yoff+4;
|
||||
// $pdf->rect($Xoff, $Yoff, 85, 8);
|
||||
$pdf->SetXY($Xoff,$Yoff);
|
||||
$pdf->SetFont('Arial','',8);
|
||||
|
||||
@ -56,7 +56,8 @@ OrdersStatistics=Orders' statistics
|
||||
NumberOfOrdersByMonth=Number of orders by month
|
||||
ListOfOrders=List of orders
|
||||
CloseOrder=Close order
|
||||
ConfirmCloseOrder=Are you sure you want to close this order ?
|
||||
ConfirmCloseOrder=Are you sure you want to close this order ? Once an order is closed, it can only be billed.
|
||||
ConfirmCloseOrderIfSending=Are you sure you want to close this order ? You must close an order only when all shipping are done.
|
||||
ConfirmDeleteOrder=Are you sure you want to delete this order ?
|
||||
ConfirmValidateOrder=Are you sure you want to validate this order ?
|
||||
ConfirmCancelOrder=Are you sure you want to cancel this order ?
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# Dolibarr language file - en_US - sendings
|
||||
RefSending=Ref. sending
|
||||
Sending=Sending
|
||||
Sendings=Sendings
|
||||
SendingsArea=Sendings area
|
||||
@ -18,5 +19,11 @@ QtyShipped=Qty shipped
|
||||
QtyReceived=Qty received
|
||||
QtyToShip=Qty to ship
|
||||
KeepToShip=Keep to ship
|
||||
OtherSendingsForSameOrder=Other sendings already shipped
|
||||
SendingsToValidate=Sending to validate
|
||||
OtherSendingsForSameOrder=Other sendings for this order
|
||||
SendingsForSameOrder=Sendings for this order
|
||||
SendingsToValidate=Sending to validate
|
||||
StatusSendingDraft=Draft
|
||||
StatusSendingValidated=Validated (products to ship or already received)
|
||||
StatusSendingDraftShort=Draft
|
||||
StatusSendingValidatedShort=Validated
|
||||
SendingSheet=Sending sheet
|
||||
@ -56,7 +56,8 @@ OrdersStatistics=Statistiques des commandes
|
||||
NumberOfOrdersByMonth=Nombre de commandes par mois
|
||||
ListOfOrders=Liste des commandes
|
||||
CloseOrder=Cloturer commande
|
||||
ConfirmCloseOrder=Êtes-vous sur de vouloir cloturer cette commande ?
|
||||
ConfirmCloseOrder=Êtes-vous sur de vouloir cloturer cette commande ? Une fois une commande cloturée, elle doit être facturée.
|
||||
ConfirmCloseOrderIfSending=Êtes-vous sur de vouloir cloturer cette commande ? Vous ne devez cloturer une commande qu'une fois les produits expédiés.
|
||||
ConfirmDeleteOrder=Êtes-vous sur de vouloir effacer cette commande ?
|
||||
ConfirmValidateOrder=Êtes-vous sur de vouloir valider cette commande ?
|
||||
ConfirmCancelOrder=Êtes-vous sur de vouloir annuler cette commande ?
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# Dolibarr language file - fr_FR - sendings
|
||||
RefSending=Réf. expédition
|
||||
Sending=Expédition
|
||||
Sendings=Expéditions
|
||||
SendingsArea=Espace expéditions
|
||||
@ -18,5 +19,11 @@ QtyShipped=Qt
|
||||
QtyToShip=Qté à expédier
|
||||
QtyReceived=Qté reçue
|
||||
KeepToShip=Reste à expédier
|
||||
OtherSendingsForSameOrder=Autres expéditions déjà envoyés
|
||||
SendingsToValidate=Expéditions à valider
|
||||
OtherSendingsForSameOrder=Autres expéditions pour cette commande
|
||||
SendingsForSameOrder=Expéditions pour cette commandes
|
||||
SendingsToValidate=Expéditions à valider
|
||||
StatusSendingDraft=Brouillon
|
||||
StatusSendingValidated=Validée (produits à envoyer ou reçus)
|
||||
StatusSendingDraftShort=Brouillon
|
||||
StatusSendingValidatedShort=Validée
|
||||
SendingSheet=Bon d'expédition
|
||||
@ -49,7 +49,7 @@ function commande_prepare_head($commande)
|
||||
if (($conf->expedition->enabled || $conf->livraison->enabled) && $user->rights->expedition->lire)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("SendingCard");
|
||||
$head[$h][1] = $langs->trans("Sendings");
|
||||
$head[$h][2] = 'shipping';
|
||||
$h++;
|
||||
}
|
||||
@ -58,7 +58,7 @@ function commande_prepare_head($commande)
|
||||
if ($conf->facture->enabled)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
|
||||
$head[$h][1] = $langs->trans("ComptaCard");
|
||||
$head[$h][1] = $langs->trans("Compta");
|
||||
$head[$h][2] = 'accountancy';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -628,101 +628,11 @@ else
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Commandes associées
|
||||
*
|
||||
*/
|
||||
$file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf";
|
||||
$relativepath = $commande->ref . "/" . $commande->ref . ".pdf";
|
||||
|
||||
$var=true;
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
print '<br>';
|
||||
print_titre("Orders");
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
print "<tr $bc[$true]><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>\n";
|
||||
}
|
||||
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
|
||||
print_titre("Actions");
|
||||
/*
|
||||
* Liste des actions
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql .= " WHERE a.fk_soc = ".$commande->socidp." AND a.fk_action in (9,10)";
|
||||
$sql .= " AND a.fk_commande = ".$livraison->id;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
$i = 0;
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr $bc[$var]><td>".$langs->trans("Date")."</td><td>".$langs->trans("Action")."</td></tr>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td>".strftime("%d %B %Y",$objp->da)."</td>\n";
|
||||
print '<td>'.stripslashes($objp->note).'</td>';
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
if ($action == 'presend')
|
||||
{
|
||||
$replytoname = $user->fullname;
|
||||
$from_name = $replytoname;
|
||||
|
||||
$replytomail = $user->email;
|
||||
$from_mail = $replytomail;
|
||||
|
||||
print "<form method=\"post\" action=\"fiche.php?id=$livraison->id&action=send\">\n";
|
||||
print '<input type="hidden" name="replytoname" value="'.$replytoname.'">';
|
||||
print '<input type="hidden" name="replytomail" value="'.$replytomail.'">';
|
||||
|
||||
print "<p><b>Envoyer le bon de livraison par mail</b>";
|
||||
print "<table cellspacing=0 border=1 cellpadding=3>";
|
||||
print '<tr><td>Destinataire</td><td colspan="5">';
|
||||
|
||||
$form = new Form($db);
|
||||
$form->select_array("destinataire",$soc->contact_email_array());
|
||||
|
||||
print "</td><td><input size=\"30\" name=\"sendto\" value=\"$commande->email\"></td></tr>";
|
||||
print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>";
|
||||
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td>";
|
||||
print "<td>$replytomail</td></tr></table>";
|
||||
|
||||
print "<input type=\"submit\" value=\"Envoyer\"></form>";
|
||||
}
|
||||
|
||||
// Rien à droite
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user