From 2264ecfb2c3fa2b72a302dc7cc7a96660ef0af60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 20:58:36 +0200 Subject: [PATCH 01/21] Update llx_commande.sql --- htdocs/install/mysql/tables/llx_commande.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 3511aa7ec78..3df4e89b910 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -63,6 +63,7 @@ create table llx_commande date_livraison date default NULL, fk_shipping_method integer, -- shipping method id + fk_warehouse date default NULL, fk_availability integer NULL, fk_input_reason integer, -- id coming from c_input_reason, '0' if no defined fk_delivery_address integer, -- delivery address (deprecated) From 1d9f9c7f5bbca2472b2f27bcaf359b943712fa6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:00:47 +0200 Subject: [PATCH 02/21] Update llx_commande.sql --- htdocs/install/mysql/tables/llx_commande.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 3df4e89b910..553b2facad7 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -63,7 +63,7 @@ create table llx_commande date_livraison date default NULL, fk_shipping_method integer, -- shipping method id - fk_warehouse date default NULL, + fk_warehouse integer default NULL, fk_availability integer NULL, fk_input_reason integer, -- id coming from c_input_reason, '0' if no defined fk_delivery_address integer, -- delivery address (deprecated) From 6a524eeabb6e58a7a0a8ea2345b945f1cd5c73e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:04:05 +0200 Subject: [PATCH 03/21] Update 3.8.0-3.9.0.sql --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 33593e7fac5..573cadceb3d 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -67,7 +67,7 @@ ALTER TABLE llx_prelevement_lignes MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); - +ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL after fk_shipping_method; ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(1000); From affe067ff1f6e0d39763ec700ef1ef07bb16acbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:09:02 +0200 Subject: [PATCH 04/21] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d20d5d82bde..716d705123e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1507,6 +1507,36 @@ abstract class CommonObject } + /** + * Change the warehouse + * + * @param int $warehouse_id Id of warehouse + * @return int 1 if OK, 0 if KO + */ + function setWarehouse($warehouse_id) + { + if (! $this->table_element) { + dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined",LOG_ERR); + return -1; + } + if ($warehouse_id<0) $warehouse_id='NULL'; + dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')'); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " SET fk_warehouse = ".$warehouse_id; + $sql.= " WHERE rowid=".$this->id; + + if ($this->db->query($sql)) { + $this->warehouse_id = ($warehouse_id=='NULL')?null:$warehouse_id; + return 1; + } else { + dol_syslog(get_class($this).'::setWarehouse Error ', LOG_DEBUG); + $this->error=$this->db->error(); + return 0; + } + } + + /** * Set last model used by doc generator * From fe1931bba88fdebcacd520e6ce21600349a8af72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:21:27 +0200 Subject: [PATCH 05/21] Update commande.class.php --- htdocs/commande/class/commande.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d2f5c4d799f..40844da3d56 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -702,6 +702,7 @@ class Commande extends CommonOrder $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int"; $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; $sql.= ", fk_shipping_method"; + $sql.= ", fk_warehouse"; $sql.= ", remise_absolue, remise_percent"; $sql.= ", fk_incoterms, location_incoterms"; $sql.= ", entity"; @@ -724,6 +725,7 @@ class Commande extends CommonOrder $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null"); $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL'); $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); + $sql.= ", ".($this->warehouse_id>0?$this->warehouse_id:'NULL'); $sql.= ", ".($this->remise_absolue>0?$this->db->escape($this->remise_absolue):'NULL'); $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0); $sql.= ", ".(int) $this->fk_incoterms; @@ -1063,6 +1065,7 @@ class Commande extends CommonOrder $this->demand_reason_id = $object->demand_reason_id; $this->date_livraison = $object->date_livraison; $this->shipping_method_id = $object->shipping_method_id; + $this->warehouse_id = $object->warehouse_id; $this->fk_delivery_address = $object->fk_delivery_address; $this->contact_id = $object->contactid; $this->ref_client = $object->ref_client; @@ -1432,6 +1435,7 @@ class Commande extends CommonOrder $sql.= ', c.date_commande'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_shipping_method'; + $sql.= ', c.fk_warehouse'; $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams'; $sql.= ', c.fk_incoterms, c.location_incoterms'; @@ -1499,6 +1503,7 @@ class Commande extends CommonOrder $this->demand_reason_code = $obj->demand_reason_code; $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; + $this->warehouse_id = ($obj->fk_warehouse>0)?$obj->fk_warehouse:null; $this->fk_delivery_address = $obj->fk_delivery_address; //Incoterms From 229fa59f6c3c749acc2c8b969fa61de4c86d32d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:57:26 +0200 Subject: [PATCH 06/21] Update commande.php --- htdocs/admin/commande.php | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 860e1a21772..f7e3812d74f 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -251,6 +251,23 @@ else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') } } +// Activate ask for warehouse +else if ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') +{ + $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER",$value,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + /* * View @@ -630,6 +647,36 @@ else print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").' '.$langs->trans('NotAvailable').''; } +// Ask for warehouse during order +if ($conf->stock->enabled) +{ + $var=!$var; + print ''; + print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '; + if (! empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER'); + } + else + { + if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) + { + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; + } + else + { + print ''.img_picto($langs->trans("Enabled"),'switch_on').''; + } + } + print ''; +} +else +{ + $var=!$var; + print ''; + print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '.$langs->trans('NotAvailable').''; +} + print ''; print '
'; From 3e730cc9e2000f7332a59b626f1540a6a95da97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 22:01:30 +0200 Subject: [PATCH 07/21] Update admin.lang --- htdocs/langs/en_US/admin.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6f720c0a92b..453bfbc946e 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1203,6 +1203,7 @@ AskPriceSupplierPDFModules=Price requests suppliers documents models FreeLegalTextOnAskPriceSupplier=Free text on price requests suppliers WatermarkOnDraftAskPriceSupplier=Watermark on draft price requests suppliers (none if empty) BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER=Ask for bank account destination of price request +WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER=Ask for Warehouse Source for order ##### Orders ##### OrdersSetup=Order management setup OrdersNumberingModules=Orders numbering models @@ -1692,4 +1693,4 @@ MailToSendSupplierRequestForQuotation=To send quotation request to supplier MailToSendSupplierOrder=To send supplier order MailToSendSupplierInvoice=To send supplier invoice MailToThirdparty=To send email from thirdparty page -ByDefaultInList=Show by default on list view \ No newline at end of file +ByDefaultInList=Show by default on list view From 50fe3f6ee9293589bf04e7d4c2cd3d819943605d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 22:06:46 +0200 Subject: [PATCH 08/21] Update html.formproduct.class.php --- .../product/class/html.formproduct.class.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 0215f20e3c6..f08143c443c 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -134,6 +134,40 @@ class FormProduct return $out; } + /** + * Display form to select warehouse + * + * @param string $page Page + * @param int $selected Id of warehouse + * @param string $htmlname Name of select html field + * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @return void + */ + function formSelectWarehouses($page, $selected='', $htmlname='warehouse_id', $addempty=0) + { + global $langs; + if ($htmlname != "none") { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $this->selectWarehouses($selected, $htmlname, '', $addempty); + print '
'; + } else { + if ($selected) { + require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; + $warehousestatic=new Entrepot($this->db); + $warehousestatic->fetch($selected); + print $warehousestatic->getNomUrl(); + } else { + print " "; + } + } + } + /** * Output a combo box with list of units * pour l'instant on ne definit pas les unites dans la base From 72491db6b4d0d24b27c05256164ac0c4938f6e6d Mon Sep 17 00:00:00 2001 From: philippe grand Date: Tue, 20 Oct 2015 09:31:33 +0200 Subject: [PATCH 09/21] [Qual] Uniformize code --- htdocs/accountancy/admin/account.php | 4 ++-- htdocs/accountancy/admin/card.php | 2 +- htdocs/accountancy/admin/export.php | 4 ++-- htdocs/accountancy/admin/fiscalyear_card.php | 6 +++--- htdocs/accountancy/admin/importaccounts.php | 6 +++--- htdocs/accountancy/admin/index.php | 12 ++++++------ htdocs/accountancy/admin/journal.php | 4 ++-- htdocs/accountancy/admin/productaccount.php | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index a56701dada2..d1c4ef409b4 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -76,7 +76,7 @@ if ($action == 'disable') { $action = 'update'; if ($result < 0) { - setEventMessage($accounting->error, 'errors'); + setEventMessages($accounting->error, $accounting->errors, 'errors'); } } else if ($action == 'enable') { if ($accounting->fetch($id)) { @@ -84,7 +84,7 @@ if ($action == 'disable') { } $action = 'update'; if ($result < 0) { - setEventMessage($accounting->error, 'errors'); + setEventMessages($accounting->error, $accounting->errors, 'errors'); } } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 925bf818137..99eb49949e7 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -125,7 +125,7 @@ else if ($action == 'delete') } if ($result < 0) { - setEventMessage($accounting->error, 'errors'); + setEventMessages($accounting->error, $accounting->errors, 'errors'); } } diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 9bde2d23c14..c0a987ddf82 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -100,9 +100,9 @@ if ($action == 'update') { } if (! $error) { - setEventMessage($langs->trans("SetupSaved")); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"), 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 657d5b100e6..45e69c991de 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -66,7 +66,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -110,7 +110,7 @@ else if ($action == 'add') { $db->rollback(); - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action='create'; } } @@ -147,7 +147,7 @@ else if ($action == 'update') } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 61e86b7df19..7c38617d66c 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -76,14 +76,14 @@ if ($_POST["action"] == 'import') { $result = $accounting->create($user); if ($result > 0) { - setEventMessage($langs->trans("AccountingAccountAdd"), 'mesgs'); + setEventMessages($langs->trans("AccountingAccountAdd"), null, 'mesgs'); } else { - setEventMessage($accounting->error, 'errors'); + setEventMessages($accounting->error, $accounting->errors, 'errors'); } $cpt ++; } } else { - setEventMessage($langs->trans('AccountPlanNotFoundCheckSetting'), 'errors'); + setEventMessages($langs->trans('AccountPlanNotFoundCheckSetting'), null, 'errors'); } } else { print '
' . $langs->trans("AnyLineImport") . '
'; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index af0bccdf00c..40dff028783 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -111,11 +111,11 @@ if ($action == 'update') if (! $error) { - setEventMessage($langs->trans("SetupSaved")); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"),'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -126,9 +126,9 @@ if ($action == 'setlistsorttodo') { $error ++; if (! $error) { - setEventMessage($langs->trans("SetupSaved"), 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"), 'mesgs'); + setEventMessages($langs->trans("Error"), null, 'mesgs'); } } @@ -138,9 +138,9 @@ if ($action == 'setlistsortdone') { if (! $res > 0) $error ++; if (! $error) { - setEventMessage($langs->trans("SetupSaved"), 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"), 'mesgs'); + setEventMessages($langs->trans("Error"), null, 'mesgs'); } } diff --git a/htdocs/accountancy/admin/journal.php b/htdocs/accountancy/admin/journal.php index b55728ee080..18f01abb082 100644 --- a/htdocs/accountancy/admin/journal.php +++ b/htdocs/accountancy/admin/journal.php @@ -68,9 +68,9 @@ if ($action == 'update') { } if (! $error) { - setEventMessage($langs->trans("SetupSaved")); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"), 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index d79d14e74d1..0bea58fd75c 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -116,7 +116,7 @@ if ($action == 'update') { $result=$accounting->fetch($accounting_account_id,null,1); if ($result<0) { - //setEventMessage(null, $accounting->errors,'errors'); + //setEventMessages(null, $accounting->errors, 'errors'); $msg .= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '
' . $sql . '
'; } else { From 3cb2637f25da744249c8f165e6ec4e75ab5d77bd Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Tue, 20 Oct 2015 09:42:02 +0200 Subject: [PATCH 10/21] Correct return value --- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 490b5cf1ea3..cf580459a9c 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -229,7 +229,7 @@ class ProductFournisseur extends Product else { $this->db->rollback(); - return 1; + return -1; } } else @@ -312,7 +312,7 @@ class ProductFournisseur extends Product else { $this->db->rollback(); - return 1; + return -1; } } else From a0fe65266adebd5ac547f2cb3b89b41db267a573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 09:50:09 +0200 Subject: [PATCH 11/21] Update shipment.php --- htdocs/expedition/shipment.php | 35 ++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 82bf1d01e6a..50a231c0898 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -123,6 +123,12 @@ if ($action == 'setshippingmethod' && $user->rights->commande->creer) { $result=$commande->setShippingMethod(GETPOST('shipping_method_id', 'int')); } +// warehouse +if ($action == 'setwarehouse' && $user->rights->commande->creer) { + $commande = new Commande($db); + $commande->fetch($id); + $result = $commande->setWarehouse(GETPOST('warehouse_id', 'int')); +} /* @@ -164,8 +170,8 @@ if ($id > 0 || ! empty($ref)) } // Onglet commande - $nbrow=8; - if (! empty($conf->projet->enabled)) $nbrow++; + //$nbrow=8; + //if (! empty($conf->projet->enabled)) $nbrow++; print ''; @@ -286,6 +292,27 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; + // Warehouse + if (! empty($conf->stock->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct=new FormProduct($db); + print ''; + print ''; + } + // Terms of payment print '"; } } + else + { + print ''; + } print "
'; + print ''; + if ($action != 'editwarehouse' && $user->rights->commande->creer) + print ''; + print '
'; + print $langs->trans('Warehouse'); + print 'id.'">'.img_edit($langs->trans('SetWarehouse'),1).'
'; + print '
'; + if ($action == 'editwarehouse') { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->warehouse_id, 'warehouse_id', 1); + } else { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->warehouse_id, 'none'); + } + print '
'; print ''; + print ''; // Qty already shipped $qtyProdCom=$objp->qty; @@ -677,7 +704,7 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("WarehouseSource").''; print '"; } } + else + { + print ''; + } print "
'; @@ -529,7 +556,7 @@ if ($id > 0 || ! empty($ref)) } // Qty ordered - print ''.$objp->qty.'' . ($objp->qty!=1?''.$objp->qty.'':$objp->qty) . ''; - print $formproduct->selectWarehouses(-1,'entrepot_id','',1); + print $formproduct->selectWarehouses(! empty($commande->warehouse_id)?$commande->warehouse_id:-1,'entrepot_id','',1); if (count($formproduct->cache_warehouses) <= 0) { print '   '.$langs->trans("WarehouseSourceNotDefined").' '.$langs->trans("AddOne").''; From f22b3cdfee24da348694b326673b324b82d19aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 10:31:45 +0200 Subject: [PATCH 12/21] Fix some action has no effect in shipment --- htdocs/expedition/shipment.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 82bf1d01e6a..fa2457516ae 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -88,9 +88,7 @@ if ($action == 'setdatedelivery' && $user->rights->commande->creer) $commande->fetch($id); $result=$commande->set_date_livraison($user,$datelivraison); if ($result < 0) - { - $mesg='
'.$commande->error.'
'; - } + setEventMessages($commande->error, $commande->errors, 'errors'); } if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) @@ -98,6 +96,8 @@ if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) $commande = new Commande($db); $commande->fetch($id); $commande->setDeliveryAddress(GETPOST('delivery_address_id','int')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } if ($action == 'setmode' && $user->rights->commande->creer) @@ -105,7 +105,24 @@ if ($action == 'setmode' && $user->rights->commande->creer) $commande = new Commande($db); $commande->fetch($id); $result = $commande->setPaymentMethods(GETPOST('mode_reglement_id','int')); - if ($result < 0) dol_print_error($db,$commande->error); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); +} + +if ($action == 'setavailability' && $user->rights->commande->creer) { + $commande = new Commande($db); + $commande->fetch($id); + $result=$commande->availability(GETPOST('availability_id')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); +} + +if ($action == 'setdemandreason' && $user->rights->commande->creer) { + $commande = new Commande($db); + $commande->fetch($id); + $result=$commande->demand_reason(GETPOST('demand_reason_id')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } if ($action == 'setconditions' && $user->rights->commande->creer) @@ -113,7 +130,8 @@ if ($action == 'setconditions' && $user->rights->commande->creer) $commande = new Commande($db); $commande->fetch($id); $result=$commande->setPaymentTerms(GETPOST('cond_reglement_id','int')); - if ($result < 0) dol_print_error($db,$commande->error); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } // shipping method @@ -121,6 +139,8 @@ if ($action == 'setshippingmethod' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($id); $result=$commande->setShippingMethod(GETPOST('shipping_method_id', 'int')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } From 2cb9dd8bf3d328d49454d7b48d2053d6b58f9941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 10:33:46 +0200 Subject: [PATCH 13/21] Update shipment.php --- htdocs/expedition/shipment.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 50a231c0898..ce42107fd79 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -128,6 +128,8 @@ if ($action == 'setwarehouse' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($id); $result = $commande->setWarehouse(GETPOST('warehouse_id', 'int')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } From 6f37fef05e9222d82f1eb54ed80e2683c8e3dad0 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Morfin Date: Tue, 20 Oct 2015 14:44:20 +0200 Subject: [PATCH 14/21] fix test against empty amount on book update - amount < 1 was considered as 0 - 0.00 was not considered as empty so $book->sens was always C --- htdocs/accountancy/bookkeeping/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index d1bf69a8eee..d4c256dfbf2 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -51,7 +51,7 @@ if ($action == "confirm_update") { $error = 0; - if ((intval($debit) != 0) && (intval($credit) != 0)) { + if ((floatval($debit)!=0.0) && (floatval($credit)!=0.0)) { setEventMessage($langs->trans('ErrorDebitCredit'), 'errors'); $error ++; } @@ -69,11 +69,11 @@ if ($action == "confirm_update") { $book->debit = $debit; $book->credit = $credit; - if (! empty($debit)) { + if (floatval($debit)!=0.0) { $book->montant = $debit; $book->sens = 'D'; } - if (! empty($credit)) { + if (floatval($credit)!=0.0) { $book->montant = $credit; $book->sens = 'C'; } @@ -372,4 +372,4 @@ if ($action == 'create') { } llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); From d9a56ef418e1eef8f87d317e3de7809302ce0e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 17:00:34 +0200 Subject: [PATCH 15/21] Update index.php --- htdocs/comm/index.php | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 18991f66bba..2c285903cbe 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; if (! $user->rights->societe->lire) accessforbidden(); @@ -65,6 +66,7 @@ $formfile = new FormFile($db); $companystatic=new Societe($db); if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db); if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db); +if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db); llxHeader(); @@ -261,6 +263,84 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $db->free($resql); } + else + { + dol_print_error($db); + } +} + + +/* + * Draft suppliers orders + */ +if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) +{ + $langs->load("orders"); + + $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql.= ", s.code_client"; + $sql.= ", s.code_fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE cf.fk_soc = s.rowid"; + $sql.= " AND cf.fk_statut = 0"; + $sql.= " AND cf.entity IN (".getEntity('supplier_order', 1).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND cf.fk_soc = ".$socid; + + $resql = $db->query($sql); + if ($resql) + { + $total = 0; + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = true; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + $i++; + $total += $obj->total_ttc; + } + if ($total>0) + { + $var=!$var; + print '"; + } + } + print "
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'; + $supplierorderstatic->id=$obj->rowid; + $supplierorderstatic->ref=$obj->ref; + $supplierorderstatic->ref_supplier=$obj->ref_suppliert; + $supplierorderstatic->total_ht = $obj->total_ht; + $supplierorderstatic->total_tva = $obj->total_tva; + $supplierorderstatic->total_ttc = $obj->total_ttc; + print $supplierorderstatic->getNomUrl(1); + print ''; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1,'customer',16); + print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."

"; + + $db->free($resql); + } else { + dol_print_error($db); + } } From 506b251f24111e59981e60bb6c3fa14e24697830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 17:02:04 +0200 Subject: [PATCH 16/21] Update orders.lang --- htdocs/langs/en_US/orders.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index bd1bb09d40f..e1f84847e5d 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -105,6 +105,7 @@ ClassifyShipped=Classify delivered ClassifyBilled=Classify billed ComptaCard=Accountancy card DraftOrders=Draft orders +DraftSuppliersOrders=Draft suppliers orders RelatedOrders=Related orders RelatedCustomerOrders=Related customer orders RelatedSupplierOrders=Related supplier orders From 4062e7474ddde50e9ad1ebbbf77060a8453b7158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:05:21 +0200 Subject: [PATCH 17/21] Update index.php --- htdocs/comm/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 2c285903cbe..fcb94392405 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -146,7 +146,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''; - print ''; + print ''; if ($num > 0) { @@ -221,7 +221,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'.$langs->trans("ProposalsDraft").' '.$num.'
'.$langs->trans("ProposalsDraft").($num?' '.$num.'':'').'
'; print ''; - print ''; + print ''; if ($num) { @@ -297,7 +297,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print '
'.$langs->trans("DraftOrders").' '.$num.'
'.$langs->trans("DraftOrders").($num?' '.$num.'':'').'
'; print ''; - print ''; + print ''; if ($num) { From 2989a9445843f86e92666ed15c4d587f94c8375f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:19:32 +0200 Subject: [PATCH 18/21] Update index.php --- htdocs/comm/index.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index fcb94392405..49f618a4dd5 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -184,6 +184,10 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print '"; } } + else + { + print ''; + } print "
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'.$langs->trans("DraftSuppliersOrders").($num?' '.$num.'':'').'
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoProposal").'

"; $db->free($resql); @@ -259,6 +263,10 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoOrder").'

"; $db->free($resql); @@ -335,6 +343,10 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print '
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoSupplierOrder").'

"; $db->free($resql); From be85943d133d2d2d1095cb0141c8be81df06cfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:21:28 +0200 Subject: [PATCH 19/21] Update orders.lang --- htdocs/langs/en_US/orders.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index e1f84847e5d..287a83afba3 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -79,6 +79,8 @@ OrdersOpened=Orders to process NoOpenedOrders=No open orders NoOtherOpenedOrders=No other open orders NoDraftOrders=No draft orders +NoOrder=No Order +NoSupplierOrder=No supplier order OtherOrders=Other orders LastOrders=Last %s customer orders LastCustomerOrders=Last %s customer orders From 15733f5ed09d8aa0d4637d7d78b745242aa05273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:23:30 +0200 Subject: [PATCH 20/21] Update propal.lang --- htdocs/langs/en_US/propal.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 168f98a2789..d12d7595f94 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -53,6 +53,7 @@ ListOfProposals=List of commercial proposals ActionsOnPropal=Events on proposal NoOpenedPropals=No open commercial proposals NoOtherOpenedPropals=No other open commercial proposals +NoPropal=No commercial proposal RefProposal=Commercial proposal ref SendPropalByMail=Send commercial proposal by mail AssociatedDocuments=Documents associated with the proposal: @@ -98,4 +99,4 @@ DocModelJauneDescription=Jaune proposal model DefaultModelPropalCreate=Default model creation DefaultModelPropalToBill=Default template when closing a business proposal (to be invoiced) DefaultModelPropalClosed=Default template when closing a business proposal (unbilled) -ProposalCustomerSignature=Written acceptance, company stamp, date and signature \ No newline at end of file +ProposalCustomerSignature=Written acceptance, company stamp, date and signature From 73f13045c13eab25a82b0f09bca3c00f81a2b100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:24:14 +0200 Subject: [PATCH 21/21] Update index.php --- htdocs/comm/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 49f618a4dd5..86f48d10817 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -127,6 +127,8 @@ if (count($listofsearchfields)) */ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { + $langs->load("propal"); + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p";