Uniformize code

This commit is contained in:
Laurent Destailleur 2016-10-29 16:18:39 +02:00
parent cb3f0dadab
commit 32b6660f63
16 changed files with 235 additions and 103 deletions

View File

@ -204,7 +204,7 @@ if ($mode == 'overwrite')
print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("NewTranslationStringToShow"),$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder);
if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
//if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
print '<td align="center"></td>';
print "</tr>\n";
@ -371,7 +371,7 @@ if ($mode == 'searchkey')
print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder).'</td>';
print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CurrentTranslationString"),$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder);
if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
//if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
print '<td align="center"></td>';
print "</tr>\n";
@ -399,7 +399,7 @@ if ($mode == 'searchkey')
//}
print '</td>';
// Action column
print '<td class="liste_titre" align="middle">';
print '<td class="liste_titre nowrap" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpitco;
print '</td>';
@ -427,10 +427,10 @@ if ($mode == 'searchkey')
$htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]);
print $form->textwithpicto('', $htmltext, 1, 'warning');
}
if (! empty($conf->multicompany->enabled) && !$user->entity)
/*if (! empty($conf->multicompany->enabled) && !$user->entity)
{
print $val;
}
}*/
print '</td></tr>'."\n";
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
@ -73,8 +73,10 @@ print '<table class="noborder" width="100%">'."\n";
clearstatcache();
$workflowcodes=array(
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
// Automatic creation
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'),
'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'),
// Automatic classification
'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'),
'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'order','warning'=>'WarningCloseAlways'),
// For the following 2 options, if module invoice is disabled, they does not exists, so "Classify billed" for order must be done manually from order card.
@ -108,7 +110,11 @@ foreach($workflowcodes as $key => $params)
if ($oldfamily != $family)
{
print '<tr class="liste_titre">'."\n";
print ' <td>'.$langs->trans("Description").'</td>';
print ' <td>';
if ($family == 'create') print $langs->trans("AutomaticCreation");
elseif ($family == 'classify') print $langs->trans("AutomaticClassification");
else print $langs->trans("Description");
print '</td>';
print ' <td align="center">'.$langs->trans("Status").'</td>';
print "</tr>\n";
$oldfamily = $family;

View File

@ -3325,7 +3325,7 @@ class Commande extends CommonOrder
* @param int $withpicto Add picto into link
* @param int $option Where point the link (0=> main card, 1,2 => shipment)
* @param int $max Max length to show
* @param int $short Use short labels
* @param int $short ???
* @param int $notooltip 1=Disable tooltip
* @return string String with URL
*/

View File

@ -1148,7 +1148,6 @@ abstract class CommonObject
*/
function fetch_origin()
{
// TODO uniformise code
if ($this->origin == 'shipping') $this->origin = 'expedition';
if ($this->origin == 'delivery') $this->origin = 'livraison';

View File

@ -21,8 +21,9 @@
* \ingroup expedition
* \brief Library for expedition module
*/
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
/**
@ -169,9 +170,10 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
$product_static=new Product($db);
$expedition=new Expedition($db);
$warehousestatic=new Entrepot($db);
$sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end";
$sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line";
$sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id";
$sql.= ", e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
//if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,";
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
@ -209,7 +211,11 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
print '<td align="center">'.$langs->trans("DateCreation").'</td>';
print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
if ($conf->livraison_bon->enabled)
if (! empty($conf->stock->enabled))
{
print '<td>'.$langs->trans("Warehouse").'</td>';
}
if (! empty($conf->livraison_bon->enabled))
{
print '<td>'.$langs->trans("DeliveryOrder").'</td>';
//print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
@ -309,6 +315,18 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
// Qty shipped
print '<td align="center">'.$objp->qty_shipped.'</td>';
// Warehouse
if (! empty($conf->stock->enabled))
{
print '<td>';
if ($objp->warehouse_id > 0)
{
$warehousestatic->fetch($objp->warehouse_id);
print $warehousestatic->getNomUrl(1);
}
print '</td>';
}
// Informations on receipt
if (! empty($conf->livraison_bon->enabled))
{

View File

@ -1352,6 +1352,8 @@ else if ($id || $ref)
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
// We don't have project on shipment, so we will use the project or source object instead
// TODO Add project on shipment
$morehtmlref .= ' : ';
if (! empty($objectsrc->fk_project)) {
$proj = new Project($db);
@ -1398,7 +1400,7 @@ else if ($id || $ref)
// Date creation
print '<tr><td class="titlefield">'.$langs->trans("DateCreation").'</td>';
print '<td colspan="3">'.dol_print_date($object->date_creation,"day")."</td>\n";
print '<td colspan="3">'.dol_print_date($object->date_creation,"dayhour")."</td>\n";
print '</tr>';
// Delivery date planned

View File

@ -21,6 +21,7 @@
/**
* \file htdocs/expedition/shipment.php
* \ingroup expedition
* \brief Tab shipments/delivery receipts on the order
*/
require '../main.inc.php';
@ -457,8 +458,8 @@ if ($id > 0 || ! empty($ref))
/**
* Lignes de commandes avec quantite livrees et reste a livrer
* Les quantites livrees sont stockees dans $commande->expeditions[fk_product]
* Lines or orders with quantity shipped and remain to ship
* Note: Qty shipped are already available into $commande->expeditions[fk_product]
*/
print '<table class="noborder noshadow" width="100%">';

View File

@ -1017,7 +1017,7 @@ SimpleNumRefModelDesc=Returns the reference number with format %syymm-nnnn where
ShowProfIdInAddress=Show professionnal id with addresses on documents
ShowVATIntaInAddress=Hide VAT Intra num with addresses on documents
TranslationUncomplete=Partial translation
SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to <a href="http://transifex.com/projects/p/dolibarr/" target="_blank">http://transifex.com/projects/p/dolibarr/</a>.
SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to <a href="https://transifex.com/projects/p/dolibarr/" target="_blank">http://transifex.com/projects/p/dolibarr/</a>.
MAIN_DISABLE_METEO=Disable meteo view
TestLoginToAPI=Test login to API
ProxyDesc=Some features of Dolibarr need to have an Internet access to work. Define here parameters for this. If the Dolibarr server is behind a Proxy server, those parameters tells Dolibarr how to access Internet through it.

View File

@ -1,10 +1,10 @@
# Dolibarr language file - Source file is en_US - deliveries
Delivery=Delivery
DeliveryRef=Ref Delivery
DeliveryCard=Delivery card
DeliveryCard=Receipt card
DeliveryOrder=Delivery order
DeliveryDate=Delivery date
CreateDeliveryOrder=Generate delivery order
CreateDeliveryOrder=Generate delivery receipt
DeliveryStateSaved=Delivery state saved
SetDeliveryDate=Set shipping date
ValidateDeliveryReceipt=Validate delivery receipt

View File

@ -20,6 +20,7 @@ CreateASending=Create a shipment
QtyShipped=Qty shipped
QtyToShip=Qty to ship
QtyReceived=Qty received
QtyInOtherShipments=Qty in other shipments
KeepToShip=Remain to ship
OtherSendingsForSameOrder=Other shipments for this order
SendingsAndReceivingForSameOrder=Shipments and receivings for this order
@ -40,6 +41,8 @@ DocumentModelMerou=Merou A5 model
WarningNoQtyLeftToSend=Warning, no products waiting to be shipped.
StatsOnShipmentsOnlyValidated=Statistics conducted on shipments only validated. Date used is date of validation of shipment (planed delivery date is not always known).
DateDeliveryPlanned=Planned date of delivery
RefDeliveryReceipt=Ref delivery receipt
StatusReceipt=Status delivery receipt
DateReceived=Date delivery received
SendShippingByEMail=Send shipment by EMail
SendShippingRef=Submission of shipment %s

View File

@ -10,4 +10,6 @@ descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to bil
descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid
descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is validated
descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal to billed when customer invoice is validated
descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify shipped linked source order on shipping validate if quantity shipped is the same as in order
descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify linked source order to shipped when a shipment is validated and quantity shipped is the same as in order
AutomaticCreation=Automatic creation
AutomaticClassification=Automatic classification

View File

@ -32,7 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
if (! empty($conf->expedition_bon->enabled))
@ -368,9 +369,73 @@ else
* Livraison
*/
print '<table class="border" width="100%">';
if ($typeobject == 'commande' && $expedition->$typeobject->id && ! empty($conf->commande->enabled))
{
$objectsrc=new Commande($db);
$objectsrc->fetch($expedition->$typeobject->id);
}
if ($typeobject == 'propal' && $expedition->$typeobject->id && ! empty($conf->propal->enabled))
{
$objectsrc=new Propal($db);
$objectsrc->fetch($expedition->$typeobject->id);
}
// Shipment card
$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref customer shipment
$morehtmlref.=$form->editfieldkey("RefCustomer", '', $expedition->ref_customer, $expedition, $user->rights->expedition->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", '', $expedition->ref_customer, $expedition, $user->rights->expedition->creer, 'string', '', null, null, '', 1);
$morehtmlref.='<br>'.$langs->trans("RefDeliveryReceipt").' : '.$object->ref;
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $expedition->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '<br>' . $langs->trans('Project') . ' ';
if (0) { // Do not change on shipment
if ($action != 'classify') {
$morehtmlref .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $expedition->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
}
if ($action == 'classify') {
// $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $expedition->id, $expedition->socid, $expedition->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $expedition->id . '">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
$morehtmlref .= $formproject->select_projects($expedition->socid, $expedition->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $expedition->id, $expedition->socid, $expedition->fk_project, 'none', 0, 0, 0, 1);
}
} else {
$morehtmlref .= ' : ';
if (! empty($expeditionsrc->fk_project)) {
$proj = new Project($db);
$proj->fetch($expeditionsrc->fk_project);
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $expeditionsrc->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref .= $proj->ref;
$morehtmlref .= '</a>';
} else {
$morehtmlref .= '';
}
}
}
$morehtmlref.='</div>';
$morehtmlright = $langs->trans("StatusReceipt").' : '.$object->getLibStatut(6).'<br>';
dol_banner_tab($expedition, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Shipment
/*
if (($object->origin == 'shipment' || $object->origin == 'expedition') && $object->origin_id > 0)
{
$linkback = '<a href="'.DOL_URL_ROOT.'/expedition/list.php">'.$langs->trans("BackToList").'</a>';
@ -394,11 +459,12 @@ else
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
print '<td align="3">'.$soc->getNomUrl(1).'</td>';
print "</tr>";
*/
// Document origine
if ($typeobject == 'commande' && $expedition->origin_id && ! empty($conf->commande->enabled))
{
print '<tr><td>'.$langs->trans("RefOrder").'</td>';
print '<tr><td class="titlefield">'.$langs->trans("RefOrder").'</td>';
$order=new Commande($db);
$order->fetch($expedition->origin_id);
print '<td colspan="3">';
@ -410,21 +476,16 @@ else
{
$propal=new Propal($db);
$propal->fetch($expedition->origin_id);
print '<tr><td>'.$langs->trans("RefProposal").'</td>';
print '<tr><td class="titlefield">'.$langs->trans("RefProposal").'</td>';
print '<td colspan="3">';
print $propal->getNomUrl(1,'expedition');
print "</td>\n";
print '</tr>';
}
// Ref client
print '<tr><td>'.$langs->trans("RefCustomer").'</td>';
print '<td colspan="3">'.$object->ref_customer."</a></td>\n";
print '</tr>';
// Date
print '<tr><td>'.$langs->trans("DateCreation").'</td>';
print '<td colspan="3">'.dol_print_date($object->date_creation,'daytext')."</td>\n";
print '<tr><td class="titlefield">'.$langs->trans("DateCreation").'</td>';
print '<td colspan="3">'.dol_print_date($object->date_creation,'dayhour')."</td>\n";
print '</tr>';
// Date delivery real / Received
@ -441,13 +502,13 @@ else
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdate_livraison">';
$form->select_date($object->date_delivery?$object->date_delivery:-1,'liv_',1,1,'',"setdate_livraison");
$form->select_date($object->date_delivery?$object->date_delivery:-1, 'liv_', 1, 1, '', "setdate_livraison", 1, 1);
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $object->date_delivery ? dol_print_date($object->date_delivery,'dayhourtext') : '&nbsp;';
print $object->date_delivery ? dol_print_date($object->date_delivery,'dayhour') : '&nbsp;';
}
print '</td>';
print '</tr>';
@ -475,27 +536,24 @@ else
print '</td></tr>';
}
/* A delivery note should be just more properties of a shipment, so notes are on shipment
// Note Public
print '<tr><td>'.$langs->trans("NotePublic").'</td>';
print '<td colspan="3">';
print nl2br($object->note_public);
/*$doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);*/
print "</td></tr>";
// Note Private
print '<tr><td>'.$langs->trans("NotePrivate").'</td>';
print '<td colspan="3">';
print nl2br($object->note_private);
/*$doleditor = new DolEditor('note_pprivate', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);*/
print "</td></tr>";
*/
// Statut
print '<tr><td>'.$langs->trans("Status").'</td>';
/*print '<tr><td>'.$langs->trans("Status").'</td>';
print '<td colspan="3">'.$object->getLibStatut(4)."</td>\n";
print '</tr>';
print '</tr>';*/
if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
{
@ -513,6 +571,8 @@ else
print "</table><br>\n";
print '</div>';
/*
* Lignes produits
*/
@ -693,12 +753,12 @@ else
print '</td></tr></table>';
// List of existing shipment and delivery receipts
if ($expedition->origin_id)
/*if ($expedition->origin_id)
{
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
{

View File

@ -817,6 +817,12 @@ class Livraison extends CommonObject
if ($statut==0) return img_picto($langs->trans('StatusDeliveryDraft'),'statut0').' '.$langs->trans('StatusDeliveryDraft');
if ($statut==1) return img_picto($langs->trans('StatusDeliveryValidated'),'statut4').' '.$langs->trans('StatusDeliveryValidated');
}
if ($mode == 6)
{
if ($statut==-1) return $langs->trans('StatusDeliveryCanceled').' '.img_picto($langs->trans('StatusDeliveryCanceled'),'statut5');
if ($statut==0) return $langs->trans('StatusDeliveryDraft').' '.img_picto($langs->trans('StatusDeliveryDraft'),'statut0');
if ($statut==1) return $langs->trans('StatusDeliveryValidated').' '.img_picto($langs->trans('StatusDeliveryValidated'),'statut4');
}
}

View File

@ -113,7 +113,7 @@ $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price
$sql.= ' p.fk_product_type, p.tms as datem,';
$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tobatch,';
$sql.= ' ps.fk_entrepot,';
$sql.= ' e.label as warehouse_label,';
$sql.= ' e.label as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,';
$sql.= ' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,';
$sql.= ' pl.eatby, pl.sellby,';
$sql.= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable';
@ -158,7 +158,7 @@ $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.pr
$sql.= " p.fk_product_type, p.tms,";
$sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tobatch,";
$sql.= " ps.fk_entrepot,";
$sql.= " e.label,";
$sql.= " e.label, e.lieu, e.fk_parent,";
$sql.= " pb.batch, pb.eatby, pb.sellby,";
$sql.= " pl.eatby, pl.sellby";
if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet
@ -303,7 +303,7 @@ if ($resql)
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
// Multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
{
@ -321,16 +321,29 @@ if ($resql)
}
}
$var=!$var;
print '<tr '.$bc[$var].'><td class="nowrap">';
$product_static->ref=$objp->ref;
$product_static->id=$objp->rowid;
$product_static->label = $objp->label;
$product_static->type=$objp->fk_product_type;
$product_static->entity=$objp->entity;
$warehousetmp->id=$objp->fk_entrepot;
$warehousetmp->ref=$objp->warehouse_ref;
$warehousetmp->label=$objp->warehouse_ref;
$warehousetmp->fk_parent=$objp->warehouse_parent;
$var=!$var;
print '<tr '.$bc[$var].'>';
// Ref
print '<td class="nowrap">';
print $product_static->getNomUrl(1,'',16);
//if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow"));
print '</td>';
// Label
print '<td>'.$objp->label.'</td>';
if (! empty($conf->service->enabled) && $type == 1)
@ -350,9 +363,6 @@ if ($resql)
print '<td>';
if ($objp->fk_entrepot > 0)
{
$warehousetmp->id=$objp->fk_entrepot;
$warehousetmp->label=$objp->warehouse_label;
//$warehousetmp->fetch($objp->fk_entrepot);
print $warehousetmp->getNomUrl(1);
}
print '</td>';

View File

@ -71,6 +71,7 @@ class Entrepot extends CommonObject
//! Code Postal
var $zip;
var $town;
var $fk_parent;
// List of short language codes for status
var $statuts = array();
@ -307,12 +308,10 @@ class Entrepot extends CommonObject
$sql = "SELECT rowid, fk_parent, label, description, statut, lieu, address, zip, town, fk_pays as country_id";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
if ($id)
{
$sql.= " WHERE rowid = '".$id."'";
}
else
{
$sql.= " WHERE entity = " .$conf->entity;
@ -330,7 +329,8 @@ class Entrepot extends CommonObject
$this->id = $obj->rowid;
$this->fk_parent = $obj->fk_parent;
$this->ref = $obj->rowid;
$this->libelle = $obj->label;
$this->label = $obj->label;
$this->libelle = $obj->label; // deprecated
$this->description = $obj->description;
$this->statut = $obj->statut;
$this->lieu = $obj->lieu;
@ -567,25 +567,46 @@ class Entrepot extends CommonObject
* Return clickable name (possibility with the pictogram)
*
* @param int $withpicto with pictogram
* @param string $option What point the link
* @param string $option Where the link point to
* @param int $showfullpath 0=Show ref only. 1=Show full path instead of Ref (this->fk_parent must be defined)
* @param int $notooltip 1=Disable tooltip
* @return string String with URL
*/
function getNomUrl($withpicto=0,$option='')
function getNomUrl($withpicto=0, $option='',$showfullpath=0, $notooltip=0)
{
global $langs;
$langs->load("stocks");
$result='';
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result='';
$label = '';
$label = '<u>' . $langs->trans("ShowWarehouse").'</u>';
$label.= '<br><b>' . $langs->trans('Ref') . ':</b> ' . (empty($this->label)?$this->libelle:$this->label);
if (! empty($this->lieu))
$label.= '<br><b>' . $langs->trans('LocationSummary').':</b> '.$this->lieu;
$link='<a href="'.DOL_URL_ROOT.'/product/stock/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
$url = DOL_URL_ROOT.'/product/stock/card.php?id='.$this->id;
if ($withpicto) $result.=($link.img_object($label, 'stock', 'class="classfortooltip"').$linkend.' ');
$result.=$link.$this->get_full_arbo().$linkend;
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowWarehouse");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
}
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
if ($withpicto) $result.=($link.img_object(($notooltip?'':$label), 'stock', ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend.' ');
$result.=$linkstart.($showfullpath ? $this->get_full_arbo() : (empty($this->label)?$this->libelle:$this->label)).$linkend;
return $result;
}
@ -620,40 +641,41 @@ class Entrepot extends CommonObject
/**
* Return full path to current warehouse
*
* @param int $protection Deep counter to avoid infinite loop
* @return string String full path to current warehouse separated by " >> "
*/
function get_full_arbo($protection=1000) {
global $user,$langs,$conf;
$TArbo = array($this->libelle);
$id = $this->id;
$i=0;
while((empty($protection) || $i < $protection)) {
$sql = 'SELECT fk_parent
FROM '.MAIN_DB_PREFIX.'entrepot
WHERE rowid = '.$id;
$resql = $this->db->query($sql);
if($resql) {
$res = $this->db->fetch_object($resql);
if(empty($res->fk_parent)) break;
$id = $res->fk_parent;
$o = new Entrepot($this->db);
$o->fetch($id);
$TArbo[] = $o->libelle;
} else break;
$i++;
}
return implode(' >> ', array_reverse($TArbo));
function get_full_arbo()
{
global $user,$langs,$conf;
$TArbo = array(empty($this->label)?$this->libelle:$this->label);
$protection=100; // We limit depth of warehouses to 100
$warehousetmp = new Entrepot($this->db);
$parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents
$i=0;
while ($parentid > 0 && $i < $protection)
{
$sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.$parentid;
$resql = $this->db->query($sql);
if ($resql)
{
$objarbo = $this->db->fetch_object($resql);
if ($objarbo)
{
$warehousetmp->fetch($parentid);
$TArbo[] = $warehousetmp->label;
$parentid = $objarbo->fk_parent;
}
else break;
}
else dol_print_error($this->db);
$i++;
}
return implode(' >> ', array_reverse($TArbo));
}
/**

View File

@ -82,7 +82,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$form=new Form($db);
$warehouse=new Entrepot($db);
$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,";
$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,";
$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot";
@ -92,7 +92,7 @@ if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref
if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label
if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status;
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
$sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays";
$sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent";
$totalnboflines=0;
$result=$db->query($sql);
if ($result)
@ -185,16 +185,19 @@ if ($result)
if ($num)
{
$entrepot=new Entrepot($db);
$warehouse=new Entrepot($db);
$var=false;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($result);
$entrepot->id = $objp->rowid;
$entrepot->libelle = $objp->ref;
$entrepot->lieu = $objp->lieu;
$warehouse->id = $objp->rowid;
$warehouse->label = $objp->ref;
$warehouse->lieu = $objp->lieu;
$warehouse->fk_parent = $objp->fk_parent;
print "<tr ".$bc[$var].">";
print '<td>' . $entrepot->getNomUrl(1) . '</td>';
print '<td>' . $warehouse->getNomUrl(1) . '</td>';
// Location
print '<td>'.$objp->lieu.'</td>';
// Stock qty
@ -214,7 +217,7 @@ if ($result)
}
print '</td>';
// Status
print '<td align="right">'.$entrepot->LibStatut($objp->statut,5).'</td>';
print '<td align="right">'.$warehouse->LibStatut($objp->statut,5).'</td>';
print '<td></td>';