From 09270aa8bdc342bc567847d8d954553ed9af55fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Jun 2016 07:27:24 +0200 Subject: [PATCH 1/6] Not used table --- .../install/mysql/tables/llx_element_lock.sql | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_element_lock.sql diff --git a/htdocs/install/mysql/tables/llx_element_lock.sql b/htdocs/install/mysql/tables/llx_element_lock.sql deleted file mode 100644 index 155deba9169..00000000000 --- a/htdocs/install/mysql/tables/llx_element_lock.sql +++ /dev/null @@ -1,27 +0,0 @@ --- ============================================================================ --- Copyright (C) 2011 Regis Houssin --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- --- ============================================================================ - -create table llx_element_lock -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_element integer NOT NULL, - elementtype varchar(32) NOT NULL, - datel datetime, -- date of lock - datem datetime, -- date of unlock/modif - sessionid varchar(255) -)ENGINE=innodb; From fd4973c413f8344339ec89c360bd89433747cbf0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Jun 2016 07:50:54 +0200 Subject: [PATCH 2/6] Fix missing total --- htdocs/compta/sociales/index.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 3133022b9e6..65b8033db4a 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -69,7 +69,7 @@ else $typeid=$_REQUEST['typeid']; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { $search_ref=""; $search_label=""; @@ -210,6 +210,8 @@ if ($resql) print ''; print "\n"; + $i=0; + $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); @@ -243,8 +245,12 @@ if ($resql) } print ''; + // Amount print ''.price($obj->amount).''; - + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; + $totalarray['totalttc'] += $obj->amount; + // Due date print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; @@ -256,6 +262,22 @@ if ($resql) $i++; } + // Show total line + if (isset($totalarray['totalttcfield'])) + { + print ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + print ''; + print ''; + print ''; + print ''.price($totalarray['totalttc']).''; + print ''; + print ''; + print ''; + print ''; + } + print ''; } print ''; From 2c4839136517d26f27f48332e069d5d0fffc08c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Jun 2016 07:51:56 +0200 Subject: [PATCH 3/6] No currency into lists --- htdocs/projet/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 2ad8d972638..6859474a987 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -658,10 +658,11 @@ if ($resql) else print $langs->trans('PrivateProject'); print ''; } + // Amount if (! empty($arrayfields['p.opp_amount']['checked'])) { print ''; - if ($obj->opp_status_code) print price($obj->opp_amount, 1, '', 1, -1, -1, $conf->currency); + if ($obj->opp_status_code) print price($obj->opp_amount, 1, '', 1, -1, -1, ''); print ''; } if (! empty($arrayfields['p.fk_opp_status']['checked'])) From 758f5897d3fb071482deb980911c620e7998e7c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Jun 2016 21:22:07 +0200 Subject: [PATCH 4/6] Fix Missing message to explain record is saved --- htdocs/product/composition/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index d0d26292251..1e145390bac 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -116,13 +116,14 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se else if($action==='save_composed_product') { $TProduct = GETPOST('TProduct', 'array'); - if(!empty($TProduct)) + if (!empty($TProduct)) { foreach ($TProduct as $id_product => $row) { if ($row['qty'] > 0) $object->update_sousproduit($id, $id_product, $row['qty'], isset($row['incdec']) ? 1 : 0 ); else $object->del_sousproduit($id, $id_product); } + setEventMessages('RecordSaved', null); } $action=''; } From ccba65fe7401a0d1f9363a09f7529d4946711297 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Jun 2016 22:30:50 +0200 Subject: [PATCH 5/6] Clean dead code --- htdocs/commande/class/commande.class.php | 19 +-- htdocs/langs/en_US/sendings.lang | 1 + htdocs/livraison/card.php | 208 +---------------------- 3 files changed, 4 insertions(+), 224 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e0c3c00adad..f5ea791a02d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1863,9 +1863,9 @@ class Commande extends CommonOrder /** * Load array this->expeditions of lines of shipments with nb of products sent for each order line - * Note: For a dedicated shipment, the fetch_lines load the qty_asked and qty_shipped. This function return qty_shipped cuulated for order + * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order * - * @param int $filtre_statut Filter on status + * @param int $filtre_statut Filter on shipment status * @return int <0 if KO, Nb of lines found if OK */ function loadExpeditions($filtre_statut=-1) @@ -1934,21 +1934,6 @@ class Commande extends CommonOrder else dol_print_error($this->db); } - /** - * Return a array with sendings by line - * - * @param int $filtre_statut Filtre sur statut - * @return int 0 si OK, <0 si KO - * - * TODO deprecate, move to Shipping class - */ - function livraison_array($filtre_statut=self::STATUS_CANCELED) - { - $delivery = new Livraison($this->db); - $deliveryArray = $delivery->livraison_array($filtre_statut); - return $deliveryArray; - } - /** * Return a array with the pending stock by product * diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 1ec229af6c5..c35aa71c8a1 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -72,6 +72,7 @@ ProductQtyInSuppliersShipmentAlreadyRecevied=Product quantity from opened suppli NoProductToShipFoundIntoStock=No product to ship found into warehouse %s. Correct stock or go back to choose another warehouse. WeightVolShort=Weight/Vol. ValidateOrderFirstBeforeShipment=You must first validate the order before being able to make shipments. +CloseShippeOrdersAutomatically=Classify the order "Delivered" if entirely shipped. # Sending methods SendingMethodCATCH=Catch by customer diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 9ae66ee685e..7b47c17f5c7 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -300,213 +300,7 @@ $formfile = new FormFile($db); if ($action == 'create') // Seems to no be used { - print load_fiche_titre($langs->trans("CreateADeliveryOrder")); - - if ($mesg) - { - print $mesg.'
'; - } - - $commande = new Commande($db); - $commande->livraison_array(); - - if ($commande->fetch(GETPOST("commande_id"))) - { - $soc = new Societe($db); - $soc->fetch($commande->socid); - $author = new User($db); - $author->fetch($commande->user_author_id); - - if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled)) - { - $entrepot = new Entrepot($db); - } - - /* - * Commande - */ - print '
'; - print ''; - print ''; - print ''; - if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled)) - { - print ''; - } - print ''; - print ''; - print ''; - - print '"; - - print ""; - print "\n"; - - print '\n"; - - print ''; - - if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled)) - { - print ''; - print ''; - } - - print "\n"; - - if ($commande->note) - { - print '"; - } - print "
'.$langs->trans("Customer").''.$soc->name.''; - - print "
".$langs->trans("Date")."".dol_print_date($commande->date,'dayhourtext')."'.$langs->trans("Order").''.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.''; - print "
'.$langs->trans("Warehouse").''; - $ents = $entrepot->list_array(); - print ''.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].''; - print '".$langs->trans("Author")."".$author->getFullName($langs)."
Note : '.nl2br($commande->note)."
"; - - /* - * Lignes de commandes - */ - print '
'; - - $commande->fetch_lines(1); - $lines = $commande->lines; - - // Lecture des livraisons deja effectuees - $commande->livraison_array(); - - $num = count($commande->lines); - $i = 0; - - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->stock->enabled)) - { - print ''; - } - print "\n"; - } - $var=true; - while ($i < $num) - { - $product = new Product($db); - - $line = $commande->lines[$i]; - $var=!$var; - print "\n"; - if ($line->fk_product > 0) - { - $product->fetch($line->fk_product); - $product->load_stock(); - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $commande->fetch_thirdparty(); - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$commande->thirdparty->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $product->label; - } - else - $label = (! empty($line->label)?$line->label:$product->label); - - print ''; - } - else - { - print "\n"; - } - - print ''; - /* - * - */ - print ''; - - $quantite_commandee = $line->qty; - $quantite_a_livrer = $quantite_commandee - $quantite_livree; - - if (! empty($conf->stock->enabled)) - { - $stock = $product->stock_warehouse[$_GET["entrepot_id"]]->real; - $stock+=0; // Convertit en numerique - - // Quantite a livrer - print ''; - - // Stock - if ($stock < $quantite_a_livrer) - { - print ''; - } - else - { - print ''; - } - } - else - { - // Quantite a livrer - print ''; - } - - print "\n"; - - $i++; - $var=!$var; - } - - /* - * - */ - - print ''; - print "
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyReceived").''.$langs->trans("QtyToShip").''.$langs->trans("Stock").'
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$label; - if ($line->description) print nl2br($line->description); - print '"; - if ($line->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - - if (! empty($line->label)) { - $text.= ' '.$line->label.''; - print $form->textwithtooltip($text,$line->description,3,'','',$i); - } else { - print $text.' '.nl2br($line->description); - } - - print_date_range($lines[$i]->date_start,$lines[$i]->date_end); - print "'.$line->qty.''; - $quantite_livree = $commande->livraisons[$line->id]; - print $quantite_livree; - print ''; - print ''; - print ''; - print ''.$stock.' '.img_warning().''.$stock.''; - print ''; - print ''; - print '

"; - print '
'; - } - else - { - dol_print_error($db); - } + } else /* *************************************************************************** */ From a29b6440e37dea429d2dc9b18d2e9ccd6df4d7cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Jun 2016 22:40:21 +0200 Subject: [PATCH 6/6] Fix order is closed if all shipments are closed. --- htdocs/expedition/class/expedition.class.php | 47 +++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 1e29a2a36f6..ca6abb40e5c 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -93,6 +93,13 @@ class Expedition extends CommonObject var $meths; var $listmeths; // List of carriers + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_CLOSED = 2; + + + /** * Constructor * @@ -1794,9 +1801,9 @@ class Expedition extends CommonObject } /** - * Classify the shipping as closed + * Classify the shipping as closed. * - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ function setClosed() { @@ -1806,15 +1813,43 @@ class Expedition extends CommonObject $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut='.self::STATUS_CLOSED; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; $resql=$this->db->query($sql); if ($resql) { - // TODO: Add option/checkbox to set order billed if 100% of order is shipped - $this->statut=2; + // Set order billed if 100% of order is shipped (qty in shipment lines match qty in order lines) + if ($this->origin == 'commande' && $this->origin_id > 0) + { + $order = new Commande($this->db); + $order->fetch($this->origin_id); + + $order->loadExpeditions(self::STATUS_CLOSED); // Fill $order->expeditions = array(orderlineid => qty) + + $shipments_match_order = 1; + foreach($order->lines as $line) + { + $lineid = $line->id; + $qty = $line->qty; + if (($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->expeditions[$lineid] != $qty) + { + $shipments_match_order = 0; + $text='Qty for order line id '.$lineid.' is '.$qty.' but in shipments with status Expedition::STATUS_CLOSED='.self::STATUS_CLOSED.', we have '.$order->expeditions[$lineid].' so we can t close order'; + dol_syslog($text); + break; + } + } + if ($shipments_match_order) + { + dol_syslog("Qty for the ".count($order->lines)." lines of order have same value for shipments with status Expedition::STATUS_CLOSED=".self::STATUS_CLOSED.', so we close order'); + $order->cloture($user); + } + } + + $this->statut=self::STATUS_CLOSED; + // If stock increment is done on closing if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { @@ -1823,7 +1858,7 @@ class Expedition extends CommonObject $langs->load("agenda"); // Loop on each product line to add a stock movement - // TODO possibilite d'expedier a partir d'une propale ou autre origine + // TODO possibilite d'expedier a partir d'une propale ou autre origine ? $sql = "SELECT cd.fk_product, cd.subprice,"; $sql.= " ed.rowid, ed.qty, ed.fk_entrepot,"; $sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock";