Fix: A lot of fix in sending/receiving module
This commit is contained in:
parent
dd3d8084b8
commit
7050187012
@ -1089,23 +1089,29 @@ class Commande extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge tableau avec les expeditions par ligne
|
||||
* \param filtre_statut Filtre sur statut
|
||||
* \return int <0 if KO, Nb of records if OK
|
||||
* \brief Load array this->expeditions of nb of products sent by line in order
|
||||
* \param filtre_statut Filter on status
|
||||
* \return int <0 if KO, Nb of lines found if OK
|
||||
*/
|
||||
function loadExpeditions($filtre_statut=-1)
|
||||
{
|
||||
$num=0;
|
||||
$this->expeditions = array();
|
||||
|
||||
$sql = 'SELECT fk_product, sum(ed.qty)';
|
||||
$sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd';
|
||||
$sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_origin_line = cd.rowid AND cd.fk_commande = c.rowid';
|
||||
$sql.=' AND cd.fk_commande =' .$this->id;
|
||||
$sql = 'SELECT cd.rowid, cd.fk_product,';
|
||||
$sql.= ' sum(ed.qty) as qty';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
|
||||
if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'expedition as e,';
|
||||
$sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
|
||||
$sql.= ' WHERE';
|
||||
if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND';
|
||||
$sql.= ' ed.fk_origin_line = cd.rowid';
|
||||
$sql.= ' AND cd.fk_commande =' .$this->id;
|
||||
if ($filtre_statut >= 0) $sql.=' AND e.fk_statut = '.$filtre_statut;
|
||||
$sql .= ' GROUP BY fk_product ';
|
||||
|
||||
dolibarr_syslog("Commande::loadExpedition sql=".$sql,LOG_DEBUG);
|
||||
$sql.= ' GROUP BY cd.rowid, cd.fk_product';
|
||||
//print $sql;
|
||||
|
||||
dolibarr_syslog("Commande::loadExpeditions sql=".$sql,LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
@ -1113,8 +1119,8 @@ class Commande extends CommonObject
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row($result);
|
||||
$this->expeditions[$row[0]] = $row[1];
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->expeditions[$obj->rowid] = $obj->qty;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free();
|
||||
@ -1123,6 +1129,7 @@ class Commande extends CommonObject
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dolibarr_syslog("Commande::loadExpeditions ".$this->error,LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -21,10 +21,10 @@
|
||||
// Code identique a /expedition/fiche.php
|
||||
|
||||
/**
|
||||
\file htdocs/expedition/commande.php
|
||||
\ingroup expedition
|
||||
\version $Id$
|
||||
*/
|
||||
\file htdocs/expedition/commande.php
|
||||
\ingroup expedition
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||
@ -43,13 +43,13 @@ $langs->load('deliveries');
|
||||
$langs->load('stocks');
|
||||
|
||||
if (!$user->rights->commande->lire)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Chargement des permissions
|
||||
@ -60,9 +60,9 @@ $error = $user->load_entrepots();
|
||||
*/
|
||||
if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == 'yes')
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET["id"]);
|
||||
$result = $commande->cloture($user);
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET["id"]);
|
||||
$result = $commande->cloture($user);
|
||||
}
|
||||
|
||||
// Positionne ref commande client
|
||||
@ -125,137 +125,137 @@ llxHeader('',$langs->trans("OrderCard"));
|
||||
|
||||
if ($_GET["id"] > 0)
|
||||
{
|
||||
$commande = New Commande($db);
|
||||
if ( $commande->fetch($_GET["id"]) > 0)
|
||||
{
|
||||
$commande->loadExpeditions(1);
|
||||
$commande = new Commande($db);
|
||||
if ( $commande->fetch($_GET["id"]) > 0)
|
||||
{
|
||||
$commande->loadExpeditions(1);
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socid);
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($commande->socid);
|
||||
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
$author = new User($db);
|
||||
$author->id = $commande->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
$head = commande_prepare_head($commande);
|
||||
dolibarr_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"));
|
||||
dolibarr_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"));
|
||||
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'cloture')
|
||||
{
|
||||
$html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture");
|
||||
print "<br />";
|
||||
}
|
||||
|
||||
// Onglet commande
|
||||
$nbrow=8;
|
||||
if ($conf->projet->enabled) $nbrow++;
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
|
||||
print '<td colspan="3">'.$commande->ref.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Ref commande client
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=RefCustomerOrder&id='.$commande->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder')
|
||||
{
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="set_ref_client">';
|
||||
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$commande->ref_client.'">';
|
||||
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $commande->ref_client;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Société
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans('Date').'</td>';
|
||||
print '<td colspan="2">'.dolibarr_print_date($commande->date,'daytext').'</td>';
|
||||
print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource();
|
||||
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>';
|
||||
print '</tr>';
|
||||
|
||||
// Date de livraison
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryDate');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'editdate_livraison')
|
||||
{
|
||||
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setdate_livraison">';
|
||||
$html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison");
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print dolibarr_print_date($commande->date_livraison,'daytext');
|
||||
}
|
||||
print '</td>';
|
||||
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
|
||||
print nl2br($commande->note_public);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Adresse de livraison
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
|
||||
if ($_GET['action'] == 'editdelivery_adress')
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Conditions et modes de réglement
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'cloture')
|
||||
{
|
||||
$html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture");
|
||||
print "<br />";
|
||||
}
|
||||
|
||||
// Onglet commande
|
||||
$nbrow=8;
|
||||
if ($conf->projet->enabled) $nbrow++;
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
|
||||
print '<td colspan="3">'.$commande->ref.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Ref commande client
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=RefCustomerOrder&id='.$commande->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder')
|
||||
{
|
||||
print '<form action="fiche.php?id='.$id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="set_ref_client">';
|
||||
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$commande->ref_client.'">';
|
||||
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $commande->ref_client;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Société
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans('Date').'</td>';
|
||||
print '<td colspan="2">'.dolibarr_print_date($commande->date,'daytext').'</td>';
|
||||
print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource();
|
||||
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>';
|
||||
print '</tr>';
|
||||
|
||||
// Date de livraison
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryDate');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'editdate_livraison')
|
||||
{
|
||||
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setdate_livraison">';
|
||||
$html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison");
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print dolibarr_print_date($commande->date_livraison,'daytext');
|
||||
}
|
||||
print '</td>';
|
||||
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
|
||||
print nl2br($commande->note_public);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Adresse de livraison
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryAddress');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&socid='.$commande->socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
|
||||
if ($_GET['action'] == 'editdelivery_adress')
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Conditions et modes de réglement
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentConditionsShort');
|
||||
print '</td>';
|
||||
|
||||
|
||||
if ($_GET['action'] != 'editconditions' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
@ -284,32 +284,32 @@ if ($_GET["id"] > 0)
|
||||
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Projet
|
||||
if ($conf->projet->enabled)
|
||||
{
|
||||
$langs->load('projects');
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Project');
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'classer' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&id='.$commande->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Project');
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'classer' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&id='.$commande->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'classer')
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Lignes de 3 colonnes
|
||||
|
||||
// Total HT
|
||||
// Total HT
|
||||
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
@ -317,7 +317,7 @@ if ($_GET["id"] > 0)
|
||||
// Total TVA
|
||||
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
|
||||
// Total TTC
|
||||
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
@ -330,196 +330,197 @@ if ($_GET["id"] > 0)
|
||||
print '</table><br>';
|
||||
|
||||
|
||||
/**
|
||||
* Lignes de commandes avec quantité livrées et reste à livrer
|
||||
* Les quantités livrées sont stockées dans $commande->expeditions[fk_product]
|
||||
*/
|
||||
print '<table class="liste" width="100%">';
|
||||
/**
|
||||
* Lignes de commandes avec quantité livrées et reste à livrer
|
||||
* Les quantités livrées sont stockées dans $commande->expeditions[fk_product]
|
||||
*/
|
||||
print '<table class="liste" width="100%">';
|
||||
|
||||
$sql = "SELECT cd.fk_product, cd.description, cd.price, cd.qty, cd.rowid, cd.tva_tx, cd.subprice";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd ";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||
$sql.= " WHERE cd.fk_commande = ".$commande->id;
|
||||
$sql.= " AND p.fk_product_type <> 1";
|
||||
$sql.= " ORDER BY cd.rowid";
|
||||
$sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.price, cd.qty, cd.tva_tx, cd.subprice";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||
$sql.= " WHERE cd.fk_commande = ".$commande->id;
|
||||
// $sql.= " AND p.fk_product_type <> 1"; Why this line ?
|
||||
$sql.= " ORDER BY cd.rowid";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
dolibarr_syslog("commande.php sql=".$sql, LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td align="center">'.$langs->trans("KeepToShip").'</td>';
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
print '<td align="center">'.$langs->trans("Stock").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
$var=true;
|
||||
$reste_a_livrer = array();
|
||||
while ($i < $num)
|
||||
{
|
||||
$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='.$objp->fk_product.'">';
|
||||
print img_object($langs->trans("Product"),"product").' '.$product->ref.'</a>';
|
||||
print $product->libelle?' - '.$product->libelle:'';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".nl2br($objp->description)."</td>\n";
|
||||
}
|
||||
|
||||
print '<td align="center">'.$objp->qty.'</td>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td align="center">'.$langs->trans("KeepToShip").'</td>';
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
print '<td align="center">'.$langs->trans("Stock").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
print '<td align="center">';
|
||||
$quantite_livree = $commande->expeditions[$objp->fk_product];
|
||||
print $quantite_livree;
|
||||
print '</td>';
|
||||
$var=true;
|
||||
$reste_a_livrer = array();
|
||||
while ($i < $num)
|
||||
{
|
||||
$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='.$objp->fk_product.'">';
|
||||
print img_object($langs->trans("Product"),"product").' '.$product->ref.'</a>';
|
||||
print $product->libelle?' - '.$product->libelle:'';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".nl2br($objp->description)."</td>\n";
|
||||
}
|
||||
|
||||
$reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree;
|
||||
$reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product];
|
||||
print '<td align="center">';
|
||||
print $reste_a_livrer[$objp->fk_product];
|
||||
print '</td>';
|
||||
print '<td align="center">'.$objp->qty.'</td>';
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
print '<td align="center">';
|
||||
print $product->stock_reel;
|
||||
if ($product->stock_reel < $reste_a_livrer[$objp->fk_product])
|
||||
{
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print "</tr>";
|
||||
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
if (! $num)
|
||||
{
|
||||
print '<tr '.$bc[false].'><td colspan="5">'.$langs->trans("NoArticleOfTypeProduct").'<br>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* Boutons Actions
|
||||
*/
|
||||
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Bouton expedier sans gestion des stocks
|
||||
if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&origin=commande&object_id='.$_GET["id"].'">'.$langs->trans("NewSending").'</a>';
|
||||
}
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
|
||||
// Bouton expedier avec gestion des stocks
|
||||
|
||||
print '<table width="100%"><tr><td width="100%" colspan="2" valign="top">';
|
||||
|
||||
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.'">';
|
||||
print '<input type="hidden" name="origin" value="commande">';
|
||||
print '<input type="hidden" name="object_id" value="'.$commande->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$entrepot = new Entrepot($db);
|
||||
$langs->load("stocks");
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td>';
|
||||
|
||||
if (sizeof($user->entrepots) === 1)
|
||||
{
|
||||
$uentrepot = array();
|
||||
$uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label'];
|
||||
$html->select_array("entrepot_id",$uentrepot);
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->select_array("entrepot_id",$entrepot->list_array());
|
||||
}
|
||||
|
||||
if (sizeof($entrepot->list_array()) <= 0)
|
||||
{
|
||||
print ' Aucun entrepôt définit, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">definissez en un</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
/*
|
||||
print '<tr><td width="20%">Mode d\'expédition</td>';
|
||||
print '<td>';
|
||||
$html->select_array("entrepot_id",$entrepot->list_array());
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
print '<tr><td align="center" colspan="2">';
|
||||
print '<input type="submit" class="button" named="save" value="'.$langs->trans("NewSending").'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
print "</form>\n";
|
||||
|
||||
$somethingshown=1;
|
||||
}
|
||||
|
||||
print "</td></tr></table>";
|
||||
print '<td align="center">';
|
||||
// Nb of sending products for this line of order
|
||||
$quantite_livree = $commande->expeditions[$objp->rowid];
|
||||
print $quantite_livree;
|
||||
print '</td>';
|
||||
|
||||
print '<br>';
|
||||
show_list_sending_receive('commande',$commande->id);
|
||||
|
||||
$reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree;
|
||||
$reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product];
|
||||
print '<td align="center">';
|
||||
print $reste_a_livrer[$objp->fk_product];
|
||||
print '</td>';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
print "Commande inexistante";
|
||||
}
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
print '<td align="center">';
|
||||
print $product->stock_reel;
|
||||
if ($product->stock_reel < $reste_a_livrer[$objp->fk_product])
|
||||
{
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print "</tr>";
|
||||
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
if (! $num)
|
||||
{
|
||||
print '<tr '.$bc[false].'><td colspan="5">'.$langs->trans("NoArticleOfTypeProduct").'<br>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* Boutons Actions
|
||||
*/
|
||||
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Bouton expedier sans gestion des stocks
|
||||
if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&origin=commande&object_id='.$_GET["id"].'">'.$langs->trans("NewSending").'</a>';
|
||||
}
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
|
||||
// Bouton expedier avec gestion des stocks
|
||||
|
||||
print '<table width="100%"><tr><td width="100%" colspan="2" valign="top">';
|
||||
|
||||
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.'">';
|
||||
print '<input type="hidden" name="origin" value="commande">';
|
||||
print '<input type="hidden" name="object_id" value="'.$commande->id.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$entrepot = new Entrepot($db);
|
||||
$langs->load("stocks");
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td>';
|
||||
|
||||
if (sizeof($user->entrepots) === 1)
|
||||
{
|
||||
$uentrepot = array();
|
||||
$uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label'];
|
||||
$html->select_array("entrepot_id",$uentrepot);
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->select_array("entrepot_id",$entrepot->list_array());
|
||||
}
|
||||
|
||||
if (sizeof($entrepot->list_array()) <= 0)
|
||||
{
|
||||
print ' Aucun entrepôt définit, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">definissez en un</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
/*
|
||||
print '<tr><td width="20%">Mode d\'expédition</td>';
|
||||
print '<td>';
|
||||
$html->select_array("entrepot_id",$entrepot->list_array());
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
print '<tr><td align="center" colspan="2">';
|
||||
print '<input type="submit" class="button" named="save" value="'.$langs->trans("NewSending").'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
print "</form>\n";
|
||||
|
||||
$somethingshown=1;
|
||||
}
|
||||
|
||||
print "</td></tr></table>";
|
||||
|
||||
print '<br>';
|
||||
show_list_sending_receive('commande',$commande->id);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
print "Commande inexistante";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -214,230 +214,229 @@ if ($_GET["action"] == 'create')
|
||||
$class = ucfirst($origin);
|
||||
|
||||
$object = new $class($db);
|
||||
$object->loadExpeditions();
|
||||
|
||||
if ( $object->fetch($origin_id))
|
||||
if ($object->fetch($origin_id))
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($object->socid);
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($object->socid);
|
||||
|
||||
$author = new User($db);
|
||||
$author->id = $object->user_author_id;
|
||||
$author->fetch();
|
||||
$author = new User($db);
|
||||
$author->id = $object->user_author_id;
|
||||
$author->fetch();
|
||||
|
||||
if ($conf->stock->enabled) $entrepot = new Entrepot($db);
|
||||
if ($conf->stock->enabled) $entrepot = new Entrepot($db);
|
||||
|
||||
/*
|
||||
* Document source
|
||||
*/
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="origin" value="'.$origin.'">';
|
||||
print '<input type="hidden" name="object_id" value="'.$object->id.'">';
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">';
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
print $langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("RefProposal").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/comm/fiche.php?propalid='.$object->id.'">'.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref;
|
||||
/*
|
||||
* Document source
|
||||
*/
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="origin" value="'.$origin.'">';
|
||||
print '<input type="hidden" name="object_id" value="'.$object->id.'">';
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
|
||||
}
|
||||
print '</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Ref client
|
||||
print '<tr><td>';
|
||||
print $langs->trans('RefCustomer').'</td><td colspan="3">';
|
||||
print $object->ref_client;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Tiers
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
||||
print '</tr>';
|
||||
// Ref
|
||||
print '<tr><td width="30%">';
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
print $langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("RefProposal").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/comm/fiche.php?propalid='.$object->id.'">'.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref;
|
||||
}
|
||||
print '</a></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Date
|
||||
print "<tr><td>".$langs->trans("Date")."</td>";
|
||||
print '<td colspan="3">'.dolibarr_print_date($object->date,"day")."</td></tr>\n";
|
||||
// Ref client
|
||||
print '<tr><td>';
|
||||
print $langs->trans('RefCustomer').'</td><td colspan="3">';
|
||||
print $object->ref_client;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Entrepot (si forcé)
|
||||
if ($conf->stock->enabled && $_GET["entrepot_id"])
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td colspan="3">';
|
||||
$ents = $entrepot->list_array();
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$_GET["entrepot_id"].'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].'</a>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
// Tiers
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($object->note && ! $user->societe_id)
|
||||
{
|
||||
print '<tr><td colspan="3">'.$langs->trans("NotePrivate").': '.nl2br($object->note)."</td></tr>";
|
||||
}
|
||||
// Date
|
||||
print "<tr><td>".$langs->trans("Date")."</td>";
|
||||
print '<td colspan="3">'.dolibarr_print_date($object->date,"day")."</td></tr>\n";
|
||||
|
||||
// Delivery method
|
||||
print "<tr><td>".$langs->trans("DeliveryMethod")."</td>";
|
||||
print '<td colspan="3">';
|
||||
// Entrepot (si forcé)
|
||||
if ($conf->stock->enabled && $_GET["entrepot_id"])
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td colspan="3">';
|
||||
$ents = $entrepot->list_array();
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$_GET["entrepot_id"].'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].'</a>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
$expe->fetch_delivery_methods();
|
||||
$html->select_array("expedition_method_id",$expe->meths);
|
||||
print "</td></tr>\n";
|
||||
// Tracking number
|
||||
print "<tr><td>".$langs->trans("TrackingNumber")."</td>";
|
||||
print '<td colspan="3">';
|
||||
print '<input name="tracking_number" size="20">';
|
||||
print "</td></tr>\n";
|
||||
print "</table>";
|
||||
if ($object->note && ! $user->societe_id)
|
||||
{
|
||||
print '<tr><td colspan="3">'.$langs->trans("NotePrivate").': '.nl2br($object->note)."</td></tr>";
|
||||
}
|
||||
|
||||
/*
|
||||
* Lignes de commandes
|
||||
*
|
||||
*/
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
// Delivery method
|
||||
print "<tr><td>".$langs->trans("DeliveryMethod")."</td>";
|
||||
print '<td colspan="3">';
|
||||
|
||||
//$lignes = $object->fetch_lines(1);
|
||||
$numAsked = sizeof($object->lignes);
|
||||
$expe->fetch_delivery_methods();
|
||||
$html->select_array("expedition_method_id",$expe->meths);
|
||||
print "</td></tr>\n";
|
||||
// Tracking number
|
||||
print "<tr><td>".$langs->trans("TrackingNumber")."</td>";
|
||||
print '<td colspan="3">';
|
||||
print '<input name="tracking_number" size="20">';
|
||||
print "</td></tr>\n";
|
||||
print "</table>";
|
||||
|
||||
/* Lecture des expeditions déjà effectuées */
|
||||
$object->loadExpeditions();
|
||||
/*
|
||||
* Lignes de commandes
|
||||
*
|
||||
*/
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
|
||||
if ($numAsked)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyToShip").'</td>';
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
print '<td align="right">'.$langs->trans("Stock").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="left">'.$langs->trans("Warehouse").'</td>';
|
||||
}
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
//$lignes = $object->fetch_lines(1);
|
||||
$numAsked = sizeof($object->lignes);
|
||||
|
||||
$var=true;
|
||||
$indiceAsked = 0;
|
||||
while ($indiceAsked < $numAsked)
|
||||
{
|
||||
$ligne = $object->lignes[$indiceAsked];
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">\n";
|
||||
if ($ligne->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($ligne->fk_product);
|
||||
/* Lecture des expeditions déjà effectuées */
|
||||
$object->loadExpeditions();
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
|
||||
if ($ligne->desc) print nl2br($ligne->desc);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{var_dump($ligne);
|
||||
print "<td>".nl2br($ligne->desc)."</td>\n";
|
||||
}
|
||||
|
||||
print '<td align="center">'.$ligne->qty.'</td>';
|
||||
|
||||
print '<td align="center">';
|
||||
$quantityDelivered = $object->expeditions[$ligne->fk_product];
|
||||
print $quantityDelivered;
|
||||
print '</td>';
|
||||
|
||||
$quantityAsked = $ligne->qty;
|
||||
$quantityToBeDelivered = $quantityAsked - $quantityDelivered;
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$defaultqty=0;
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
$stock = $product->stock_entrepot[$_GET["entrepot_id"]];
|
||||
$stock+=0; // Convertit en numérique
|
||||
$defaultqty=min($quantityToBeDelivered, $stock);
|
||||
if ($defaultqty < 0) $defaultqty=0;
|
||||
}
|
||||
if ($numAsked)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyToShip").'</td>';
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
print '<td align="right">'.$langs->trans("Stock").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="left">'.$langs->trans("Warehouse").'</td>';
|
||||
}
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
// Quantité à livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$defaultqty.'">';
|
||||
print '</td>';
|
||||
$var=true;
|
||||
$indiceAsked = 0;
|
||||
while ($indiceAsked < $numAsked)
|
||||
{
|
||||
$ligne = $object->lignes[$indiceAsked];
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">\n";
|
||||
if ($ligne->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($ligne->fk_product);
|
||||
|
||||
// Stock
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
print '<td align="right">'.$stock;
|
||||
if ($stock < $quantityToBeDelivered)
|
||||
{
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$array=array();
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
|
||||
if ($ligne->desc) print nl2br($ligne->desc);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{var_dump($ligne);
|
||||
print "<td>".nl2br($ligne->desc)."</td>\n";
|
||||
}
|
||||
|
||||
$sql = "SELECT e.rowid, e.label, ps.reel";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."entrepot as e";
|
||||
$sql.= " WHERE ps.fk_entrepot = e.rowid AND fk_product = '".$product->id."'";
|
||||
$result = $db->query($sql) ;
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i=0;
|
||||
if ($num > 0)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$array[$obj->rowid] = $obj->label.' ('.$obj->reel.')';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$db->error();
|
||||
return -1;
|
||||
}
|
||||
print '<td align="center">'.$ligne->qty.'</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
$html->select_array('entl'.$i,$array,'',1,0,0);
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Quantité à livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$indiceAsked.'" type="text" size="6" value="'.$quantityToBeDelivered.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$indiceAsked++;
|
||||
}
|
||||
print '<td align="center">';
|
||||
$quantityDelivered = $object->expeditions[$ligne->id];
|
||||
print $quantityDelivered;
|
||||
print '</td>';
|
||||
|
||||
$quantityAsked = $ligne->qty;
|
||||
$quantityToBeDelivered = $quantityAsked - $quantityDelivered;
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$defaultqty=0;
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
$stock = $product->stock_entrepot[$_GET["entrepot_id"]];
|
||||
$stock+=0; // Convertit en numérique
|
||||
$defaultqty=min($quantityToBeDelivered, $stock);
|
||||
if ($defaultqty < 0) $defaultqty=0;
|
||||
}
|
||||
|
||||
// Quantité à livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$defaultqty.'">';
|
||||
print '</td>';
|
||||
|
||||
// Stock
|
||||
if ($_GET["entrepot_id"])
|
||||
{
|
||||
print '<td align="right">'.$stock;
|
||||
if ($stock < $quantityToBeDelivered)
|
||||
{
|
||||
print ' '.img_warning($langs->trans("StockTooLow"));
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$array=array();
|
||||
|
||||
$sql = "SELECT e.rowid, e.label, ps.reel";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."entrepot as e";
|
||||
$sql.= " WHERE ps.fk_entrepot = e.rowid AND fk_product = '".$product->id."'";
|
||||
$result = $db->query($sql) ;
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i=0;
|
||||
if ($num > 0)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$array[$obj->rowid] = $obj->label.' ('.$obj->reel.')';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$db->error();
|
||||
return -1;
|
||||
}
|
||||
|
||||
print '<td align="left">';
|
||||
$html->select_array('entl'.$i,$array,'',1,0,0);
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Quantité à livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$indiceAsked.'" type="text" size="6" value="'.$quantityToBeDelivered.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$indiceAsked++;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
@ -449,7 +448,7 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -462,7 +461,7 @@ else
|
||||
{
|
||||
if ($_GET["id"] > 0)
|
||||
{
|
||||
$expedition = New Expedition($db);
|
||||
$expedition = new Expedition($db);
|
||||
$result = $expedition->fetch($_GET["id"]);
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -582,7 +581,7 @@ else
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="3">'.dolibarr_print_date($expedition->date,"day")."</td>\n";
|
||||
print '<td colspan="3">'.dolibarr_print_date($expedition->date,"daytext")."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
// Poids Total
|
||||
@ -715,7 +714,7 @@ else
|
||||
|
||||
|
||||
/*
|
||||
* Documents générés
|
||||
* Documents generated
|
||||
*/
|
||||
if ($conf->expedition_bon->enabled)
|
||||
{
|
||||
@ -740,8 +739,9 @@ else
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '<br>';
|
||||
show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
|
||||
|
||||
//show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
|
||||
show_list_sending_receive($expedition->origin,$expedition->origin_id);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -167,7 +167,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$pdf->SetFont('Arial','', 7);
|
||||
|
||||
//Insertion de l entete
|
||||
$this->_pagehead($pdf, $this->expe);
|
||||
$this->_pagehead($pdf, $this->expe, $outputlangs);
|
||||
|
||||
//Initialisation des coordonnées
|
||||
$tab_top = 53;
|
||||
@ -180,7 +180,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$curY = $pdf->GetY();
|
||||
$nexY = $pdf->GetY();
|
||||
//Generation du tableau
|
||||
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
|
||||
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
|
||||
//Recuperation des produits de la commande.
|
||||
$this->expe->commande->fetch_lines(1);
|
||||
$Produits = $this->expe->commande->lignes;
|
||||
@ -199,27 +199,32 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
//Insertion du libelle
|
||||
$pdf->SetFont('Arial','', 7);
|
||||
$pdf->SetXY (50, $curY );
|
||||
$pdf->MultiCell(130, 5, $Prod->libelle, 0, 'L', 0);
|
||||
//Insertion de la quantite
|
||||
$pdf->MultiCell(90, 5, $Prod->libelle, 0, 'L', 0);
|
||||
//Insertion de la quantite commandée
|
||||
$pdf->SetFont('Arial','', 7);
|
||||
$pdf->SetXY (180, $curY );
|
||||
$pdf->MultiCell(20, 5, $Produits[$i]->qty, 0, 'L', 0);
|
||||
$pdf->SetXY (140, $curY );
|
||||
$pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_asked, 0, 'C', 0);
|
||||
//Insertion de la quantite à envoyer
|
||||
$pdf->SetFont('Arial','', 7);
|
||||
$pdf->SetXY (170, $curY );
|
||||
$pdf->MultiCell(30, 5, $this->expe->lignes[$i]->qty_shipped, 0, 'C', 0);
|
||||
|
||||
//Generation de la page 2
|
||||
$curY += 4;
|
||||
$nexY = $curY;
|
||||
if ($nexY > ($tab_top+$tab_height-10) && $i < $nblignes - 1){
|
||||
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
|
||||
$this->_pagefoot($pdf);
|
||||
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
|
||||
$this->_pagefoot($pdf, $outputlangs);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$nexY = $iniY;
|
||||
$this->_pagehead($pdf, $this->expe);
|
||||
$this->_pagehead($pdf, $this->expe, $outputlangs);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetFont('Arial','', 7);
|
||||
}
|
||||
}
|
||||
//Insertion du pied de page
|
||||
$this->_pagefoot($pdf);
|
||||
$this->_pagefoot($pdf, $outputlangs);
|
||||
|
||||
$pdf->AliasNbPages();
|
||||
|
||||
@ -252,7 +257,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
//********************************
|
||||
// Generation du tableau
|
||||
//********************************
|
||||
function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
|
||||
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@ -267,18 +272,20 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$pdf->MultiCell(10,5,"LR",0,'C',1);
|
||||
$pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
|
||||
$pdf->SetXY(30,$tab_top);
|
||||
$pdf->MultiCell(20,5,$langs->transnoentities("Ref"),0,'C',1);
|
||||
$pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1);
|
||||
$pdf->SetXY(50,$tab_top);
|
||||
$pdf->MultiCell(130,5,$langs->transnoentities("Description"),0,'L',1);
|
||||
$pdf->SetXY(180,$tab_top);
|
||||
$pdf->MultiCell(20,5,$langs->transnoentities("Quantity"),0,'L',1);
|
||||
$pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1);
|
||||
$pdf->SetXY(140,$tab_top);
|
||||
$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1);
|
||||
$pdf->SetXY(170,$tab_top);
|
||||
$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1);
|
||||
$pdf->Rect(10, $tab_top, 190, $tab_height);
|
||||
}
|
||||
|
||||
//********************************
|
||||
// Generation du Pied de page
|
||||
//********************************
|
||||
function _pagefoot(&$pdf)
|
||||
function _pagefoot(&$pdf, $outputlangs)
|
||||
{
|
||||
$pdf->SetFont('Arial','',8);
|
||||
$pdf->SetY(-23);
|
||||
@ -295,7 +302,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
//********************************
|
||||
// Generation de l entete
|
||||
//********************************
|
||||
function _pagehead(&$pdf, $exp)
|
||||
function _pagehead(&$pdf, $exp, $outputlangs)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@ -331,7 +338,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, $langs->transnoentities("SendingSheet"), '' , 'L'); // Bordereau expedition
|
||||
$pdf->MultiCell(0, 8, $outputlangs->transnoentities("SendingSheet"), '' , 'L'); // Bordereau expedition
|
||||
//Num Expedition
|
||||
$Yoff = $Yoff+7;
|
||||
$Xoff = 140;
|
||||
@ -339,7 +346,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$pdf->SetXY($Xoff,$Yoff);
|
||||
$pdf->SetFont('Arial','',8);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(0, 8, $langs->transnoentities("RefSending").': '.$exp->ref, '' , 'L');
|
||||
$pdf->MultiCell(0, 8, $outputlangs->transnoentities("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+4;
|
||||
@ -347,7 +354,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
$pdf->SetXY($Xoff,$Yoff);
|
||||
$pdf->SetFont('Arial','',8);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(0, 8, $langs->transnoentities("RefOrder").': '.$exp->commande->ref, '' , 'L');
|
||||
$pdf->MultiCell(0, 8, $outputlangs->transnoentities("RefOrder").': '.$exp->commande->ref, '' , 'L');
|
||||
|
||||
$Xoff = 115;
|
||||
//$this->Code39($Xoff+43, $Yoff+1, $exp->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
|
||||
@ -491,7 +498,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
|
||||
//Tel Client
|
||||
$pdf->SetXY($blDestX,$Yoff+$blSocY);
|
||||
$pdf->SetFont('Arial','',7);
|
||||
$pdf->MultiCell($blW,3, "Tel : ".$this->destinataire->phone_pro, 0, 'L');
|
||||
$pdf->MultiCell($blW,3, $outputlangs->trans("Tel")." : ".$this->destinataire->phone_pro, 0, 'L');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -5,6 +5,7 @@ DeliveryCard=Delivery card
|
||||
DeliveryOrder=Delivery order
|
||||
DeliveryOrders=Delivery orders
|
||||
DeliveryDate=Delivery date
|
||||
DeliveryDateShort=Deliv. date
|
||||
CreateDeliveryOrder=Generate delivery order
|
||||
SetDeliveryDate=Set shipping date
|
||||
ValidateDeliveryReceipt=Validate delivery receipt
|
||||
|
||||
@ -21,7 +21,8 @@ QtyToShip=Qty to ship
|
||||
QtyReceived=Qty received
|
||||
KeepToShip=Keep to ship
|
||||
OtherSendingsForSameOrder=Other sendings for this order
|
||||
DateSending=Date sending
|
||||
DateSending=Date sending order
|
||||
DateSendingShort=Date sending order
|
||||
SendingsForSameOrder=Sendings for this order
|
||||
SendingsAndReceivingForSameOrder=Sendings and receivings for this order
|
||||
SendingsToValidate=Sending to validate
|
||||
|
||||
@ -5,6 +5,7 @@ DeliveryCard=Fiche livraison
|
||||
DeliveryOrder=Bon de livraison
|
||||
DeliveryOrders=Bons de livraison
|
||||
DeliveryDate=Date de livraison
|
||||
DeliveryDateShort=Date livr.
|
||||
CreateDeliveryOrder=Générer bon de livraison
|
||||
QtyDelivered=Qté livrée
|
||||
SetDeliveryDate=Définir la date de livraison
|
||||
|
||||
@ -13,15 +13,16 @@ StatisticsOfSendings=Statistiques des exp
|
||||
NbOfSendings=Nombre d'expéditions
|
||||
SendingCard=Fiche expédition
|
||||
NewSending=Nouvelle expédition
|
||||
CreateASending=Créer une expedition
|
||||
CreateSending=Créer expedition
|
||||
CreateASending=Créer une expédition
|
||||
CreateSending=Créer expédition
|
||||
QtyOrdered=Qté commandée
|
||||
QtyShipped=Qté expédiée
|
||||
QtyToShip=Qté à expédier
|
||||
QtyReceived=Qté reçue
|
||||
KeepToShip=Reste à expédier
|
||||
OtherSendingsForSameOrder=Autres expéditions pour cette commande
|
||||
DateSending=Date d'expedition
|
||||
DateSending=Date ordre d'expédition
|
||||
DateSendingShort=Date ordre expéd.
|
||||
SendingsForSameOrder=Expéditions pour cette commande
|
||||
SendingsAndReceivingForSameOrder=Expéditions et réceptions pour cette commande
|
||||
SendingsToValidate=Expéditions à valider
|
||||
|
||||
@ -17,10 +17,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/lib/sendings.lib.php
|
||||
\ingroup expedition
|
||||
\brief Library for expedition module
|
||||
\version $Id$
|
||||
* \file htdocs/lib/sendings.lib.php
|
||||
* \ingroup expedition
|
||||
* \brief Library for expedition module
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
|
||||
@ -37,10 +37,11 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
||||
$sql = "SELECT obj.rowid, obj.fk_product, obj.description, obj.qty as qty_asked";
|
||||
$sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id";
|
||||
$sql.= ", e.ref, ".$db->pdate("e.date_expedition")." as date_expedition";
|
||||
if ($conf->livraison_bon->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$origin."det as obj";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
|
||||
if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid";
|
||||
if ($conf->livraison_bon->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, ".$db->pdate("l.date_livraison")." as date_delivery, ld.qty as qty_received";
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$origin."det as obj,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."expedition as e)";
|
||||
if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line";
|
||||
$sql.= " WHERE obj.fk_".$origin." = ".$origin_id;
|
||||
if ($filter) $sql.=$filter;
|
||||
$sql.= " AND obj.rowid = ed.fk_origin_line";
|
||||
@ -63,17 +64,16 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
||||
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$langs->trans("Ref").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="left">'.$langs->trans("Description").'</td>';
|
||||
//print '<td align="left">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="left">'.$langs->trans("SendingSheet").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateSending").'</td>';
|
||||
if ($conf->expedition_bon->enabled)
|
||||
{
|
||||
print '<td>'.$langs->trans("SendingSheet").'</td>';
|
||||
}
|
||||
if ($conf->livraison_bon->enabled)
|
||||
if ($conf->livraison_bon->enabled)
|
||||
{
|
||||
print '<td>'.$langs->trans("DeliveryOrder").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DeliveryDate").'</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
@ -83,7 +83,8 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
||||
$var=!$var;
|
||||
$objp = $db->fetch_object($resql);
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td align="left" nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>';
|
||||
|
||||
// Description
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
@ -98,21 +99,28 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
||||
{
|
||||
print "<td>".dol_htmlentitiesbr(dolibarr_trunc($objp->description,24))."</td>\n";
|
||||
}
|
||||
|
||||
//print '<td align="center">'.$objp->qty_asked.'</td>';
|
||||
|
||||
// Sending id
|
||||
print '<td align="left" nowrap="nowrap"><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">'.$objp->qty_shipped.'</td>';
|
||||
|
||||
print '<td align="center" nowrap="nowrap">'.dolibarr_print_date($objp->date_expedition,'dayhour').'</td>';
|
||||
if ($conf->expedition_bon->enabled)
|
||||
{
|
||||
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 ($conf->livraison_bon->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>';
|
||||
print '<td align="center">'.$objp->qty_received.'</td>';
|
||||
print '<td>'.dolibarr_print_date($objp->date_delivery,'dayhour').'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
}
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
@ -21,15 +21,16 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/livraison/fiche.php
|
||||
\ingroup livraison
|
||||
\brief Fiche descriptive d'un bon de livraison
|
||||
\version $Id$
|
||||
* \file htdocs/livraison/fiche.php
|
||||
* \ingroup livraison
|
||||
* \brief Fiche descriptive d'un bon de livraison
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/livraison/mods/modules_livraison.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/sendings.lib.php");
|
||||
if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
if ($conf->expedition_bon->enabled) require_once(DOL_DOCUMENT_ROOT."/expedition/expedition.class.php");
|
||||
if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
|
||||
@ -42,7 +43,7 @@ if (!$user->rights->expedition->livraison->lire)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
// S<EFBFBD>curit<EFBFBD> acc<63>s client
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
@ -125,6 +126,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||
{
|
||||
Header("Location: liste.php");
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,7 +236,7 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
if ($commande->note)
|
||||
{
|
||||
print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>";
|
||||
print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
@ -254,84 +256,84 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
if ($num)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="54%">'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">Quan. command<6E>e</td>';
|
||||
print '<td align="center">Quan. livr<76>e</td>';
|
||||
print '<td align="center">Quan. <20> livrer</td>';
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
print '<td width="12%" align="center">'.$langs->trans("Stock").'</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="54%">'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">Quan. command<6E>e</td>';
|
||||
print '<td align="center">Quan. livr<76>e</td>';
|
||||
print '<td align="center">Quan. <20> livrer</td>';
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
print '<td width="12%" align="center">'.$langs->trans("Stock").'</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$ligne = $commande->lignes[$i];
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>\n";
|
||||
if ($ligne->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($ligne->fk_product);
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
|
||||
if ($ligne->description) print nl2br($ligne->description);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".nl2br($ligne->description)."</td>\n";
|
||||
}
|
||||
|
||||
print '<td align="center">'.$ligne->qty.'</td>';
|
||||
/*
|
||||
*
|
||||
*/
|
||||
print '<td align="center">';
|
||||
$quantite_livree = $commande->livraisons[$ligne->fk_product];
|
||||
print $quantite_livree;;
|
||||
print '</td>';
|
||||
$ligne = $commande->lignes[$i];
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>\n";
|
||||
if ($ligne->fk_product > 0)
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($ligne->fk_product);
|
||||
|
||||
$quantite_commandee = $ligne->qty;
|
||||
$quantite_a_livrer = $quantite_commandee - $quantite_livree;
|
||||
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$stock = $product->stock_entrepot[$_GET["entrepot_id"]];
|
||||
$stock+=0; // Convertit en num<75>rique
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$ligne->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
|
||||
if ($ligne->description) print nl2br($ligne->description);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".nl2br($ligne->description)."</td>\n";
|
||||
}
|
||||
|
||||
// Quantit<69> <20> livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.min($quantite_a_livrer, $stock).'">';
|
||||
print '</td>';
|
||||
print '<td align="center">'.$ligne->qty.'</td>';
|
||||
/*
|
||||
*
|
||||
*/
|
||||
print '<td align="center">';
|
||||
$quantite_livree = $commande->livraisons[$ligne->id];
|
||||
print $quantite_livree;;
|
||||
print '</td>';
|
||||
|
||||
// Stock
|
||||
if ($stock < $quantite_a_livrer)
|
||||
{
|
||||
print '<td align="center">'.$stock.' '.img_alerte().'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">'.$stock.'</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Quantit<69> <20> livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.$quantite_a_livrer.'">';
|
||||
print '</td>';
|
||||
}
|
||||
$quantite_commandee = $ligne->qty;
|
||||
$quantite_a_livrer = $quantite_commandee - $quantite_livree;
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
$var=!$var;
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$stock = $product->stock_entrepot[$_GET["entrepot_id"]];
|
||||
$stock+=0; // Convertit en num<75>rique
|
||||
|
||||
// Quantit<69> <20> livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.min($quantite_a_livrer, $stock).'">';
|
||||
print '</td>';
|
||||
|
||||
// Stock
|
||||
if ($stock < $quantite_a_livrer)
|
||||
{
|
||||
print '<td align="center">'.$stock.' '.img_alerte().'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">'.$stock.'</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Quantit<69> <20> livrer
|
||||
print '<td align="center">';
|
||||
print '<input name="idl'.$i.'" type="hidden" value="'.$ligne->id.'">';
|
||||
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.$quantite_a_livrer.'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -359,6 +361,9 @@ else
|
||||
$livraison = new Livraison($db);
|
||||
$result = $livraison->fetch($_GET["id"]);
|
||||
$livraison->fetch_client();
|
||||
|
||||
$expedition=new Expedition($db);
|
||||
$result = $expedition->fetch($livraison->expedition_id);
|
||||
|
||||
if ($livraison->origin_id)
|
||||
{
|
||||
@ -370,7 +375,7 @@ else
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($livraison->socid);
|
||||
|
||||
|
||||
$h=0;
|
||||
if ($conf->expedition_bon->enabled)
|
||||
{
|
||||
@ -378,7 +383,7 @@ else
|
||||
$head[$h][1] = $langs->trans("SendingCard");
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$livraison->id;
|
||||
$head[$h][1] = $langs->trans("DeliveryCard");
|
||||
$hselected = $h;
|
||||
@ -427,7 +432,7 @@ else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("RefOrder").'</td>';
|
||||
$order=new Commande($db);
|
||||
$order->fetch($livraison->origin_id);
|
||||
$order->fetch($expedition->origin_id);
|
||||
print '<td colspan="3">';
|
||||
print $order->getNomUrl(1,4);
|
||||
print "</td>\n";
|
||||
@ -481,13 +486,13 @@ else
|
||||
if ($num_prod)
|
||||
{
|
||||
$i = 0;
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Products").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
$var=true;
|
||||
while ($i < $num_prod)
|
||||
{
|
||||
@ -497,7 +502,7 @@ else
|
||||
{
|
||||
$product = new Product($db);
|
||||
$product->fetch($livraison->lignes[$i]->fk_product);
|
||||
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$livraison->lignes[$i]->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$product->libelle;
|
||||
if ($livraison->lignes[$i]->description) print '<br>'.$livraison->lignes[$i]->description;
|
||||
@ -529,7 +534,7 @@ else
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
|
||||
if (! eregi('^(valid|delete)',$_REQUEST["action"]))
|
||||
{
|
||||
if ($livraison->statut == 0 && $user->rights->expedition->livraison->valider && $num_prod > 0)
|
||||
@ -549,15 +554,15 @@ else
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
print "\n";
|
||||
|
||||
|
||||
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
|
||||
|
||||
|
||||
/*
|
||||
* Documents g<EFBFBD>n<EFBFBD>r<EFBFBD>s
|
||||
* Documents generated
|
||||
*/
|
||||
|
||||
$livraisonref = sanitize_string($livraison->ref);
|
||||
@ -568,81 +573,17 @@ else
|
||||
$delallowed=$user->rights->expedition->livraison->supprimer;
|
||||
|
||||
$somethingshown=$formfile->show_documents('livraison',$livraisonref,$filedir,$urlsource,$genallowed,$delallowed,$livraison->modelpdf);
|
||||
|
||||
/*
|
||||
* D<EFBFBD>j<EFBFBD> livre
|
||||
*/
|
||||
$sql = "SELECT ld.fk_product, ld.description, ld.qty as qty_shipped, ld.fk_livraison as livraison_id";
|
||||
$sql.= ", l.ref, ".$db->pdate("l.date_livraison")." as date_livraison";
|
||||
$sql.= ", cd.rowid, cd.qty as qty_commande";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l";
|
||||
$sql.= " WHERE l.rowid <> ".$livraison->id;
|
||||
$sql.= " AND cd.rowid = ld.fk_origin_line";
|
||||
$sql.= " AND ld.fk_livraison = l.rowid";
|
||||
$sql.= " AND l.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 align="left">'.$langs->trans("Sending").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyShipped").'</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]>";
|
||||
print '<td align="left"><a href="'.DOL_URL_ROOT.'/livraison/fiche.php?id='.$objp->livraison_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 nl2br($objp->description);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
|
||||
}
|
||||
print '<td align="center">'.$objp->qty_shipped.'</td>';
|
||||
print '<td align="center">'.dolibarr_print_date($objp->date_livraison,"dayhour").'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
if ($genallowed && ! $somethingshown) $somethingshown=1;
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
// Rien <EFBFBD> droite
|
||||
|
||||
// Rien a droite
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '<br>';
|
||||
//show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
|
||||
show_list_sending_receive($expedition->origin,$expedition->origin_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -633,10 +633,11 @@ class Livraison extends CommonObject
|
||||
$this->lignes = array();
|
||||
|
||||
$sql = "SELECT p.label, p.ref,";
|
||||
$sql.= " l.description, l.fk_product, l.subprice, l.total_ht, l.qty as qty_shipped";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."livraisondet as l";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = l.fk_product";
|
||||
$sql.= " WHERE l.fk_livraison = ".$this->id;
|
||||
$sql.= " cd.qty as qty_asked,";
|
||||
$sql.= " ld.description, ld.fk_product, ld.subprice, ld.total_ht, ld.qty as qty_shipped";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = ld.fk_product";
|
||||
$sql.= " WHERE ld.fk_origin_line = cd.rowid AND ld.fk_livraison = ".$this->id;
|
||||
|
||||
dolibarr_syslog("Livraison::fetch_lignes sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -153,7 +153,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
|
||||
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
||||
$pdf->SetAuthor($user->fullname);
|
||||
|
||||
$this->_pagehead($pdf, $delivery);
|
||||
$this->_pagehead($pdf, $delivery, $outputlangs);
|
||||
|
||||
$pagenb = 1;
|
||||
$tab_top = 100;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user