diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index ae73691a5d5..cadb6d85e57 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2003-2005 Rodolphe Quiedeville * Copyright (C) 2005 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -21,17 +21,16 @@ * */ -/** - \file htdocs/expedition/fiche.php - \ingroup expedition - \brief Fiche descriptive d'une expedition - \version $Revision$ +/*! + \file htdocs/expedition/fiche.php + \ingroup expedition + \brief Fiche descriptive d'une expedition + \version $Revision$ */ require("./pre.inc.php"); -$user->getrights('commande'); -$user->getrights('expedition'); + if (!$user->rights->expedition->lire) accessforbidden(); @@ -113,7 +112,6 @@ $html = new Form($db); * Mode creation * * - * ************************************************************************/ if ($_POST["action"] == 'create') { @@ -175,8 +173,11 @@ if ($_POST["action"] == 'create') $lignes = $commande->fetch_lignes(1); + /* Lecture des livraisons déjà effectuées */ + $commande->livraison_array(); + $num = sizeof($commande->lignes); - $i = 0; $total = 0; + $i = 0; if ($num) { @@ -277,10 +278,9 @@ else { $expedition = New Expedition($db); $result = $expedition->fetch($_GET["id"]); - - if ( $result > 0) + + if ( $expedition->id > 0) { - $author = new User($db); $author->id = $expedition->user_author_id; $author->fetch(); @@ -293,7 +293,13 @@ else $soc = new Societe($db); $soc->fetch($commande->soc_id); - print_titre($langs->trans("Sending").": ".$expedition->ref); + $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 @@ -330,7 +336,7 @@ else print ''; } - print ''; + print '
'; print ''; print ''; @@ -340,8 +346,9 @@ else print ""; print ""; - print '\n"; + print '\n"; print ''; + print ""; print "\n"; @@ -358,28 +365,29 @@ else */ echo '
Client'; print ''.$soc->nom.'
Commande'.$commande->ref."'.$commande->ref."  
Date".strftime("%A %d %B %Y",$expedition->date)."
'; - $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande, ed.qty as qty_livre"; + $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 "; - $result = $db->query($sql); - if ($result) + $resql = $db->query($sql); + + if ($resql) { - $num = $db->num_rows(); - $i = 0; $total = 0; + $num_prod = $db->num_rows($resql); + $i = 0; - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print "\n"; - } + + print ''; + print ''; + print ''; + print ''; + print "\n"; + $var=True; - while ($i < $num) + while ($i < $num_prod) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($resql); print ""; if ($objp->fk_product > 0) { @@ -392,194 +400,213 @@ else } print ''; print ''; - + print ""; $i++; $var=!$var; } - $db->free(); + $db->free($resql); } - else - { - dolibarr_print_error($db); - } - - - print "
'.$langs->trans("Description").'Quan. commandéeQuan. livrée
'.$langs->trans("Description").'Quan. commandéeQuan. livrée
'.$objp->qty_commande.''.$objp->qty_livre.'
"; - /* - * - */ - if ($user->societe_id == 0) - { - print '
'; - - if ($expedition->statut == 0 && $user->rights->expedition->valider) - { - print ''.$langs->trans("Validate").''; - } - - if ($expedition->brouillon && $user->rights->expedition->supprimer) - { - print ''.$langs->trans("Delete").''; - } - - - print "
"; - } - - /* - * Déjà livré - * - * - */ - $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande, ed.qty as qty_livre, e.ref"; - $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e"; - $sql .= " WHERE cd.fk_commande = $expedition->commande_id AND e.rowid <> $expedition->id AND cd.rowid = ed.fk_commande_ligne AND ed.fk_expedition = e.rowid"; - $sql .= " ORDER BY cd.fk_product"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows(); - $i = 0; $total = 0; + else + { + dolibarr_print_error($db); + } + + + print "\n\n"; + /* + * + */ + if ($user->societe_id == 0) + { + print '
'; - if ($num) - { - print '
'; - print ''; - print ''; - print ''; - print ''; - - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - print ""; - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print "\n"; - } - print ''; - print ''; - $i++; - } - - print '
'.$langs->trans("Description").'Quan. livréeExpédition
'; - print ''.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->qty_livre.''.$objp->ref.'
'; - } - } + if ($expedition->statut == 0 && $user->rights->expedition->valider && $num_prod > 0) + { + print ''.$langs->trans("Validate").''; + } + + if ($expedition->brouillon && $user->rights->expedition->supprimer) + { + print ''.$langs->trans("Delete").''; + } + + + print "
"; + } - - /* - * Documents générés - * - */ - $file = $conf->commande->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; - $relativepath = $commande->ref . "/" . $commande->ref . ".pdf"; + /* + * 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"; + $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"; - $var=true; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + if ($num) + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print "\n"; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + print ""; + if ($objp->fk_product > 0) + { + print ''; + } + else + { + print "\n"; + } + print ''; + print ''; + print ''; + $i++; + } + + print '
'.$langs->trans("Description").'Quan. livréeExpédition'.$langs->trans("Date").'
'; + print ''.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->qty_livre.''.$objp->ref.''.dolibarr_print_date($objp->date_expedition).'
'; + } + $db->free($resql); + } + + /* + * 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 ""; + print "\n"; + print ''; + print ""; + $i++; + } + print "
"; - print_titre("Documents"); - print ''; + if (file_exists($file)) + { + print "
"; + print_titre("Documents"); + print ''; - print ""; - print ''; - print ''; - print ''; - print ''; + print ""; + print ''; + print ''; + print ''; + print ''; - print "
".$langs->trans("Order")." PDF'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
".$langs->trans("Order")." PDF'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; - print '
'; - print_titre("Actions"); - /* - * Liste des actions - * - */ - $sql = "SELECT ".$db->pdate("a.datea")." as da, a.note"; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a WHERE a.fk_soc = $commande->socidp AND a.fk_action in (9,10) AND a.fk_commande = $expedition->id"; + print "
\n"; + print '
'; + 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"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows(); - if ($num) - { - $i = 0; $total = 0; - print ''; - print "\n"; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + print '
".$langs->trans("Date")."".$langs->trans("Action")."
'; + print "\n"; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print "\n"; - print ''; - print ""; - $i++; - } - print "
".$langs->trans("Date")."".$langs->trans("Action")."
".strftime("%d %B %Y",$objp->da)."'.stripslashes($objp->note).'
"; - } - } - else - { - dolibarr_print_error($db); - } + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print "
".strftime("%d %B %Y",$objp->da)."'.stripslashes($objp->note).'
"; + } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } - /* - * - * - */ - print ""; - } - /* - * - * - */ + /* + * + * + */ + print ""; + } + /* + * + * + */ - if ($action == 'presend') - { - $replytoname = $user->fullname; - $from_name = $replytoname; + if ($action == 'presend') + { + $replytoname = $user->fullname; + $from_name = $replytoname; - $replytomail = $user->email; - $from_mail = $replytomail; + $replytomail = $user->email; + $from_mail = $replytomail; - print "
id&action=send\">\n"; - print ''; - print ''; + print "id&action=send\">\n"; + print ''; + print ''; - print "

Envoyer la commande par mail"; - print ""; - print '"; + print ""; + print ""; + print "
Destinataire'; + print "

Envoyer la commande par mail"; + print ""; + print '"; - print ""; - print ""; - print "
Destinataire'; - $form = new Form($db); - $form->select_array("destinataire",$soc->contact_email_array()); + $form = new Form($db); + $form->select_array("destinataire",$soc->contact_email_array()); - print "email\">
Expéditeur$from_name$from_mail
Reply-to$replytoname$replytomail
"; + print "

email\">
Expéditeur$from_name$from_mail
Reply-to$replytoname$replytomail
"; - print "

"; - } - } - else - { - /* Commande non trouvée */ - print "Commande inexistante ou accés refusé"; - } + print ""; + } + } + 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é"; } }