Fix: On exclut les expeditions brouillons dans calcul des epxeditions livres

Fix: Lien invalides
This commit is contained in:
Laurent Destailleur 2006-01-14 13:45:04 +00:00
parent 362b6099d3
commit 709e8944b7
2 changed files with 430 additions and 415 deletions

View File

@ -30,16 +30,16 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
$user->getrights('commande');
$user->getrights('expedition');
if (!$user->rights->commande->lire)
accessforbidden();
accessforbidden();
require_once(DOL_DOCUMENT_ROOT."/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
// Sécurité accés client
if ($user->societe_id > 0)
@ -60,6 +60,9 @@ if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == 'yes')
}
$html = new Form($db);
/* *************************************************************************** */
/* */
/* Mode vue et edition */
@ -68,15 +71,13 @@ if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == 'yes')
llxHeader('',$langs->trans("OrderCard"));
$html = new Form($db);
if ($_GET["id"] > 0)
{
$commande = New Commande($db);
if ( $commande->fetch($_GET["id"]) > 0)
{
$commande->livraison_array();
$commande->livraison_array(1);
$soc = new Societe($db);
$soc->fetch($commande->soc_id);
@ -124,51 +125,51 @@ if ($_GET["id"] > 0)
print "<br />";
}
// Onglet expedition
// Onglet commande
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="15%">'.$langs->trans('Ref').'</td>';
print '<td colspan="2">'.$commande->ref.'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
if ($commande->source == 0)
{
// Si source = propal
$propal = new Propal($db);
$propal->fetch($commande->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
}
print '</td></tr>';
// Société
print '<tr><td>'.$langs->trans('Customer').'</td>';
print '<td colspan="3">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
print '</tr>';
$nbrow=3;
// Ref commande client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCdeClient').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td><td colspan="2">';
print $commande->ref_client;
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('Note').' :<br>';
print nl2br($commande->note);
print '</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$commande->statuts[$commande->statut].'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'%A %d %B %Y').'</td>';
print '</tr>';
// Ref
print '<tr><td width="15%">'.$langs->trans('Ref').'</td>';
print '<td colspan="2">'.$commande->ref.'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
if ($commande->source == 0)
{
// Si source = propal
$propal = new Propal($db);
$propal->fetch($commande->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
}
print '</td></tr>';
// Société
print '<tr><td>'.$langs->trans('Customer').'</td>';
print '<td colspan="3">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
print '</tr>';
$nbrow=3;
// Ref commande client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCdeClient').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td><td colspan="2">';
print $commande->ref_client;
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('Note').' :<br>';
print nl2br($commande->note);
print '</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$commande->statuts[$commande->statut].'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'%A %d %B %Y').'</td>';
print '</tr>';
print '</table>';
@ -206,7 +207,7 @@ if ($_GET["id"] > 0)
$reste_a_livrer = array();
while ($i < $num)
{
$objp = $db->fetch_object();
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
@ -373,25 +374,29 @@ if ($_GET["id"] > 0)
/*
* Déjà livré
*/
$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";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
$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";
$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";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
$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);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$i = 0;
if ($num)
{
print '<br><table class="liste" width="100%">';
print '<br>';
print_titre($langs->trans("OtherSendingsForSameOrder"));
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>';
print '<td align="center">Quan. livrée</td>';
@ -411,7 +416,7 @@ if ($_GET["id"] > 0)
$product->fetch($objp->fk_product);
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->product_id.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
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 nl2br($objp->description);
print '</td>';
}

View File

@ -37,6 +37,7 @@ require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
$langs->load("bills");
$user->getrights('expedition');
if (!$user->rights->expedition->lire)
accessforbidden();
@ -295,7 +296,7 @@ if ($_GET["action"] == 'create')
*
*/
print '<tr><td align="center" colspan="4"><br><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
print '<tr><td align="center" colspan="4"><br><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print "</table>";
print '</form>';
}
@ -311,381 +312,390 @@ else
/* */
/* *************************************************************************** */
{
if ($_GET["id"] > 0)
if ($_GET["id"] > 0)
{
$expedition = New Expedition($db);
$result = $expedition->fetch($_GET["id"]);
if ( $expedition->id > 0)
{
$author = new User($db);
$author->id = $expedition->user_author_id;
$author->fetch();
llxHeader('','Fiche expedition','ch-expedition.html',$form_search,$author);
$commande = New Commande($db);
$commande->fetch($expedition->commande_id);
$soc = new Societe($db);
$soc->fetch($commande->soc_id);
$h=0;
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id;
$head[$h][1] = $langs->trans("SendingCard");
$hselected = $h;
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Sending")." : ".$expedition->ref);
/*
* Confirmation de la suppression
*
*/
if ($_GET["action"] == 'delete')
{
$html->form_confirm("fiche.php?id=$expedition->id","Supprimer l'expedition","Etes-vous sûr de vouloir supprimer cette expedition ?","confirm_delete");
print '<br>';
}
/*
* Confirmation de la validation
*
*/
if ($_GET["action"] == 'valid')
{
$html->form_confirm("fiche.php?id=$expedition->id","Valider l'expédition","Etes-vous sûr de vouloir valider cette expédition ?","confirm_valid");
print '<br>';
}
/*
* Confirmation de l'annulation
*
*/
if ($_GET["action"] == 'annuler')
{
$html->form_confirm("fiche.php?id=$expedition->id",$langs->trans("Cancel"),"Etes-vous sûr de vouloir annuler cette commande ?","confirm_cancel");
print '<br>';
}
/*
* Commande
*/
if ($commande->brouillon == 1 && $user->rights->commande->creer)
{
print '<form action="fiche.php?id='.$expedition->id.'" method="post">';
print '<input type="hidden" name="action" value="setremise">';
}
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
print '<td width="30%">';
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
print '<td width="20%">'.$langs->trans("Author").'</td><td width="30%">'.$author->fullname.'</td>';
print "</tr>";
print '<tr><td>'.$langs->trans("Order").'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref."</a></td>\n";
print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td>".strftime("%A %d %B %Y",$expedition->date)."</td>\n";
$entrepot = new Entrepot($db);
$entrepot->fetch($expedition->entrepot_id);
print '<td width="20%">'.$langs->trans("Warehouse").'</td><td><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td></tr>';
print "</table>\n";
/*
* Lignes
*
*/
echo '<br><table class="noborder" width="100%">';
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande";
$sql .= " , ed.qty as qty_livre";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed";
$sql .= " WHERE ed.fk_expedition = $expedition->id AND cd.rowid = ed.fk_commande_ligne ";
$resql = $db->query($sql);
if ($resql)
{
$num_prod = $db->num_rows($resql);
$i = 0;
print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Products").'</td>';
print '<td align="center">Quan. commandée</td>';
print '<td align="center">Quan. livrée</td>';
print "</tr>\n";
$var=true;
while ($i < $num_prod)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
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='.$ligne->product_id.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
if ($objp->description) print nl2br($objp->description);
print '</td>';
}
else
{
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
}
print '<td align="center">'.$objp->qty_commande.'</td>';
print '<td align="center">'.$objp->qty_livre.'</td>';
print "</tr>";
$i++;
$var=!$var;
}
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print "</table>\n";
print "\n</div>\n";
/*
*
*/
if ($user->societe_id == 0)
{
print '<div class="tabsAction">';
if ($expedition->statut == 0 && $user->rights->expedition->valider && $num_prod > 0)
{
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
}
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&amp;action=pdf">'.$langs->trans('BuildPDF').'</a>';
if ($expedition->brouillon && $user->rights->expedition->supprimer)
{
print '<a class="butActionDelete" href="fiche.php?id='.$expedition->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
print '</div>';
}
/*
* Documents générés
*/
$filename=sanitize_string($expedition->id);
$filedir=$conf->expedition->dir_output . "/" .get_exdir($expedition->id);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$expedition->id;
//$genallowed=$user->rights->expedition->creer;
//$delallowed=$user->rights->expedition->supprimer;
$genallowed=0;
$delallowed=0;
$var=true;
print "<br>\n";
$html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
/*
* Déjà livré
*/
$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";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
$sql .= " WHERE cd.fk_commande = $expedition->commande_id";
$sql .= " AND e.rowid <> $expedition->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)
$expedition = New Expedition($db);
$result = $expedition->fetch($_GET["id"]);
if ( $expedition->id > 0)
{
$num = $db->num_rows($resql);
$i = 0;
if ($num)
$author = new User($db);
$author->id = $expedition->user_author_id;
$author->fetch();
llxHeader('','Fiche expedition','ch-expedition.html',$form_search,$author);
$commande = New Commande($db);
$commande->fetch($expedition->commande_id);
$soc = new Societe($db);
$soc->fetch($commande->soc_id);
$h=0;
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id;
$head[$h][1] = $langs->trans("SendingCard");
$hselected = $h;
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Sending"));
/*
* Confirmation de la suppression
*
*/
if ($_GET["action"] == 'delete')
{
$html->form_confirm("fiche.php?id=$expedition->id","Supprimer l'expedition","Etes-vous sûr de vouloir supprimer cette expedition ?","confirm_delete");
print '<br>';
print_titre($langs->trans("OtherSendingsForSameOrder"));
print '<table class="liste" width="100%">';
}
/*
* Confirmation de la validation
*
*/
if ($_GET["action"] == 'valid')
{
$html->form_confirm("fiche.php?id=$expedition->id","Valider l'expédition","Etes-vous sûr de vouloir valider cette expédition ?","confirm_valid");
print '<br>';
}
/*
* Confirmation de l'annulation
*
*/
if ($_GET["action"] == 'annuler')
{
$html->form_confirm("fiche.php?id=$expedition->id",$langs->trans("Cancel"),"Etes-vous sûr de vouloir annuler cette commande ?","confirm_cancel");
print '<br>';
}
/*
* Commande
*/
if ($commande->brouillon == 1 && $user->rights->commande->creer)
{
print '<form action="fiche.php?id='.$expedition->id.'" method="post">';
print '<input type="hidden" name="action" value="setremise">';
}
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">'.$expedition->ref.'</td></tr>';
// Client
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
print '<td width="30%">';
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
// Auteur
print '<td width="20%">'.$langs->trans("Author").'</td><td width="30%">'.$author->fullname.'</td>';
print "</tr>";
// Commande liée
print '<tr><td>'.$langs->trans("Order").'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref."</a></td>\n";
print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
// Date
print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td>".strftime("%A %d %B %Y",$expedition->date)."</td>\n";
// Entrepot
$entrepot = new Entrepot($db);
$entrepot->fetch($expedition->entrepot_id);
print '<td width="20%">'.$langs->trans("Warehouse").'</td><td><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td></tr>';
print "</table>\n";
/*
* Lignes produits
*/
echo '<br><table class="noborder" width="100%">';
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande";
$sql .= " , ed.qty as qty_livre";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed";
$sql .= " WHERE ed.fk_expedition = $expedition->id AND cd.rowid = ed.fk_commande_ligne ";
$resql = $db->query($sql);
if ($resql)
{
$num_prod = $db->num_rows($resql);
$i = 0;
print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>';
print '<td width="54%">'.$langs->trans("Products").'</td>';
print '<td align="center">Quan. commandée</td>';
print '<td align="center">Quan. livrée</td>';
print '<td align="center">'.$langs->trans("Sending").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print "</tr>\n";
$var=True;
while ($i < $num)
$var=true;
while ($i < $num_prod)
{
$var=!$var;
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
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='.$ligne->product_id.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
if ($objp->description) print nl2br($objp->description);
print '</td>';
$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 nl2br($objp->description);
print '</td>';
}
else
{
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
}
print '<td align="center">'.$objp->qty_commande.'</td>';
print '<td align="center">'.$objp->qty_livre.'</td>';
print '<td align="center"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>';
print '<td align="center">'.dolibarr_print_date($objp->date_expedition).'</td>';
print "</tr>";
$i++;
$var=!$var;
}
print '</table>';
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print "</table>\n";
print "\n</div>\n";
/*
* Boutons actions
*/
if ($user->societe_id == 0)
{
print '<div class="tabsAction">';
if ($expedition->statut == 0 && $user->rights->expedition->valider && $num_prod > 0)
{
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
}
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&amp;action=pdf">'.$langs->trans('BuildPDF').'</a>';
if ($expedition->brouillon && $user->rights->expedition->supprimer)
{
print '<a class="butActionDelete" href="fiche.php?id='.$expedition->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
print '</div>';
}
/*
* Documents générés
*/
$filename=sanitize_string($expedition->id);
$filedir=$conf->expedition->dir_output . "/" .get_exdir($expedition->id);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$expedition->id;
//$genallowed=$user->rights->expedition->creer;
//$delallowed=$user->rights->expedition->supprimer;
$genallowed=0;
$delallowed=0;
$var=true;
print "<br>\n";
$html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
/*
* Déjà livre
*/
$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";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
$sql .= " WHERE cd.fk_commande = ".$expedition->commande_id;
$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);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
if ($num)
{
print '<br>';
print_titre($langs->trans("OtherSendingsForSameOrder"));
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>';
print '<td align="center">Quan. livrée</td>';
print '<td align="center">'.$langs->trans("Sending").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print "</tr>\n";
$var=True;
while ($i < $num)
{
$var=!$var;
$objp = $db->fetch_object($resql);
print "<tr $bc[$var]>";
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 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"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>';
print '<td align="center">'.dolibarr_print_date($objp->date_expedition).'</td>';
$i++;
}
print '</table>';
}
$db->free($resql);
}
else {
dolibarr_print_error($db);
}
/*
* Documents générés
*
*/
$file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf";
$relativepath = $commande->ref . "/" . $commande->ref . ".pdf";
$var=true;
if (file_exists($file))
{
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
print_titre("Documents");
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 = $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);
}
/*
*
*
*/
print "</td></tr></table>";
}
/*
*
*
*/
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&amp;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>";
}
$db->free($resql);
}
else {
dolibarr_print_error($db);
}
/*
* Documents générés
*
*/
$file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf";
$relativepath = $commande->ref . "/" . $commande->ref . ".pdf";
$var=true;
if (file_exists($file))
{
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
print_titre("Documents");
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 = $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);
}
/*
*
*
*/
print "</td></tr></table>";
}
/*
*
*
*/
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&amp;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>";
}
}
else
{
/* Expedition non trouvée */
llxHeader('','Fiche expedition','ch-expedition.html',$form_search);
print "Expedition inexistante ou accés refusé";
}
else
{
/* Expedition non trouvée */
llxHeader('','Fiche expedition','ch-expedition.html',$form_search);
print "Expedition inexistante ou accés refusé";
}
}
else
else
{
/* Expedition non trouvée */
llxHeader('','Fiche expedition','ch-expedition.html',$form_search);
print "Expedition inexistante ou accés refusé";
/* Expedition non trouvée */
llxHeader('','Fiche expedition','ch-expedition.html',$form_search);
print "Expedition inexistante ou accés refusé";
}
}