From 32b6660f6340a275cfc3ac5845fd77406a4928df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Oct 2016 16:18:39 +0200 Subject: [PATCH] Uniformize code --- htdocs/admin/translation.php | 10 +- htdocs/admin/workflow.php | 12 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/core/class/commonobject.class.php | 1 - htdocs/core/lib/sendings.lib.php | 26 ++++- htdocs/expedition/card.php | 4 +- htdocs/expedition/shipment.php | 5 +- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/en_US/deliveries.lang | 4 +- htdocs/langs/en_US/sendings.lang | 3 + htdocs/langs/en_US/workflow.lang | 4 +- htdocs/livraison/card.php | 108 ++++++++++++++---- htdocs/livraison/class/livraison.class.php | 6 + htdocs/product/reassortlot.php | 26 +++-- htdocs/product/stock/class/entrepot.class.php | 106 ++++++++++------- htdocs/product/stock/list.php | 19 +-- 16 files changed, 235 insertions(+), 103 deletions(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 1ecd204be98..43f2953ccda 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -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 ''; print "\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).''; 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 ''; print "\n"; @@ -399,7 +399,7 @@ if ($mode == 'searchkey') //} print ''; // Action column - print ''; + print ''; $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); print $searchpitco; print ''; @@ -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 ''."\n"; } diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 75b0ce6d808..d9595cd7fb0 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Laurent Destailleur + * Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -73,8 +73,10 @@ print ''."\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 ''."\n"; - print ' '; + print ' '; print ' '; print "\n"; $oldfamily = $family; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7e1134a8a21..9250060cad4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -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 */ diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e2c6d67074a..5e89b32afb5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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'; diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 06eb19de48e..2a22e3a7383 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -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 ''; print ''; print ''; - if ($conf->livraison_bon->enabled) + if (! empty($conf->stock->enabled)) + { + print ''; + } + if (! empty($conf->livraison_bon->enabled)) { print ''; //print ''; @@ -309,6 +315,18 @@ function show_list_sending_receive($origin,$origin_id,$filter='') // Qty shipped print ''; + // Warehouse + if (! empty($conf->stock->enabled)) + { + print ''; + } + // Informations on receipt if (! empty($conf->livraison_bon->enabled)) { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 62fdcd89dc1..1267783e256 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -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 ''; - print '\n"; + print '\n"; print ''; // Delivery date planned diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 5de764922e1..d16cd64f0ff 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -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 '
'.$langs->trans("Description").''; + if ($family == 'create') print $langs->trans("AutomaticCreation"); + elseif ($family == 'classify') print $langs->trans("AutomaticClassification"); + else print $langs->trans("Description"); + print ''.$langs->trans("Status").'
'.$langs->trans("DateCreation").''.$langs->trans("DateDeliveryPlanned").''.$langs->trans("QtyShipped").''.$langs->trans("Warehouse").''.$langs->trans("DeliveryOrder").''.$langs->trans("QtyReceived").''.$objp->qty_shipped.''; + if ($objp->warehouse_id > 0) + { + $warehousestatic->fetch($objp->warehouse_id); + print $warehousestatic->getNomUrl(1); + } + print '
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation,"day")."'.dol_print_date($object->date_creation,"dayhour")."
'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 7ccd6b10cdc..746d0ec7d77 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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 http://transifex.com/projects/p/dolibarr/. +SomeTranslationAreUncomplete=Some languages may be partially translated or may contains errors. If you detect some, you can fix language files registering to http://transifex.com/projects/p/dolibarr/. 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. diff --git a/htdocs/langs/en_US/deliveries.lang b/htdocs/langs/en_US/deliveries.lang index 423d425c383..7e39f48ea55 100644 --- a/htdocs/langs/en_US/deliveries.lang +++ b/htdocs/langs/en_US/deliveries.lang @@ -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 diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 627e8a78e75..cbbeb092a1a 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -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 diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 6002180ad09..7e22b2a3522 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index e3d2c03970b..fcd32762139 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -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 '
'; - + 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 = ''.$langs->trans("BackToList").''; + + $morehtmlref='
'; + // 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.='
'.$langs->trans("RefDeliveryReceipt").' : '.$object->ref; + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $expedition->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
' . $langs->trans('Project') . ' '; + if (0) { // Do not change on shipment + if ($action != 'classify') { + $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $expedition->id, $expedition->socid, $expedition->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($expedition->socid, $expedition->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; + } 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 .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } + $morehtmlref.='
'; + + $morehtmlright = $langs->trans("StatusReceipt").' : '.$object->getLibStatut(6).'
'; + + dol_banner_tab($expedition, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + + print '
'; + print '
'; + + print '
'; + // Shipment + /* if (($object->origin == 'shipment' || $object->origin == 'expedition') && $object->origin_id > 0) { $linkback = ''.$langs->trans("BackToList").''; @@ -394,11 +459,12 @@ else print ''; print ''; print ""; - + */ + // Document origine if ($typeobject == 'commande' && $expedition->origin_id && ! empty($conf->commande->enabled)) { - print ''; + print ''; $order=new Commande($db); $order->fetch($expedition->origin_id); print ''; + print ''; print '\n"; print ''; } - // Ref client - print ''; - print '\n"; - print ''; - // Date - print ''; - print '\n"; + print ''; + print '\n"; print ''; // Date delivery real / Received @@ -441,13 +502,13 @@ else print ''; print ''; print ''; - $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 ''; print ''; } else { - print $object->date_delivery ? dol_print_date($object->date_delivery,'dayhourtext') : ' '; + print $object->date_delivery ? dol_print_date($object->date_delivery,'dayhour') : ' '; } print ''; print ''; @@ -475,27 +536,24 @@ else print ''; } + /* A delivery note should be just more properties of a shipment, so notes are on shipment // Note Public print ''; print '"; // Note Private print ''; print '"; - + */ // Statut - print ''; + /*print ''; print '\n"; - print ''; + print '';*/ if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled)) { @@ -513,6 +571,8 @@ else print "
'.$langs->trans("Customer").''.$soc->getNomUrl(1).'
'.$langs->trans("RefOrder").'
'.$langs->trans("RefOrder").''; @@ -410,21 +476,16 @@ else { $propal=new Propal($db); $propal->fetch($expedition->origin_id); - print '
'.$langs->trans("RefProposal").'
'.$langs->trans("RefProposal").''; print $propal->getNomUrl(1,'expedition'); print "
'.$langs->trans("RefCustomer").''.$object->ref_customer."
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation,'daytext')."
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation,'dayhour')."
'.$langs->trans("NotePublic").''; 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 "
'.$langs->trans("NotePrivate").''; 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 "
'.$langs->trans("Status").'
'.$langs->trans("Status").''.$object->getLibStatut(4)."

\n"; + print ''; + /* * Lignes produits */ @@ -693,12 +753,12 @@ else print ''; // List of existing shipment and delivery receipts - if ($expedition->origin_id) + /*if ($expedition->origin_id) { print '
'; //show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id); show_list_sending_receive($expedition->origin,$expedition->origin_id); - } + }*/ } else { diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 45e86b50686..15421a8a367 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -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'); + } } diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 43f956b5eea..c9619124389 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -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 ''; + $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 ''; + + // Ref + print ''; print $product_static->getNomUrl(1,'',16); //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); print ''; + + // Label print ''.$objp->label.''; if (! empty($conf->service->enabled) && $type == 1) @@ -350,9 +363,6 @@ if ($resql) print ''; 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 ''; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 032a0f3a56d..2f5af64da96 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -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 = '' . $langs->trans("ShowWarehouse").''; $label.= '
' . $langs->trans('Ref') . ': ' . (empty($this->label)?$this->libelle:$this->label); if (! empty($this->lieu)) $label.= '
' . $langs->trans('LocationSummary').': '.$this->lieu; - $link=''; - $linkend=''; + $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 = ''; + $linkend=''; + + 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)); } /** diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 0498c32bf05..453f49f0c33 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -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 ""; - print '' . $entrepot->getNomUrl(1) . ''; + print '' . $warehouse->getNomUrl(1) . ''; // Location print ''.$objp->lieu.''; // Stock qty @@ -214,7 +217,7 @@ if ($result) } print ''; // Status - print ''.$entrepot->LibStatut($objp->statut,5).''; + print ''.$warehouse->LibStatut($objp->statut,5).''; print '';