From 40bd017b20e9b67922522f6293c254b6bdc34da4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 09:10:01 +0200 Subject: [PATCH 01/41] Fix: try void phpunit error --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 39183b07f48..4510a6151ae 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -28,7 +28,7 @@ * \brief File that defines environment for Dolibarr pages only (variables not required by scripts) */ -@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP +@ini_set('memory_limit', '128M'); // This may be useless if memory is hard limited by your PHP // For optionnal tuning. Enabled if environment variable DOL_TUNING is defined. // A call first. Is the equivalent function dol_microtime_float not yet loaded. From 88fe00429e084d0b5b19a140dd76d99aae210da6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 09:24:28 +0200 Subject: [PATCH 02/41] Fix: try void phpunit error --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4510a6151ae..54ccf671c4b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -28,7 +28,7 @@ * \brief File that defines environment for Dolibarr pages only (variables not required by scripts) */ -@ini_set('memory_limit', '128M'); // This may be useless if memory is hard limited by your PHP +//@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP // For optionnal tuning. Enabled if environment variable DOL_TUNING is defined. // A call first. Is the equivalent function dol_microtime_float not yet loaded. From 5b975ca1437f09a7e9f20133b04ebdd9aecf725b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 09:35:01 +0200 Subject: [PATCH 03/41] Fix: change phpunit parameter --- test/phpunit/hudson_phpunittest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/hudson_phpunittest.xml b/test/phpunit/hudson_phpunittest.xml index 4720fa4ace8..98a793df7cb 100644 --- a/test/phpunit/hudson_phpunittest.xml +++ b/test/phpunit/hudson_phpunittest.xml @@ -9,7 +9,7 @@ colors="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false"> + syntaxCheck="true"> ../../build/ From 1c067482fc4efebb156c7cf08b7fdc4321e82b38 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 13:49:40 +0200 Subject: [PATCH 04/41] Fix: bad link --- htdocs/comm/prospect/list.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 832ea49e510..a9600493d98 100755 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2011 Philippe Grand * * This program is free software; you can redistribute it and/or modify @@ -177,16 +177,16 @@ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)"; $sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND s.client in (2, 3)"; +$sql.= " AND s.client IN (2, 3)"; $sql.= " AND s.entity = ".$conf->entity; if ($user->societe_id) $sql.= " AND s.rowid = " .$user->societe_id; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ if (isset($stcomm) && $stcomm != '') $sql.= " AND s.fk_stcomm=".$stcomm; -if ($search_nom) $sql .= " AND s.nom like '%".$db->escape(strtolower($search_nom))."%'"; -if ($search_ville) $sql .= " AND s.ville like '%".$db->escape(strtolower($search_ville))."%'"; -if ($search_departement) $sql .= " AND d.nom like '%".$db->escape(strtolower($search_departement))."%'"; +if ($search_nom) $sql .= " AND s.nom LIKE '%".$db->escape(strtolower($search_nom))."%'"; +if ($search_ville) $sql .= " AND s.ville LIKE '%".$db->escape(strtolower($search_ville))."%'"; +if ($search_departement) $sql .= " AND d.nom LIKE '%".$db->escape(strtolower($search_departement))."%'"; if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'"; // Insert levels filters if ($search_levels) @@ -205,7 +205,7 @@ if ($search_categ) } if ($socname) { - $sql .= " AND s.nom like '%".$db->escape($socname)."%'"; + $sql .= " AND s.nom LIKE '%".$db->escape($socname)."%'"; $sortfield = "s.nom"; $sortorder = "ASC"; } @@ -262,7 +262,7 @@ if ($resql) // Print the search-by-sale and search-by-categ filters - print '
'; + print ''; print ''; @@ -289,12 +289,12 @@ if ($resql) } print ''; - print_liste_field_titre($langs->trans("Company"),"prospects.php","s.nom","",$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Town"),"prospects.php","s.ville","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("State"),"prospects.php","s.fk_departement","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),"prospects.php","s.datec","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ProspectLevelShort"),"prospects.php","s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("StatusProsp"),"prospects.php","s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.ville","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("State"),$_SERVER["PHP_SELF"],"s.fk_departement","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("ProspectLevelShort"),$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("StatusProsp"),$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); print ''; print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$params,'align="right"',$sortfield,$sortorder); print "\n"; @@ -377,11 +377,11 @@ if ($resql) print $prospectstatic->getNomUrl(1,'prospect'); print ''; print ""; - print ""; + print ''; // Creation date - print ""; + print ''; // Level - print ""; // Statut @@ -395,7 +395,7 @@ if ($resql) { if ($value <> $obj->fk_stcomm) { - print ''; + print ''; print img_action(0,$value); print ' '; } From 35e2632d7b05486b8c73f538aad8a1a6a314491e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 17:24:35 +0200 Subject: [PATCH 05/41] Add markdown readme for github --- README.md | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000000..fe555903653 --- /dev/null +++ b/README.md @@ -0,0 +1,126 @@ +DOLIBARR ERP/CRM +================ + + +1. INSTALL +---------- + +If you have no technical knowledge, use Windows and you are looking for an autoinstaller to install Dolibarr ERP/CRM in few clicks, you must download DoliWamp (the all-in-one package of Dolibarr for Windows). +You can download it at: + +[Sourceforge] (http://www.dolibarr.org/downloads/cat_view/62-stable-versions) + +If you already have installed a Web server and a Mysql database, you can install this version like this: + +- Copy directory "dolibarr" and all its files inside your web server root, or copy directory anywhere and set up your web server to use "dolibarr/htdocs" as root for a new web server virtual host (second choice need to be server administrator). + +- Create an empty file "htdocs/conf/conf.php" and set permissions for your web server user (write permissions will be removed once install is finished). + +- From your browser, call the dolibarr "install/" page. + +Url depends on choice made on first step: + + http://localhost/dolibarr/htdocs/install/ +or + http://yourdolibarrvirtualhost/install/ + +- Follow instructions provided by installer... + + + +2. UPGRADE +---------- + +To upgrade Dolibarr from an old version to this one: + +- Overwrite all old files inside old 'dolibarr' directory by files provided into new version package. + +- If you came from version x.y.z to x.y.w (only third number differ), there is no need to run any migrate process. + +- If you came from a beta version or from any version x.y.z to any other where x or y number differs, you must call the Dolibarr "install/" page in your browser (this should be done automatically at first dolibarr access). + +This URL should looks like: + + http://localhost/dolibarr/htdocs/install/ +or + + http://yourdolibarrhost/install/index.php + +Then choose the "update" option according to your case. +Note: Migrate process can be ran safely several times. + + + +3. WHAT'S NEW +------------- + +See ChangeLog file. + + + +4. WHAT DOLIBARR CAN DO +----------------------- + +Main modules/features: + +- Products and services catalog +- Customers, Prospects or Suppliers directory +- Address book +- Stock management +- Bank accounts management +- Orders management with PDF export +- Commercial proposals management with PDF export +- Contracts management +- Invoices management with PDF export +- Payments management +- Standing orders management +- Shipping management +- ECM (Electronic Content Management) +- EMailings +- Agenda with ical,vcal export for third tools integration +- Management of foundation members +- Donation management + +Other modules: + +- Bookmarks management +- Can reports Dolibarr events inside Webcalendar or Phenix +- Data export tools +- LDAP connectivity +- Third parties or products categories +- ClickToDial phone numbers +- RSS + +Miscellanous: + +- Mutli-user, with several permissions levels for each feature. +- Serveral menu managers (can be used by internal users, as a back-office, + with a particular menu, or by external users, as a front-office, with + another menu and permissions). +- Very user friendly and easy to use. +- Optional WYSIWYG forms, optional Ajax forms. +- Several skins. +- Code is highly customizable (a lot of use of modules and submodules). +- Works with Mysql 3.1 or higher, experimental support for PostgreSql. +- Works with PHP 4.3 or higher. +- An easy to understand and maintain code (PHP with no heavy frameworks). +- A trigger architecture to allow you to make Dolibarr business events run + PHP code to update your own information system. +- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM + called "Non Perçue Récupérable"). + + + +5. WHAT DOLIBARR CAN'T DO YET (TODO LIST) +----------------------------------------- + +This is features that Dolibarr does not support completely yet: + +- Accountancy. +- Dolibarr can manage only one currency. +- Dolibarr does not support the double Canadian Tax. +- Dolibarr does not make coffee (not yet). +- Stock management with option increase/decrease on invoice works on + warehouse number one only (no way to choose warehouse). +- Stock management with option increase/decrease on orders works on + warehouse number one only (no way to choose warehouse). From 5199dac0755ec3cd6bb948edcbcb3b13b48d155f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 17:31:16 +0200 Subject: [PATCH 06/41] Fix: bad layout --- README.md | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index fe555903653..7421c7a1722 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ -DOLIBARR ERP/CRM -================ +## DOLIBARR ERP/CRM -1. INSTALL ----------- +# INSTALL If you have no technical knowledge, use Windows and you are looking for an autoinstaller to install Dolibarr ERP/CRM in few clicks, you must download DoliWamp (the all-in-one package of Dolibarr for Windows). You can download it at: -[Sourceforge] (http://www.dolibarr.org/downloads/cat_view/62-stable-versions) +[dolibarr.org] (http://www.dolibarr.org/downloads/cat_view/62-stable-versions) If you already have installed a Web server and a Mysql database, you can install this version like this: @@ -28,8 +26,7 @@ or -2. UPGRADE ----------- +# UPGRADE To upgrade Dolibarr from an old version to this one: @@ -51,15 +48,13 @@ Note: Migrate process can be ran safely several times. -3. WHAT'S NEW -------------- +# WHAT'S NEW See ChangeLog file. -4. WHAT DOLIBARR CAN DO ------------------------ +# WHAT DOLIBARR CAN DO Main modules/features: @@ -94,9 +89,7 @@ Other modules: Miscellanous: - Mutli-user, with several permissions levels for each feature. -- Serveral menu managers (can be used by internal users, as a back-office, - with a particular menu, or by external users, as a front-office, with - another menu and permissions). +- Serveral menu managers (can be used by internal users, as a back-office, with a particular menu, or by external users, as a front-office, with another menu and permissions). - Very user friendly and easy to use. - Optional WYSIWYG forms, optional Ajax forms. - Several skins. @@ -104,15 +97,12 @@ Miscellanous: - Works with Mysql 3.1 or higher, experimental support for PostgreSql. - Works with PHP 4.3 or higher. - An easy to understand and maintain code (PHP with no heavy frameworks). -- A trigger architecture to allow you to make Dolibarr business events run - PHP code to update your own information system. -- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM - called "Non Perçue Récupérable"). +- A trigger architecture to allow you to make Dolibarr business events run PHP code to update your own information system. +- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM called "Non Perçue Récupérable"). -5. WHAT DOLIBARR CAN'T DO YET (TODO LIST) ------------------------------------------ +# WHAT DOLIBARR CAN'T DO YET (TODO LIST) This is features that Dolibarr does not support completely yet: @@ -120,7 +110,5 @@ This is features that Dolibarr does not support completely yet: - Dolibarr can manage only one currency. - Dolibarr does not support the double Canadian Tax. - Dolibarr does not make coffee (not yet). -- Stock management with option increase/decrease on invoice works on - warehouse number one only (no way to choose warehouse). -- Stock management with option increase/decrease on orders works on - warehouse number one only (no way to choose warehouse). +- Stock management with option increase/decrease on invoice works on warehouse number one only (no way to choose warehouse). +- Stock management with option increase/decrease on orders works on warehouse number one only (no way to choose warehouse). From ef6509fd9e8d90e71c1f3d8b29db18f59d734be2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 17:34:32 +0200 Subject: [PATCH 07/41] Fix: bad layout --- README.md | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index fe555903653..47ecd563dba 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ -DOLIBARR ERP/CRM -================ +# DOLIBARR ERP/CRM -1. INSTALL ----------- +## INSTALL If you have no technical knowledge, use Windows and you are looking for an autoinstaller to install Dolibarr ERP/CRM in few clicks, you must download DoliWamp (the all-in-one package of Dolibarr for Windows). You can download it at: -[Sourceforge] (http://www.dolibarr.org/downloads/cat_view/62-stable-versions) +[dolibarr.org] (http://www.dolibarr.org/downloads/cat_view/62-stable-versions) If you already have installed a Web server and a Mysql database, you can install this version like this: @@ -22,14 +20,14 @@ Url depends on choice made on first step: http://localhost/dolibarr/htdocs/install/ or + http://yourdolibarrvirtualhost/install/ - Follow instructions provided by installer... -2. UPGRADE ----------- +## UPGRADE To upgrade Dolibarr from an old version to this one: @@ -51,17 +49,15 @@ Note: Migrate process can be ran safely several times. -3. WHAT'S NEW -------------- +## WHAT'S NEW See ChangeLog file. -4. WHAT DOLIBARR CAN DO ------------------------ +## WHAT DOLIBARR CAN DO -Main modules/features: +### Main modules/features: - Products and services catalog - Customers, Prospects or Suppliers directory @@ -81,7 +77,7 @@ Main modules/features: - Management of foundation members - Donation management -Other modules: +### Other modules: - Bookmarks management - Can reports Dolibarr events inside Webcalendar or Phenix @@ -91,12 +87,10 @@ Other modules: - ClickToDial phone numbers - RSS -Miscellanous: +### Miscellanous: - Mutli-user, with several permissions levels for each feature. -- Serveral menu managers (can be used by internal users, as a back-office, - with a particular menu, or by external users, as a front-office, with - another menu and permissions). +- Serveral menu managers (can be used by internal users, as a back-office, with a particular menu, or by external users, as a front-office, with another menu and permissions). - Very user friendly and easy to use. - Optional WYSIWYG forms, optional Ajax forms. - Several skins. @@ -104,15 +98,12 @@ Miscellanous: - Works with Mysql 3.1 or higher, experimental support for PostgreSql. - Works with PHP 4.3 or higher. - An easy to understand and maintain code (PHP with no heavy frameworks). -- A trigger architecture to allow you to make Dolibarr business events run - PHP code to update your own information system. -- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM - called "Non Perçue Récupérable"). +- A trigger architecture to allow you to make Dolibarr business events run PHP code to update your own information system. +- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM called "Non Perçue Récupérable"). -5. WHAT DOLIBARR CAN'T DO YET (TODO LIST) ------------------------------------------ +## WHAT DOLIBARR CAN'T DO YET (TODO LIST) This is features that Dolibarr does not support completely yet: @@ -120,7 +111,5 @@ This is features that Dolibarr does not support completely yet: - Dolibarr can manage only one currency. - Dolibarr does not support the double Canadian Tax. - Dolibarr does not make coffee (not yet). -- Stock management with option increase/decrease on invoice works on - warehouse number one only (no way to choose warehouse). -- Stock management with option increase/decrease on orders works on - warehouse number one only (no way to choose warehouse). +- Stock management with option increase/decrease on invoice works on warehouse number one only (no way to choose warehouse). +- Stock management with option increase/decrease on orders works on warehouse number one only (no way to choose warehouse). From 1404bfec1747e839a20c37de92df1f6d6575a45d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 17:46:55 +0200 Subject: [PATCH 08/41] Fix: bad link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bfa5163e14..0a1b84f5fd2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ If you have no technical knowledge, use Windows and you are looking for an autoinstaller to install Dolibarr ERP/CRM in few clicks, you must download DoliWamp (the all-in-one package of Dolibarr for Windows). -You can download it at: [www.dolibarr.org] (http://www.dolibarr.org/downloads/cat_view/62-stable-versions) +You can download it at: [Official Website] (http://www.dolibarr.org/downloads/cat_view/62-stable-versions) If you already have installed a Web server and a Mysql database, you can install this version like this: From 00a032ad686da7ea0ddca61f8fa341dd22c15eda Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Sep 2011 17:49:42 +0200 Subject: [PATCH 09/41] Fix: add description --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0a1b84f5fd2..66521f53db8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # DOLIBARR ERP/CRM +Dolibarr ERP/CRM is a modern software to manage your company or foundation activity (contacts, suppliers, invoices, orders, stocks, agenda, ...).It's an opensource software (wrote with PHP language) designed for small and medium companies, foundation and freelances. You can freely install, use and distribute it as a standalone application or as a web application to use it from every internet access and media. + ## INSTALL From c1f5b2f3a196f1480ec06d9d4f5df3ad757e5bc6 Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 01:29:43 +0200 Subject: [PATCH 10/41] Fix: Bad var name --- htdocs/product/canvas/product/actions_card_product.class.php | 2 +- htdocs/product/canvas/service/actions_card_service.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 3a04e75c43e..2038024887d 100755 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -79,7 +79,7 @@ class ActionsCardProduct extends Product $tmpobject = new Product($this->db); if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref); - $this->object = $object; + $this->object = $tmpobject; //parent::assign_values($action); diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 42003219528..591e220c22b 100755 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -78,7 +78,7 @@ class ActionsCardService extends Product $tmpobject = new Product($this->db); if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref); - $this->object = $object; + $this->object = $tmpobject; //parent::assign_values($action); From f70b1894dbff1e42c16ddf5658cea285cf4abff8 Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 01:30:32 +0200 Subject: [PATCH 11/41] Work on product webservice --- htdocs/product/class/product.class.php | 25 +- htdocs/webservices/admin/webservices.php | 10 + .../demo_wsclient_productorservice.php | 140 ++++++++++ htdocs/webservices/server_invoice.php | 94 ++++--- htdocs/webservices/server_other.php | 35 +-- .../webservices/server_productorservice.php | 221 ++++++++++++++++ .../webservices/server_supplier_invoice.php | 92 ++++--- htdocs/webservices/server_thirdparty.php | 140 +++++----- test/phpunit/ProductTest.php | 250 ++++++++++++++++++ 9 files changed, 828 insertions(+), 179 deletions(-) create mode 100755 htdocs/webservices/demo_wsclient_productorservice.php create mode 100755 htdocs/webservices/server_productorservice.php create mode 100755 test/phpunit/ProductTest.php diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ec4cc4b49aa..b4ed55e0e72 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -124,6 +124,10 @@ class Product extends CommonObject //! Canevas a utiliser si le produit n'est pas un produit generique var $canvas; + var $import_key; + var $date_creation; + var $date_modification; + //! Id du fournisseur var $product_fourn_id; @@ -997,21 +1001,21 @@ class Product extends CommonObject /** * Load a product in memory from database * - * @param id Id of product/service to load - * @param ref Ref of product/service to load - * @return int <0 if KO, >0 if OK + * @param int $id Id of product/service to load + * @param string $ref Ref of product/service to load + * @param string $ref_ext Ref ext of product/service to load + * @return int <0 if KO, >0 if OK */ - function fetch($id='',$ref='') + function fetch($id='',$ref='',$ref_ext='') { include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php'); - global $langs; - global $conf; + global $langs, $conf; - dol_syslog("Product::fetch id=$id ref=$ref"); + dol_syslog("Product::fetch id=$id ref=$ref ref_ext=$ref_ext"); // Check parameters - if (! $id && ! $ref) + if (! $id && ! $ref && ! $ref_ext) { $this->error=$langs->trans('ErrorWrongParameters'); dol_print_error("Product::fetch ".$this->error, LOG_ERR); @@ -1023,10 +1027,11 @@ class Product extends CommonObject $sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,"; $sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; $sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,"; - $sql.= " import_key"; + $sql.= " datec, tms, import_key"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; if ($id) $sql.= " WHERE rowid = '".$id."'"; else if ($ref) $sql.= " WHERE ref = '".$this->db->escape($ref)."'"; + else if ($ref_ext) $sql.= " WHERE ref_ext = '".$this->db->escape($ref_ext)."'"; dol_syslog("Product::fetch sql=".$sql); $resql = $this->db->query($sql); @@ -1083,6 +1088,8 @@ class Product extends CommonObject $this->stock_reel = $object->stock; $this->pmp = $object->pmp; + $this->date_creation = $object->datec; + $this->date_modification = $object->tms; $this->import_key = $object->import_key; $this->db->free($resql); diff --git a/htdocs/webservices/admin/webservices.php b/htdocs/webservices/admin/webservices.php index 128b13106e6..b70281734b8 100644 --- a/htdocs/webservices/admin/webservices.php +++ b/htdocs/webservices/admin/webservices.php @@ -101,6 +101,11 @@ print '

'; print ''.$langs->trans("WSDLCanBeDownloadedHere").':
'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php?wsdl'; print img_picto('','object_globe.png').' '.''.$url."
\n"; +if ($conf->product->enabled || $conf->service->enabled) +{ + $url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php?wsdl'; + print img_picto('','object_globe.png').' '.''.$url."
\n"; +} if ($conf->societe->enabled) { $url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php?wsdl'; @@ -123,6 +128,11 @@ print '
'; print ''.$langs->trans("EndPointIs").':
'; $url=DOL_MAIN_URL_ROOT.'/webservices/server_other.php'; print img_picto('','object_globe.png').' '.''.$url."
\n"; +if ($conf->product->enabled || $conf->service->enabled) +{ + $url=DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; + print img_picto('','object_globe.png').' '.''.$url."
\n"; +} if ($conf->societe->enabled) { $url=DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php'; diff --git a/htdocs/webservices/demo_wsclient_productorservice.php b/htdocs/webservices/demo_wsclient_productorservice.php new file mode 100755 index 00000000000..a7f1c1e7a1e --- /dev/null +++ b/htdocs/webservices/demo_wsclient_productorservice.php @@ -0,0 +1,140 @@ + + * + * 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 2 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 . + */ + +/** + * \file htdocs/webservices/demo_wsclient_productorservice.php + * \brief Demo page to make a client call to Dolibarr WebServices "server_product" + */ + +// This is to make Dolibarr working with Plesk +set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); + +require_once("../master.inc.php"); +require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP + +$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_productorservice.php'; +//$WS_DOL_URL = 'http://localhost:8080/'; // To test with Soapui mock. If not a page, should end with / +$WS_METHOD1 = 'createProductOrService'; +$WS_METHOD2 = 'getProductOrService'; +$ns='http://www.dolibarr.org/ns/'; + + +// Set the WebService URL +dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL); +$soapclient1 = new nusoap_client($WS_DOL_URL); +if ($soapclient1) +{ + $soapclient1->soap_defencoding='UTF-8'; + $soapclient1->decodeUTF8(false); +} +$soapclient2 = new nusoap_client($WS_DOL_URL); +if ($soapclient2) +{ + $soapclient2->soap_defencoding='UTF-8'; + $soapclient2->decodeUTF8(false); +} + +// Call the WebService method and store its result in $result. +$authentication=array( + 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, + 'sourceapplication'=>'DEMO', + 'login'=>'admin', + 'password'=>'changeme', + 'entity'=>''); + + +// Test url 1 +if ($WS_METHOD1) +{ + $parameters = array('authentication'=>$authentication,'id'=>1,'ref'=>''); + dol_syslog("Call method ".$WS_METHOD1); + $result1 = $soapclient1->call($WS_METHOD1,$parameters,$ns,''); + if (! $result1) + { + print $soapclient1->error_str; + print "
\n\n"; + print $soapclient1->request; + print "
\n\n"; + print $soapclient1->response; + exit; + } +} + +// Test url 2 +if ($WS_METHOD2) +{ + $parameters = array('authentication'=>$authentication,'id'=>1,'ref'=>''); + dol_syslog("Call method ".$WS_METHOD2); + $result2 = $soapclient1->call($WS_METHOD2,$parameters,$ns,''); + if (! $result2) + { + print $soapclient1->error_str; + print "
\n\n"; + print $soapclient1->request; + print "
\n\n"; + print $soapclient1->response; + exit; + } +} + + +/* + * View + */ + +header("Content-type: text/html; charset=utf8"); +print ''."\n"; +echo ''."\n"; +echo ''; +echo 'WebService Test: '.$WS_METHOD1.''; +echo ''."\n"; + +echo ''."\n"; + +echo "

Request:

"; +echo '

Function

'; +echo $WS_METHOD1; +echo '

SOAP Message

'; +echo '
' . htmlspecialchars($soapclient1->request, ENT_QUOTES) . '
'; +echo '
'; +echo "

Response:

"; +echo '

Result

'; +echo '
';
+print_r($result1);
+echo '
'; +echo '

SOAP Message

'; +echo '
' . htmlspecialchars($soapclient1->response, ENT_QUOTES) . '
'; + +print '
'; + +echo "

Request:

"; +echo '

Function

'; +echo $WS_METHOD2; +echo '

SOAP Message

'; +echo '
' . htmlspecialchars($soapclient2->request, ENT_QUOTES) . '
'; +echo '
'; +echo "

Response:

"; +echo '

Result

'; +echo '
';
+print_r($result2);
+echo '
'; +echo '

SOAP Message

'; +echo '
' . htmlspecialchars($soapclient2->response, ENT_QUOTES) . '
'; + +echo ''."\n";; +echo ''."\n";; +?> diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index c43dc993d62..030b8c234a2 100755 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -52,7 +52,7 @@ $server->configureWSDL('WebServicesDolibarrInvoice',$ns); $server->wsdl->schemaTargetNamespace=$ns; -// Define WSDL content +// Define WSDL Authentication object $server->wsdl->addComplexType( 'authentication', 'complexType', @@ -67,7 +67,20 @@ $server->wsdl->addComplexType( 'entity' => array('name'=>'entity','type'=>'xsd:string'), ) ); +// Define WSDL Return object +$server->wsdl->addComplexType( + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), + ) +); +// Define other specific objects $server->wsdl->addComplexType( 'line', 'complexType', @@ -183,19 +196,6 @@ $server->wsdl->addComplexType( ); -$server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), - ) -); - - // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped // Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model. @@ -205,43 +205,49 @@ $styleuse='encoded'; // encoded/literal/literal wrapped // Better choice is document/literal wrapped but literal wrapped not supported by nusoap. // Register WSDL -$server->register('getInvoice', -// Entry values -array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'), -// Exit values -array('result'=>'tns:result','invoice'=>'tns:invoice'), -$ns, -$ns.'#getInvoice', -$styledoc, -$styleuse, -'WS to get a particular invoice' +$server->register( + 'getInvoice', + // Entry values + array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'), + // Exit values + array('result'=>'tns:result','invoice'=>'tns:invoice'), + $ns, + $ns.'#getInvoice', + $styledoc, + $styleuse, + 'WS to get a particular invoice' ); -$server->register('getInvoicesForThirdParty', -// Entry values -array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'), -// Exit values -array('result'=>'tns:result','invoices'=>'tns:InvoicesArray2'), -$ns, -$ns.'#getInvoicesForThirdParty', -$styledoc, -$styleuse, -'WS to get all invoices of a third party' +$server->register( + 'getInvoicesForThirdParty', + // Entry values + array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'), + // Exit values + array('result'=>'tns:result','invoices'=>'tns:InvoicesArray2'), + $ns, + $ns.'#getInvoicesForThirdParty', + $styledoc, + $styleuse, + 'WS to get all invoices of a third party' ); -$server->register('createInvoice', -// Entry values -array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'), -// Exit values -array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'), -$ns, -$ns.'#createInvoice', -$styledoc, -$styleuse, -'WS to create an invoice' +$server->register( + 'createInvoice', + // Entry values + array('authentication'=>'tns:authentication','invoice'=>'tns:invoice'), + // Exit values + array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'), + $ns, + $ns.'#createInvoice', + $styledoc, + $styleuse, + 'WS to create an invoice' ); /** * Get invoice from id, ref or ref_ext + * + * @param object $authentication + * */ function getInvoice($authentication,$id='',$ref='',$ref_ext='') { diff --git a/htdocs/webservices/server_other.php b/htdocs/webservices/server_other.php index 53ab2e9b168..a12db69dcfd 100644 --- a/htdocs/webservices/server_other.php +++ b/htdocs/webservices/server_other.php @@ -52,21 +52,22 @@ $server->configureWSDL('WebServicesDolibarrOther',$ns); $server->wsdl->schemaTargetNamespace=$ns; -// Define WSDL content +// Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'), - 'login' => array('name'=>'login','type'=>'xsd:string'), - 'password' => array('name'=>'password','type'=>'xsd:string'), - 'entity' => array('name'=>'entity','type'=>'xsd:string'), - )); - + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'), + 'login' => array('name'=>'login','type'=>'xsd:string'), + 'password' => array('name'=>'password','type'=>'xsd:string'), + 'entity' => array('name'=>'entity','type'=>'xsd:string'), + ) +); +// Define WSDL Return object $server->wsdl->addComplexType( 'result', 'complexType', @@ -76,7 +77,11 @@ $server->wsdl->addComplexType( array( 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), - )); + ) +); + +// Define other specific objects +// None // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php new file mode 100755 index 00000000000..59676e34395 --- /dev/null +++ b/htdocs/webservices/server_productorservice.php @@ -0,0 +1,221 @@ + + * + * 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 2 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 . + */ + +/** + * \file htdocs/webservices/server_productorservice.php + * \brief File that is entry point to call Dolibarr WebServices + */ + +// This is to make Dolibarr working with Plesk +set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); + +require_once("../master.inc.php"); +require_once(NUSOAP_PATH.'/nusoap.php'); // Include SOAP +require_once(DOL_DOCUMENT_ROOT."/lib/ws.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); + +require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); + + +dol_syslog("Call Dolibarr webservices interfaces"); + +// Enable and test if module web services is enabled +if (empty($conf->global->MAIN_MODULE_WEBSERVICES)) +{ + $langs->load("admin"); + dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled"); + print $langs->trans("WarningModuleNotActive",'WebServices').'.

'; + print $langs->trans("ToActivateModule"); + exit; +} + +// Create the soap Object +$server = new nusoap_server(); +$server->soap_defencoding='UTF-8'; +$server->decode_utf8=false; +$ns='http://www.dolibarr.org/ns/'; +$server->configureWSDL('WebServicesDolibarrProductOrService',$ns); +$server->wsdl->schemaTargetNamespace=$ns; + + +// Define WSDL Authentication object +$server->wsdl->addComplexType( + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'), + 'login' => array('name'=>'login','type'=>'xsd:string'), + 'password' => array('name'=>'password','type'=>'xsd:string'), + 'entity' => array('name'=>'entity','type'=>'xsd:string'), + ) +); +// Define WSDL Return object +$server->wsdl->addComplexType( + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), + ) +); + +// Define other specific objects +$server->wsdl->addComplexType( + 'product', + 'complexType', + 'struct', + 'all', + '', + array( + 'id' => array('name'=>'id','type'=>'xsd:string'), + 'ref' => array('name'=>'name','type'=>'xsd:string'), + 'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'), + 'label' => array('name'=>'label','type'=>'xsd:string'), + 'description' => array('name'=>'description','type'=>'xsd:string'), + 'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'), + 'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'), + 'note' => array('name'=>'note','type'=>'xsd:string'), + 'tobuy' => array('name'=>'tobuy','type'=>'xsd:string'), + 'tosell' => array('name'=>'tosell','type'=>'xsd:string'), + 'type' => array('name'=>'type','type'=>'xsd:string'), + 'barcode' => array('name'=>'barcode','type'=>'xsd:string'), + 'country_id' => array('name'=>'country_id','type'=>'xsd:string') + ) +); + + + +// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped +// Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model. +// http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/ +$styledoc='rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages) +$styleuse='encoded'; // encoded/literal/literal wrapped +// Better choice is document/literal wrapped but literal wrapped not supported by nusoap. + +// Register WSDL +$server->register( + 'createProductOrService', + // Entry values + array('authentication'=>'tns:authentication','product'=>'tns:product'), + // Exit values + array('result'=>'tns:result','id'=>'xsd:string'), + $ns, + $ns.'#createProductOrService', + $styledoc, + $styleuse, + 'WS to create a product or service' +); + +// Register WSDL +$server->register( + 'getProductOrService', + // Entry values + array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'), + // Exit values + array('result'=>'tns:result','product'=>'tns:product'), + $ns, + $ns.'#getProductOrService', + $styledoc, + $styleuse, + 'WS to get product or service' +); + + +// Full methods code +function getProductOrService($authentication,$id='',$ref='',$ref_ext='') +{ + global $db,$conf,$langs; + + dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); + + if ($authentication['entity']) $conf->entity=$authentication['entity']; + + // Init and check authentication + $objectresp=array(); + $errorcode='';$errorlabel=''; + $error=0; + $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); + // Check parameters + if (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) + { + $error++; + $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both."; + } + + if (! $error) + { + $fuser->getrights(); + + if ($fuser->rights->produit->lire || $fuser->rights->service->lire) + { + $product=new Product($db); + $result=$product->fetch($id,$ref,$ref_ext); + if ($result > 0) + { + // Create + $objectresp = array( + 'result'=>array('result_code'=>'OK', 'result_label'=>''), + 'product'=>array( + 'id' => $product->id, + 'ref' => $product->name, + 'ref_ext' => $product->ref_ext, + 'label' => $product->label, + 'description' => $product->description, + 'date_creation' => $product->date_creation, + 'date_modification' => $product->date_modification, + 'note' => $product->note, + 'tobuy' => $product->tobuy, + 'tosell' => $product->tosell, + 'type' => $product->type, + 'barcode' => $product->barcode, + 'country_id' => $product->country_id + )); + } + else + { + $error++; + $errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; + } + } + else + { + $error++; + $errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request'; + } + } + + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } + + return $objectresp; +} + + + +// Return the results. +$server->service($HTTP_RAW_POST_DATA); + +?> diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index 66ccf0c59ac..8f65042c3da 100755 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -52,21 +52,35 @@ $server->configureWSDL('WebServicesDolibarrSupplierInvoice',$ns); $server->wsdl->schemaTargetNamespace=$ns; -// Define WSDL content +// Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'), - 'login' => array('name'=>'login','type'=>'xsd:string'), - 'password' => array('name'=>'password','type'=>'xsd:string'), - 'entity' => array('name'=>'entity','type'=>'xsd:string'), - )); + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'), + 'login' => array('name'=>'login','type'=>'xsd:string'), + 'password' => array('name'=>'password','type'=>'xsd:string'), + 'entity' => array('name'=>'entity','type'=>'xsd:string'), + ) +); +// Define WSDL Return object +$server->wsdl->addComplexType( + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), + ) +); +// Define other specific objects $server->wsdl->addComplexType( 'line', 'element', @@ -163,16 +177,6 @@ $server->wsdl->addComplexType( 'tns:invoice' ); -$server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), - )); // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped @@ -183,27 +187,29 @@ $styleuse='encoded'; // encoded/literal/literal wrapped // Better choice is document/literal wrapped but literal wrapped not supported by nusoap. // Register WSDL -$server->register('getSupplierInvoice', -// Entry values -array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'), -// Exit values -array('result'=>'tns:result','invoice'=>'tns:invoice'), -$ns, -$ns.'#getSupplierInvoice', -$styledoc, -$styleuse, -'WS to get SupplierInvoice' +$server->register( + 'getSupplierInvoice', + // Entry values + array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'), + // Exit values + array('result'=>'tns:result','invoice'=>'tns:invoice'), + $ns, + $ns.'#getSupplierInvoice', + $styledoc, + $styleuse, + 'WS to get SupplierInvoice' ); -$server->register('getSupplierInvoicesForThirdParty', -// Entry values -array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'), -// Exit values -array('result'=>'tns:result','invoices'=>'tns:invoices'), -$ns, -$ns.'#getSupplierInvoicesForThirdParty', -$styledoc, -$styleuse, -'WS to get SupplierInvoicesForThirdParty' +$server->register( + 'getSupplierInvoicesForThirdParty', + // Entry values + array('authentication'=>'tns:authentication','idthirdparty'=>'xsd:string'), + // Exit values + array('result'=>'tns:result','invoices'=>'tns:invoices'), + $ns, + $ns.'#getSupplierInvoicesForThirdParty', + $styledoc, + $styleuse, + 'WS to get SupplierInvoicesForThirdParty' ); diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 051388b7f01..2187f345b5e 100755 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -52,67 +52,70 @@ $server->configureWSDL('WebServicesDolibarrThirdParty',$ns); $server->wsdl->schemaTargetNamespace=$ns; -// Define WSDL content +// Define WSDL Authentication object $server->wsdl->addComplexType( - 'authentication', - 'complexType', - 'struct', - 'all', - '', - array( - 'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'), - 'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'), - 'login' => array('name'=>'login','type'=>'xsd:string'), - 'password' => array('name'=>'password','type'=>'xsd:string'), - 'entity' => array('name'=>'entity','type'=>'xsd:string'), - )); + 'authentication', + 'complexType', + 'struct', + 'all', + '', + array( + 'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'), + 'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'), + 'login' => array('name'=>'login','type'=>'xsd:string'), + 'password' => array('name'=>'password','type'=>'xsd:string'), + 'entity' => array('name'=>'entity','type'=>'xsd:string'), + ) +); +// Define WSDL Return object +$server->wsdl->addComplexType( + 'result', + 'complexType', + 'struct', + 'all', + '', + array( + 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), + 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), + ) +); +// Define other specific objects $server->wsdl->addComplexType( - 'thirdparty', - 'complexType', - 'struct', - 'all', - '', - array( - 'id' => array('name'=>'id','type'=>'xsd:string'), - 'ref' => array('name'=>'name','type'=>'xsd:string'), - 'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'), - 'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'), - 'date' => array('name'=>'date','type'=>'xsd:date'), - 'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'), - 'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'), - 'note' => array('name'=>'note','type'=>'xsd:string'), - 'address' => array('name'=>'address','type'=>'xsd:string'), - 'zip' => array('name'=>'zip','type'=>'xsd:string'), - 'town' => array('name'=>'town','type'=>'xsd:string'), - 'province_id' => array('name'=>'province_id','type'=>'xsd:string'), - 'country_id' => array('name'=>'country_id','type'=>'xsd:string'), - 'country_code' => array('name'=>'country_code','type'=>'xsd:string'), - 'country' => array('name'=>'country','type'=>'xsd:string'), - 'phone' => array('name'=>'country_id','type'=>'xsd:string'), - 'fax' => array('name'=>'country_id','type'=>'xsd:string'), - 'email' => array('name'=>'country_id','type'=>'xsd:string'), - 'url' => array('name'=>'country_id','type'=>'xsd:string'), - 'profid1' => array('name'=>'profid1','type'=>'xsd:string'), - 'profid2' => array('name'=>'profid2','type'=>'xsd:string'), - 'profid3' => array('name'=>'profid3','type'=>'xsd:string'), - 'profid4' => array('name'=>'profid4','type'=>'xsd:string'), - 'prefix' => array('name'=>'prefix','type'=>'xsd:string'), - 'vat_used' => array('name'=>'vat_used','type'=>'xsd:string'), - 'vat_number' => array('name'=>'vat_number','type'=>'xsd:string') - ) - ); - -$server->wsdl->addComplexType( - 'result', - 'complexType', - 'struct', - 'all', - '', - array( - 'result_code' => array('name'=>'result_code','type'=>'xsd:string'), - 'result_label' => array('name'=>'result_label','type'=>'xsd:string'), - )); + 'thirdparty', + 'complexType', + 'struct', + 'all', + '', + array( + 'id' => array('name'=>'id','type'=>'xsd:string'), + 'ref' => array('name'=>'name','type'=>'xsd:string'), + 'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'), + 'fk_user_author' => array('name'=>'fk_user_author','type'=>'xsd:string'), + 'date' => array('name'=>'date','type'=>'xsd:date'), + 'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'), + 'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'), + 'note' => array('name'=>'note','type'=>'xsd:string'), + 'address' => array('name'=>'address','type'=>'xsd:string'), + 'zip' => array('name'=>'zip','type'=>'xsd:string'), + 'town' => array('name'=>'town','type'=>'xsd:string'), + 'province_id' => array('name'=>'province_id','type'=>'xsd:string'), + 'country_id' => array('name'=>'country_id','type'=>'xsd:string'), + 'country_code' => array('name'=>'country_code','type'=>'xsd:string'), + 'country' => array('name'=>'country','type'=>'xsd:string'), + 'phone' => array('name'=>'country_id','type'=>'xsd:string'), + 'fax' => array('name'=>'country_id','type'=>'xsd:string'), + 'email' => array('name'=>'country_id','type'=>'xsd:string'), + 'url' => array('name'=>'country_id','type'=>'xsd:string'), + 'profid1' => array('name'=>'profid1','type'=>'xsd:string'), + 'profid2' => array('name'=>'profid2','type'=>'xsd:string'), + 'profid3' => array('name'=>'profid3','type'=>'xsd:string'), + 'profid4' => array('name'=>'profid4','type'=>'xsd:string'), + 'prefix' => array('name'=>'prefix','type'=>'xsd:string'), + 'vat_used' => array('name'=>'vat_used','type'=>'xsd:string'), + 'vat_number' => array('name'=>'vat_number','type'=>'xsd:string') + ) +); // 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped @@ -123,16 +126,17 @@ $styleuse='encoded'; // encoded/literal/literal wrapped // Better choice is document/literal wrapped but literal wrapped not supported by nusoap. // Register WSDL -$server->register('getThirdParty', -// Entry values -array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'), -// Exit values -array('result'=>'tns:result','thirdparty'=>'tns:thirdparty'), -$ns, -$ns.'#getVersions', -$styledoc, -$styleuse, -'WS to get Versions' +$server->register( + 'getThirdParty', + // Entry values + array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'), + // Exit values + array('result'=>'tns:result','thirdparty'=>'tns:thirdparty'), + $ns, + $ns.'#getVersions', + $styledoc, + $styleuse, + 'WS to get Versions' ); diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php new file mode 100755 index 00000000000..ae83bfa229a --- /dev/null +++ b/test/phpunit/ProductTest.php @@ -0,0 +1,250 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file test/phpunit/ProductTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/product/class/product.class.php'; + +if (empty($user->id)) +{ + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class ProductTest extends PHPUnit_Framework_TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return ProductTest + */ + function ProductTest() + { + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; + } + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + } + /** + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + /** + */ + public function testProductCreate() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Product($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user); + + print __METHOD__." result=".$result."\n"; + $this->assertLessThanOrEqual($result, 0); + + return $result; + } + + /** + * @depends testProductCreate + * The depends says test is run only if previous is ok + */ + public function testProductFetch($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Product($this->savdb); + $result=$localobject->fetch($id); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + $result=$localobject->verify(); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertEquals($result, 0); + + return $localobject; + } + + /** + * @depends testProductFetch + * The depends says test is run only if previous is ok + */ + public function testProductUpdate($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject->note='New note after update'; + $result=$localobject->update($localobject->id,$user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + return $localobject; + } + + /** + * @depends testProductUpdate + * The depends says test is run only if previous is ok + */ + public function testProductOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + + return $localobject->id; + } + + /** + * @depends testProductOther + * The depends says test is run only if previous is ok + */ + public function testProductDelete($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Product($this->savdb); + $result=$localobject->fetch($id); + + $result=$localobject->delete($id); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + return $result; + } + + /** + * + */ + /*public function testVerifyNumRef() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Adherent($this->savdb); + $result=$localobject->ref='refthatdoesnotexists'; + $result=$localobject->VerifyNumRef(); + + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, 0); + return $result; + }*/ + + + /** + */ + public function testProductStatic() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Product($db); + + + return; + } +} +?> \ No newline at end of file From b2d635dab793a84c904e47ce3ae0d194366d3644 Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 01:40:15 +0200 Subject: [PATCH 12/41] Qual: More PHPUnit tests --- htdocs/product/class/product.class.php | 25 +++++++++++++++++++++++++ test/phpunit/AllTests.php | 3 +++ test/phpunit/ProductTest.php | 4 ---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b4ed55e0e72..fbf38befc79 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2912,5 +2912,30 @@ class Product extends CommonObject } } + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + function initAsSpecimen() + { + global $user,$langs,$conf,$mysoc; + + $now=dol_now(); + + // Initialize parameters + $this->id=0; + $this->ref = 'PRODUCT_SPEC'; + $this->libelle = 'PRODUCT SPECIMEN'; + $this->description = 'PRODUCT SPECIMEN '.dol_print_date($now,'dayhourlog'); + $this->specimen=1; + $this->country_id=1; + $this->tosell=1; + $this->tobuy=1; + $this->type=0; + $this->note='This is a comment (private)'; + } } ?> \ No newline at end of file diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index cc9921a0480..864315d3c86 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -75,6 +75,9 @@ class AllTests require_once dirname(__FILE__).'/DiscountTest.php'; $suite->addTestSuite('DiscountTest'); + require_once dirname(__FILE__).'/ProductTest.php'; + $suite->addTestSuite('ProductTest'); + require_once dirname(__FILE__).'/CommandeTest.php'; $suite->addTestSuite('CommandeTest'); require_once dirname(__FILE__).'/CommandeFournisseurTest.php'; diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index ae83bfa229a..353b19dfc06 100755 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -145,10 +145,6 @@ class ProductTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); - $result=$localobject->verify(); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertEquals($result, 0); - return $localobject; } From be01d88e2d8ace3659b13c3c798708647b6ba830 Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 12:48:31 +0200 Subject: [PATCH 13/41] Qual: Removed warning Look: Uniformize code --- htdocs/product/fiche.php | 2358 +++++++++++++++--------------- htdocs/product/liste.php | 4 +- htdocs/product/stock/product.php | 11 +- 3 files changed, 1191 insertions(+), 1182 deletions(-) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 904a4182f4c..7f1621651df 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -43,7 +43,7 @@ $langs->load("other"); if ($conf->stock->enabled) $langs->load("stocks"); if ($conf->facture->enabled) $langs->load("bills"); -$mesg = ''; $error=0; $errors=array(); +$mesg=''; $error=0; $errors=array(); $id=GETPOST('id'); $ref=GETPOST('ref'); @@ -89,393 +89,394 @@ if (empty($reshook)) { if ($action == 'setproductaccountancycodebuy') { - $product = new Product($db); - $result=$product->fetch($id,$ref); - $product->accountancy_code_buy=$_POST["productaccountancycodebuy"]; - $result=$product->update($product->id,$user,1,0,1); - if ($result < 0) - { - $mesg=join(',',$product->errors); - } - $action=""; - $id=$_POST["id"]; - $_GET["id"]=$_POST["id"]; + $product = new Product($db); + $result=$product->fetch($id,$ref); + $product->accountancy_code_buy=$_POST["productaccountancycodebuy"]; + $result=$product->update($product->id,$user,1,0,1); + if ($result < 0) + { + $mesg=join(',',$product->errors); + } + $action=""; + $id=$_POST["id"]; + $_GET["id"]=$_POST["id"]; } if ($action == 'setproductaccountancycodesell') { - $product = new Product($db); - $result=$product->fetch($id,$ref); - $product->accountancy_code_sell=$_POST["productaccountancycodesell"]; - $result=$product->update($product->id,$user,1,0,1); - if ($result < 0) - { - $mesg=join(',',$product->errors); - } - $action=""; + $product = new Product($db); + $result=$product->fetch($id,$ref); + $product->accountancy_code_sell=$_POST["productaccountancycodesell"]; + $result=$product->update($product->id,$user,1,0,1); + if ($result < 0) + { + $mesg=join(',',$product->errors); + } + $action=""; } if ($action == 'fastappro') { - $product = new Product($db); - $result=$product->fetch($id,$ref); - $result=$product->fastappro($user); - Header("Location: fiche.php?id=".$product->id); - exit; + $product = new Product($db); + $result=$product->fetch($id,$ref); + $result=$product->fastappro($user); + Header("Location: fiche.php?id=".$product->id); + exit; } // Add a product or service if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer)) { - $error=0; + $error=0; - if (empty($_POST["libelle"])) - { - $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'
'; - $action = "create"; - $_GET["canvas"] = $_POST["canvas"]; - $_GET["type"] = $_POST["type"]; - $error++; - } - if (empty($ref)) - { - $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
'; - $action = "create"; - $_GET["canvas"] = $_POST["canvas"]; - $_GET["type"] = $_POST["type"]; - $error++; - } + if (empty($_POST["libelle"])) + { + $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'
'; + $action = "create"; + $_GET["canvas"] = $_POST["canvas"]; + $_GET["type"] = $_POST["type"]; + $error++; + } + if (empty($ref)) + { + $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
'; + $action = "create"; + $_GET["canvas"] = $_POST["canvas"]; + $_GET["type"] = $_POST["type"]; + $error++; + } - $product=new Product($db); + $product=new Product($db); - if (! $error) - { - $product->ref = $ref; - $product->libelle = $_POST["libelle"]; - $product->price_base_type = $_POST["price_base_type"]; - if ($product->price_base_type == 'TTC') $product->price_ttc = $_POST["price"]; - else $product->price = $_POST["price"]; - if ($product->price_base_type == 'TTC') $product->price_min_ttc = $_POST["price_min"]; - else $product->price_min = $_POST["price_min"]; - $product->tva_tx = $_POST["tva_tx"]; + if (! $error) + { + $product->ref = $ref; + $product->libelle = $_POST["libelle"]; + $product->price_base_type = $_POST["price_base_type"]; + if ($product->price_base_type == 'TTC') $product->price_ttc = $_POST["price"]; + else $product->price = $_POST["price"]; + if ($product->price_base_type == 'TTC') $product->price_min_ttc = $_POST["price_min"]; + else $product->price_min = $_POST["price_min"]; + $product->tva_tx = $_POST["tva_tx"]; - // local taxes. - $product->localtax1_tx = get_localtax($product->tva_tx,1); - $product->localtax2_tx = get_localtax($product->tva_tx,2); + // local taxes. + $product->localtax1_tx = get_localtax($product->tva_tx,1); + $product->localtax2_tx = get_localtax($product->tva_tx,2); - $product->type = $_POST["type"]; - $product->status = $_POST["statut"]; - $product->status_buy = $_POST["statut_buy"]; - $product->description = dol_htmlcleanlastbr($_POST["desc"]); - $product->note = dol_htmlcleanlastbr($_POST["note"]); + $product->type = $_POST["type"]; + $product->status = $_POST["statut"]; + $product->status_buy = $_POST["statut_buy"]; + $product->description = dol_htmlcleanlastbr($_POST["desc"]); + $product->note = dol_htmlcleanlastbr($_POST["note"]); $product->customcode = $_POST["customcode"]; $product->country_id = $_POST["country_id"]; - $product->duration_value = $_POST["duration_value"]; - $product->duration_unit = $_POST["duration_unit"]; - $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0; - $product->canvas = $_POST["canvas"]; - $product->weight = $_POST["weight"]; - $product->weight_units = $_POST["weight_units"]; - $product->length = $_POST["size"]; - $product->length_units = $_POST["size_units"]; - $product->surface = $_POST["surface"]; - $product->surface_units = $_POST["surface_units"]; - $product->volume = $_POST["volume"]; - $product->volume_units = $_POST["volume_units"]; - $product->finished = $_POST["finished"]; - $product->hidden = $_POST["hidden"]=='yes'?1:0; + $product->duration_value = $_POST["duration_value"]; + $product->duration_unit = $_POST["duration_unit"]; + $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0; + $product->canvas = $_POST["canvas"]; + $product->weight = $_POST["weight"]; + $product->weight_units = $_POST["weight_units"]; + $product->length = $_POST["size"]; + $product->length_units = $_POST["size_units"]; + $product->surface = $_POST["surface"]; + $product->surface_units = $_POST["surface_units"]; + $product->volume = $_POST["volume"]; + $product->volume_units = $_POST["volume_units"]; + $product->finished = $_POST["finished"]; + $product->hidden = $_POST["hidden"]=='yes'?1:0; - // MultiPrix - if($conf->global->PRODUIT_MULTIPRICES) - { - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - if($_POST["price_".$i]) - { - $product->multiprices["$i"] = price2num($_POST["price_".$i],'MU'); - $product->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; - } - else - { - $product->multiprices["$i"] = ""; - } - } - } + // MultiPrix + if($conf->global->PRODUIT_MULTIPRICES) + { + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) + { + if($_POST["price_".$i]) + { + $product->multiprices["$i"] = price2num($_POST["price_".$i],'MU'); + $product->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; + } + else + { + $product->multiprices["$i"] = ""; + } + } + } - $id = $product->create($user); + $id = $product->create($user); - if ($id > 0) - { - Header("Location: fiche.php?id=".$id); - exit; - } - else - { - $mesg='
'.$langs->trans($product->error).'
'; - $action = "create"; - $_GET["type"] = $_POST["type"]; - } - } + if ($id > 0) + { + Header("Location: fiche.php?id=".$id); + exit; + } + else + { + $mesg='
'.$langs->trans($product->error).'
'; + $action = "create"; + $_GET["type"] = $_POST["type"]; + } + } } // Update a product or service if ($action == 'update' && ($user->rights->produit->creer || $user->rights->service->creer)) { - if (! empty($_POST["cancel"])) - { - $action = ''; - } - else - { - $product=new Product($db); - if ($product->fetch($id,$ref)) - { - $product->ref = $ref; - $product->libelle = $_POST["libelle"]; - $product->description = dol_htmlcleanlastbr($_POST["desc"]); - $product->note = dol_htmlcleanlastbr($_POST["note"]); + if (! empty($_POST["cancel"])) + { + $action = ''; + } + else + { + $product=new Product($db); + if ($product->fetch($id,$ref)) + { + $product->ref = $ref; + $product->libelle = $_POST["libelle"]; + $product->description = dol_htmlcleanlastbr($_POST["desc"]); + $product->note = dol_htmlcleanlastbr($_POST["note"]); $product->customcode = $_POST["customcode"]; $product->country_id = $_POST["country_id"]; - $product->status = $_POST["statut"]; - $product->status_buy = $_POST["statut_buy"]; - $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; - $product->duration_value = $_POST["duration_value"]; - $product->duration_unit = $_POST["duration_unit"]; - $product->canvas = $_POST["canvas"]; - $product->weight = $_POST["weight"]; - $product->weight_units = $_POST["weight_units"]; - $product->length = $_POST["size"]; - $product->length_units = $_POST["size_units"]; - $product->surface = $_POST["surface"]; - $product->surface_units = $_POST["surface_units"]; - $product->volume = $_POST["volume"]; - $product->volume_units = $_POST["volume_units"]; - $product->finished = $_POST["finished"]; - $product->hidden = $_POST["hidden"]=='yes'?1:0; + $product->status = $_POST["statut"]; + $product->status_buy = $_POST["statut_buy"]; + $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; + $product->duration_value = $_POST["duration_value"]; + $product->duration_unit = $_POST["duration_unit"]; + $product->canvas = $_POST["canvas"]; + $product->weight = $_POST["weight"]; + $product->weight_units = $_POST["weight_units"]; + $product->length = $_POST["size"]; + $product->length_units = $_POST["size_units"]; + $product->surface = $_POST["surface"]; + $product->surface_units = $_POST["surface_units"]; + $product->volume = $_POST["volume"]; + $product->volume_units = $_POST["volume_units"]; + $product->finished = $_POST["finished"]; + $product->hidden = $_POST["hidden"]=='yes'?1:0; - if ($product->check()) - { - if ($product->update($product->id, $user) > 0) - { - $action = ''; - } - else - { - $action = 'edit'; - $mesg = $product->error; - } - } - else - { - $action = 'edit'; - $mesg = $langs->trans("ErrorProductBadRefOrLabel"); - } - } - } + if ($product->check()) + { + if ($product->update($product->id, $user) > 0) + { + $action = ''; + } + else + { + $action = 'edit'; + $mesg = $product->error; + } + } + else + { + $action = 'edit'; + $mesg = $langs->trans("ErrorProductBadRefOrLabel"); + } + } + } } // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) { - if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) - { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; - } - else - { - $db->begin(); + if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) + { + $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; + } + else + { + $db->begin(); - $product = new Product($db); - $originalId = $id; - if ($product->fetch($id,$ref) > 0) - { - $product->ref = GETPOST('clone_ref'); - $product->status = 0; - $product->status_buy = 0; - $product->finished = 1; - $product->id = null; + $product = new Product($db); + $originalId = $id; + if ($product->fetch($id,$ref) > 0) + { + $product->ref = GETPOST('clone_ref'); + $product->status = 0; + $product->status_buy = 0; + $product->finished = 1; + $product->id = null; - if ($product->check()) - { - $id = $product->create($user); - if ($id > 0) - { - // $product->clone_fournisseurs($originalId, $id); + if ($product->check()) + { + $id = $product->create($user); + if ($id > 0) + { + // $product->clone_fournisseurs($originalId, $id); - $db->commit(); - $db->close(); + $db->commit(); + $db->close(); - Header("Location: fiche.php?id=$id"); - exit; - } - else - { - if ($product->error == 'ErrorProductAlreadyExists') - { - $db->rollback(); + Header("Location: fiche.php?id=$id"); + exit; + } + else + { + if ($product->error == 'ErrorProductAlreadyExists') + { + $db->rollback(); - $_error = 1; - $action = ""; + $_error = 1; + $action = ""; - $mesg='
'.$langs->trans("ErrorProductAlreadyExists",$product->ref); - $mesg.=' '.$langs->trans("ShowCardHere").'.'; - $mesg.='
'; - //dol_print_error($product->db); - } - else - { - $db->rollback(); - dol_print_error($product->db); - } - } - } - } - else - { - $db->rollback(); - dol_print_error($product->db); - } - } + $mesg='
'.$langs->trans("ErrorProductAlreadyExists",$product->ref); + $mesg.=' '.$langs->trans("ShowCardHere").'.'; + $mesg.='
'; + //dol_print_error($product->db); + } + else + { + $db->rollback(); + dol_print_error($product->db); + } + } + } + } + else + { + $db->rollback(); + dol_print_error($product->db); + } + } } // Delete a product if ($action == 'confirm_delete' && $confirm == 'yes') { - $object = new Product($db); - $object->fetch($id,$ref); + $object = new Product($db); + $object->fetch($id,$ref); - if ( ($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer) ) - { - $result = $object->delete($id); - } + if ( ($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer) ) + { + $result = $object->delete($id); + } - if ($result > 0) - { - Header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.urlencode($object->ref)); - exit; - } - else - { - $mesg=$object->error; - $reload = 0; - $action=''; - } + if ($result > 0) + { + Header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.urlencode($object->ref)); + exit; + } + else + { + $mesg=$object->error; + $reload = 0; + $action=''; + } } // Add product into proposal if ($action == 'addinpropal') { - $propal = new Propal($db); - $result=$propal->fetch($_POST["propalid"]); - if ($result <= 0) - { - dol_print_error($db,$propal->error); - exit; - } + $propal = new Propal($db); + $result=$propal->fetch($_POST["propalid"]); + if ($result <= 0) + { + dol_print_error($db,$propal->error); + exit; + } - $soc = new Societe($db); - $result=$soc->fetch($propal->socid); - if ($result <= 0) - { - dol_print_error($db,$soc->error); - exit; - } + $soc = new Societe($db); + $result=$soc->fetch($propal->socid); + if ($result <= 0) + { + dol_print_error($db,$soc->error); + exit; + } - $prod = new Product($db); - $result=$prod->fetch($id,$ref); - if ($result <= 0) - { - dol_print_error($db,$prod->error); - exit; - } + $prod = new Product($db); + $result=$prod->fetch($id,$ref); + if ($result <= 0) + { + dol_print_error($db,$prod->error); + exit; + } - $desc = $prod->description; + $desc = $prod->description; - $tva_tx = get_default_tva($mysoc, $soc, $prod->id); - $localtax1_tx= get_localtax($tva_tx, 1, $soc); - $localtax2_tx= get_localtax($tva_tx, 2, $soc); + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $localtax1_tx= get_localtax($tva_tx, 1, $soc); + $localtax2_tx= get_localtax($tva_tx, 2, $soc); $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; $price_base_type = $prod->price_base_type; - // If multiprice - if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) - { - $pu_ht = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; - } + // If multiprice + if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) + { + $pu_ht = $prod->multiprices[$soc->price_level]; + $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; + $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + } - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) - { - if ($price_base_type != 'HT') - { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); - } - else - { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); - } - } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + if ($tva_tx != $prod->tva_tx) + { + if ($price_base_type != 'HT') + { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); + } + else + { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + } - $result = $propal->addline($propal->id, - $desc, - $pu_ht, - $_POST["qty"], - $tva_tx, - $localtax1_tx, // localtax1 - $localtax2_tx, // localtax2 - $prod->id, - $_POST["remise_percent"], - $price_base_type, - $pu_ttc - ); - if ($result > 0) - { - Header("Location: ".DOL_URL_ROOT."/comm/propal.php?id=".$propal->id); - return; - } + $result = $propal->addline( + $propal->id, + $desc, + $pu_ht, + $_POST["qty"], + $tva_tx, + $localtax1_tx, // localtax1 + $localtax2_tx, // localtax2 + $prod->id, + $_POST["remise_percent"], + $price_base_type, + $pu_ttc + ); + if ($result > 0) + { + Header("Location: ".DOL_URL_ROOT."/comm/propal.php?id=".$propal->id); + return; + } - $mesg = $langs->trans("ErrorUnknown").": $result"; + $mesg = $langs->trans("ErrorUnknown").": $result"; } // Add product into order if ($action == 'addincommande') { - $commande = new Commande($db); - $result=$commande->fetch($_POST["commandeid"]); - if ($result <= 0) - { - dol_print_error($db,$commande->error); - exit; - } + $commande = new Commande($db); + $result=$commande->fetch($_POST["commandeid"]); + if ($result <= 0) + { + dol_print_error($db,$commande->error); + exit; + } - $soc = new Societe($db); - $result=$soc->fetch($commande->socid); - if ($result <= 0) - { - dol_print_error($db,$soc->error); - exit; - } + $soc = new Societe($db); + $result=$soc->fetch($commande->socid); + if ($result <= 0) + { + dol_print_error($db,$soc->error); + exit; + } - $prod = new Product($db); - $result=$prod->fetch($id,$ref); - if ($result <= 0) - { - dol_print_error($db,$prod->error); - exit; - } + $prod = new Product($db); + $result=$prod->fetch($id,$ref); + if ($result <= 0) + { + dol_print_error($db,$prod->error); + exit; + } - $desc = $prod->description; + $desc = $prod->description; - $tva_tx = get_default_tva($mysoc, $soc, $prod->id); - $localtax1_tx= get_localtax($tva_tx, 1, $soc); - $localtax2_tx= get_localtax($tva_tx, 2, $soc); + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $localtax1_tx= get_localtax($tva_tx, 1, $soc); + $localtax2_tx= get_localtax($tva_tx, 2, $soc); $pu_ht = $prod->price; @@ -490,74 +491,75 @@ if (empty($reshook)) $price_base_type = $prod->multiprices_base_type[$soc->price_level]; } - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) - { - if ($price_base_type != 'HT') - { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); - } - else - { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); - } - } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + if ($tva_tx != $prod->tva_tx) + { + if ($price_base_type != 'HT') + { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); + } + else + { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + } - $result = $commande->addline($commande->id, - $desc, - $pu_ht, - $_POST["qty"], - $tva_tx, - $localtax1_tx, // localtax1 - $localtax2_tx, // localtax2 - $prod->id, - $_POST["remise_percent"], - '', - '', //Todo: voir si fk_remise_except est encore valable car n'apparait plus dans les propales - $price_base_type, - $pu_ttc - ); + $result = $commande->addline( + $commande->id, + $desc, + $pu_ht, + $_POST["qty"], + $tva_tx, + $localtax1_tx, // localtax1 + $localtax2_tx, // localtax2 + $prod->id, + $_POST["remise_percent"], + '', + '', //Todo: voir si fk_remise_except est encore valable car n'apparait plus dans les propales + $price_base_type, + $pu_ttc + ); - if ($result > 0) - { - Header("Location: ".DOL_URL_ROOT."/commande/fiche.php?id=".$commande->id); - exit; - } + if ($result > 0) + { + Header("Location: ".DOL_URL_ROOT."/commande/fiche.php?id=".$commande->id); + exit; + } } // Add product into invoice if ($action == 'addinfacture' && $user->rights->facture->creer) { - $facture = New Facture($db); - $result=$facture->fetch($_POST["factureid"]); - if ($result <= 0) - { - dol_print_error($db,$facture->error); - exit; - } + $facture = New Facture($db); + $result=$facture->fetch($_POST["factureid"]); + if ($result <= 0) + { + dol_print_error($db,$facture->error); + exit; + } - $soc = new Societe($db); - $soc->fetch($facture->socid); - if ($result <= 0) - { - dol_print_error($db,$soc->error); - exit; - } + $soc = new Societe($db); + $soc->fetch($facture->socid); + if ($result <= 0) + { + dol_print_error($db,$soc->error); + exit; + } - $prod = new Product($db); - $result = $prod->fetch($id,$ref); - if ($result <= 0) - { - dol_print_error($db,$prod->error); - exit; - } + $prod = new Product($db); + $result = $prod->fetch($id,$ref); + if ($result <= 0) + { + dol_print_error($db,$prod->error); + exit; + } - $desc = $prod->description; + $desc = $prod->description; - $tva_tx = get_default_tva($mysoc, $soc, $prod->id); - $localtax1_tx= get_localtax($tva_tx, 1, $soc); - $localtax2_tx= get_localtax($tva_tx, 2, $soc); + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $localtax1_tx= get_localtax($tva_tx, 1, $soc); + $localtax2_tx= get_localtax($tva_tx, 2, $soc); $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; @@ -571,51 +573,52 @@ if (empty($reshook)) $price_base_type = $prod->multiprices_base_type[$soc->price_level]; } - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) - { - if ($price_base_type != 'HT') - { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); - } - else - { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); - } - } + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + if ($tva_tx != $prod->tva_tx) + { + if ($price_base_type != 'HT') + { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); + } + else + { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + } - $result = $facture->addline($facture->id, - $desc, - $pu_ht, - $_POST["qty"], - $tva_tx, - $localtax1_tx, - $localtax2_tx, - $prod->id, - $_POST["remise_percent"], - '', - '', - '', - '', - '', - $price_base_type, - $pu_ttc - ); + $result = $facture->addline( + $facture->id, + $desc, + $pu_ht, + $_POST["qty"], + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $prod->id, + $_POST["remise_percent"], + '', + '', + '', + '', + '', + $price_base_type, + $pu_ttc + ); - if ($result > 0) - { - Header("Location: ".DOL_URL_ROOT."/compta/facture.php?facid=".$facture->id); - exit; - } + if ($result > 0) + { + Header("Location: ".DOL_URL_ROOT."/compta/facture.php?facid=".$facture->id); + exit; + } } } if (GETPOST("cancel") == $langs->trans("Cancel")) { - $action = ''; - Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]); - exit; + $action = ''; + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]); + exit; } @@ -641,10 +644,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // When used with CANVAS // ----------------------------------------- if (! $objcanvas->hasActions() && ($id || $ref)) - { - $object = new Product($db); - $object->fetch($id, $ref); // For use with "pure canvas" (canvas that contains templates only) - } + { + $object = new Product($db); + $object->fetch($id, $ref); // For use with "pure canvas" (canvas that contains templates only) + } $objcanvas->assign_values($action, $id, $ref); // Set value for templates $objcanvas->display_canvas(); // Show template } @@ -655,106 +658,106 @@ else // ----------------------------------------- if ($action == 'create' && ($user->rights->produit->creer || $user->rights->service->creer)) { - print ''; - print ''; - print ''; - print ''."\n"; + print ''; + print ''; + print ''; + print ''."\n"; - if ($_GET["type"]==1) $title=$langs->trans("NewService"); - else $title=$langs->trans("NewProduct"); - print_fiche_titre($title); + if ($_GET["type"]==1) $title=$langs->trans("NewService"); + else $title=$langs->trans("NewProduct"); + print_fiche_titre($title); - dol_htmloutput_mesg($mesg); + dol_htmloutput_mesg($mesg); - print '
 
".$obj->ville." $obj->departement'.$obj->departement.'".dol_print_date($db->jdate($obj->datec))."'.dol_print_date($db->jdate($obj->datec)).'"; + print ''; print $prospectstatic->LibLevel($obj->fk_prospectlevel); print "
'; - print ''; - print ''; + print '
'.$langs->trans("Ref").''; - if ($_error == 1) - { - print $langs->trans("RefAlreadyExists"); - } - print '
'; + print ''; + print ''; - // Label - print ''; + // Label + print ''; - // On sell - print ''; + // On sell + print ''; - // To buy - print ''; + // To buy + print ''; - // Stock min level - if ($_GET["type"] != 1 && $conf->stock->enabled) - { - print ''; - } - else - { - print ''; - } + // Stock min level + if ($_GET["type"] != 1 && $conf->stock->enabled) + { + print ''; + } + else + { + print ''; + } - // Description (used in invoice, propal...) - print '"; + print ""; - // Nature - if ($_GET["type"] != 1) - { - print ''; - } + // Nature + if ($_GET["type"] != 1) + { + print ''; + } - //Duration - if ($_GET["type"] == 1) - { - print ''; - } + //Duration + if ($_GET["type"] == 1) + { + print ''; + } - if ($_GET["type"] != 1) // Le poids et le volume ne concerne que les produits et pas les services - { - // Weight - print ''; - // Length - print ''; - // Surface - print ''; - // Volume - print ''; - } + if ($_GET["type"] != 1) // Le poids et le volume ne concerne que les produits et pas les services + { + // Weight + print ''; + // Length + print ''; + // Surface + print ''; + // Volume + print ''; + } // Custom code print ''; @@ -765,50 +768,50 @@ else if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; - // Note (invisible sur facture, propales...) - print '"; - print '
'.$langs->trans("Ref").''; + if ($_error == 1) + { + print $langs->trans("RefAlreadyExists"); + } + print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.''; - $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - print $html->selectarray('statut',$statutarray,$_POST["statut"]); - print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; + $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); + print $html->selectarray('statut',$statutarray,$_POST["statut"]); + print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.''; - $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); - print $html->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; + $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); + print $html->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); + print '
'.$langs->trans("StockLimit").''; - print ''; - print '
'.$langs->trans("StockLimit").''; + print ''; + print '
'.$langs->trans("Description").''; + // Description (used in invoice, propal...) + print '
'.$langs->trans("Description").''; - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc',$_POST["desc"],'',160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90); - $doleditor->Create(); + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc',$_POST["desc"],'',160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90); + $doleditor->Create(); - print "
'.$langs->trans("Nature").''; - $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $html->selectarray('finished',$statutarray,$_POST["finished"]); - print '
'.$langs->trans("Nature").''; + $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); + print $html->selectarray('finished',$statutarray,$_POST["finished"]); + print '
'.$langs->trans("Duration").'  '; - print ''.$langs->trans("Hour").' '; - print ''.$langs->trans("Day").' '; - print ''.$langs->trans("Week").' '; - print ''.$langs->trans("Month").' '; - print ''.$langs->trans("Year").' '; - print '
'.$langs->trans("Duration").'  '; + print ''.$langs->trans("Hour").' '; + print ''.$langs->trans("Day").' '; + print ''.$langs->trans("Week").' '; + print ''.$langs->trans("Month").' '; + print ''.$langs->trans("Year").' '; + print '
'.$langs->trans("Weight").''; - print ''; - print $formproduct->select_measuring_units("weight_units","weight"); - print '
'.$langs->trans("Length").''; - print ''; - print $formproduct->select_measuring_units("size_units","size"); - print '
'.$langs->trans("Surface").''; - print ''; - print $formproduct->select_measuring_units("surface_units","surface"); - print '
'.$langs->trans("Volume").''; - print ''; - print $formproduct->select_measuring_units("volume_units","volume"); - print '
'.$langs->trans("Weight").''; + print ''; + print $formproduct->select_measuring_units("weight_units","weight"); + print '
'.$langs->trans("Length").''; + print ''; + print $formproduct->select_measuring_units("size_units","size"); + print '
'.$langs->trans("Surface").''; + print ''; + print $formproduct->select_measuring_units("surface_units","surface"); + print '
'.$langs->trans("Volume").''; + print ''; + print $formproduct->select_measuring_units("volume_units","volume"); + print '
'.$langs->trans("CustomCode").'
'.$langs->trans("NoteNotVisibleOnBill").''; - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note',$_POST["note"],'',180,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); - $doleditor->Create(); + // Note (invisible sur facture, propales...) + print '
'.$langs->trans("NoteNotVisibleOnBill").''; + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note',$_POST["note"],'',180,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); + $doleditor->Create(); - print "
'; + print ""; + print ''; - print '
'; + print '
'; - if ($conf->global->PRODUIT_MULTIPRICES) - { - // We do no show price array on create when multiprices enabled. - // We must set them on prices tab. - } - else - { - print ''; + if ($conf->global->PRODUIT_MULTIPRICES) + { + // We do no show price array on create when multiprices enabled. + // We must set them on prices tab. + } + else + { + print '
'; - // PRIX - print ''; - print ''; + // PRIX + print ''; + print ''; - // MIN PRICE - print ''; - print ''; + // MIN PRICE + print ''; + print ''; - // VAT - print ''; + // VAT + print ''; - print '
'.$langs->trans("SellingPrice").''; - print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); - print '
'.$langs->trans("SellingPrice").''; + print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); + print '
'.$langs->trans("MinPrice").''; - print '
'.$langs->trans("MinPrice").''; + print '
'.$langs->trans("VATRate").''; - print $html->load_tva("tva_tx",-1,$mysoc,''); - print '
'.$langs->trans("VATRate").''; + print $html->load_tva("tva_tx",-1,$mysoc,''); + print '
'; + print ''; - print '
'; - } + print '
'; + } - print '
'; + print '
'; - print '
'; + print ''; } /** @@ -817,134 +820,134 @@ else if ($id || $ref) { - $object=new Product($db); - $object->fetch($id,$ref); + $object=new Product($db); + $object->fetch($id,$ref); - /* - * Fiche en mode edition - */ - if ($action == 'edit' && ($user->rights->produit->creer || $user->rights->service->creer)) - { - $type = $langs->trans('Product'); - if ($object->isservice()) $type = $langs->trans('Service'); - print_fiche_titre($langs->trans('Modify').' '.$type.' : '.$object->ref, ""); + /* + * Fiche en mode edition + */ + if ($action == 'edit' && ($user->rights->produit->creer || $user->rights->service->creer)) + { + $type = $langs->trans('Product'); + if ($object->isservice()) $type = $langs->trans('Service'); + print_fiche_titre($langs->trans('Modify').' '.$type.' : '.$object->ref, ""); - dol_htmloutput_errors($mesg); + dol_htmloutput_errors($mesg); - // Main official, simple, and not duplicated code - print '
'."\n"; - print ''; - print ''; - print ''; - print ''; - print ''; + // Main official, simple, and not duplicated code + print ''."\n"; + print ''; + print ''; + print ''; + print ''; + print '
'; - // Ref - print ''; + // Ref + print ''; - // Label - print ''; + // Label + print ''; - // Status - print ''; + // Status + print ''; - // To Buy - print ''; + // To Buy + print ''; - // Description (used in invoice, propal...) - print '"; - print "\n"; + // Description (used in invoice, propal...) + print '"; + print "\n"; - // Nature - if($object->type!=1) - { - print ''; - } + // Nature + if($object->type!=1) + { + print ''; + } - if ($object->isproduct() && $conf->stock->enabled) - { - print "".''; - } - else - { - print ''; - } + if ($object->isproduct() && $conf->stock->enabled) + { + print "".''; + } + else + { + print ''; + } - if ($object->isservice()) - { - // Duration - print ''; - } - else - { - // Weight - print ''; - // Length - print ''; - // Surface - print ''; - // Volume - print ''; - } + print ''; + } + else + { + // Weight + print ''; + // Length + print ''; + // Surface + print ''; + // Volume + print ''; + } // Custom code print ''; @@ -955,162 +958,162 @@ else if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; - // Note - print '"; - print '
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.''; - print ''; - print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; + print ''; + print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.''; - print ''; - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; + print ''; + print '
'.$langs->trans("Description").''; - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc',$object->description,'',160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90); - $doleditor->Create(); - print "
'.$langs->trans("Description").''; + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc',$object->description,'',160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90); + $doleditor->Create(); + print "
'.$langs->trans("Nature").''; - $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - print $html->selectarray('finished',$statutarray,$object->finished); - print '
'.$langs->trans("Nature").''; + $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); + print $html->selectarray('finished',$statutarray,$object->finished); + print '
'.$langs->trans("StockLimit").''; - print ''; - print '
'.$langs->trans("StockLimit").''; + print ''; + print '
'.$langs->trans("Duration").''; - print '  '; - print 'duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); - print '  '; - print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); - print '  '; - print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); - print '  '; - print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); - print '  '; - print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); + if ($object->isservice()) + { + // Duration + print '
'.$langs->trans("Duration").''; + print '  '; + print 'duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); + print '  '; + print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); + print '  '; + print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); + print '  '; + print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); + print '  '; + print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); - print '
'.$langs->trans("Weight").''; - print ' '; - print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units); - print '
'.$langs->trans("Length").''; - print ' '; - print $formproduct->select_measuring_units("size_units", "size", $object->length_units); - print '
'.$langs->trans("Surface").''; - print ' '; - print $formproduct->select_measuring_units("surface_units", "surface", $object->surface_units); - print '
'.$langs->trans("Volume").''; - print ' '; - print $formproduct->select_measuring_units("volume_units", "volume", $object->volume_units); - print '
'.$langs->trans("Weight").''; + print ' '; + print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units); + print '
'.$langs->trans("Length").''; + print ' '; + print $formproduct->select_measuring_units("size_units", "size", $object->length_units); + print '
'.$langs->trans("Surface").''; + print ' '; + print $formproduct->select_measuring_units("surface_units", "surface", $object->surface_units); + print '
'.$langs->trans("Volume").''; + print ' '; + print $formproduct->select_measuring_units("volume_units", "volume", $object->volume_units); + print '
'.$langs->trans("CustomCode").'
'.$langs->trans("NoteNotVisibleOnBill").''; - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note',$object->note,'',200,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); - $doleditor->Create(); - print "
'; + // Note + print ''.$langs->trans("NoteNotVisibleOnBill").''; + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note',$object->note,'',200,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70); + $doleditor->Create(); + print ""; + print ''; - print '
'; + print '
'; - print '
    '; - print '
'; + print '
    '; + print '
'; - print '
'; - } - /* - * Fiche en mode visu - */ - else - { - $head=product_prepare_head($object, $user); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==1?'service':'product'); - dol_fiche_head($head, 'card', $titre, 0, $picto); + print ''; + } + /* + * Fiche en mode visu + */ + else + { + $head=product_prepare_head($object, $user); + $titre=$langs->trans("CardProduct".$object->type); + $picto=($object->type==1?'service':'product'); + dol_fiche_head($head, 'card', $titre, 0, $picto); - // Confirm delete product - if ($action == 'delete' || $conf->use_javascript_ajax) - { - $ret=$html->form_confirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); - if ($ret == 'html') print '
'; - } + // Confirm delete product + if ($action == 'delete' || $conf->use_javascript_ajax) + { + $ret=$html->form_confirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); + if ($ret == 'html') print '
'; + } $isphoto=$object->is_photo_available($conf->product->dir_output); - // En mode visu - print ''; + // En mode visu + print '
'; - // Ref - print ''; + // Ref + print ''; - print ''; + print ''; - // Label - print ''; + // Label + print ''; - $nblignes=9; - if ($object->type!=1) $nblignes++; - if ($object->isservice()) $nblignes++; - else $nblignes+=4; + $nblignes=9; + if ($object->type!=1) $nblignes++; + if ($object->isservice()) $nblignes++; + else $nblignes+=4; - if ($isphoto) - { - // Photo - print ''; - } + if ($isphoto) + { + // Photo + print ''; + } - print ''; + print ''; - // Accountancy sell code - print ''; + // Accountancy sell code + print ''; - // Accountancy buy code - print ''; + // Accountancy buy code + print ''; - // Status (to sell) - print ''; + // Status (to sell) + print ''; - // Status (to buy) - print ''; + // Status (to buy) + print ''; - // Description - print ''; + // Description + print ''; - // Nature - if($object->type!=1) - { - print ''; - } + // Nature + if($object->type!=1) + { + print ''; + } - if ($object->isservice()) - { - // Duration - print ''; - } - else - { - // Weight - print '\n"; - // Length - print '\n"; - // Surface - print '\n"; - // Volume - print '\n"; - } + print ''; + } + else + { + // Weight + print '\n"; + // Length + print '\n"; + // Surface + print '\n"; + // Volume + print '\n"; + } // Custom code print ''; @@ -1119,19 +1122,19 @@ else print ''; - // Note - print ''; + // Note + print ''; - print "
'.$langs->trans("Ref").''; - print $html->showrefnav($object,'ref','',1,'ref'); - print ''.$langs->trans("Ref").''; + print $html->showrefnav($object,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$object->libelle.'
'.$langs->trans("Label").''.$object->libelle.''; - print $object->show_photos($conf->product->dir_output,1,1,0,0,0,80); - print ''; + print $object->show_photos($conf->product->dir_output,1,1,0,0,0,80); + print '
'.$html->editfieldkey("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,'id',$object->id,$user->rights->produit->creer).''; - print $html->editfieldval("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,'id',$object->id,$user->rights->produit->creer); - print '
'.$html->editfieldkey("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,'id',$object->id,$user->rights->produit->creer).''; + print $html->editfieldval("ProductAccountancySellCode",'productaccountancycodesell',$object->accountancy_code_sell,'id',$object->id,$user->rights->produit->creer); + print '
'.$html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,'id',$object->id,$user->rights->produit->creer).''; - print $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,'id',$object->id,$user->rights->produit->creer); - print '
'.$html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,'id',$object->id,$user->rights->produit->creer).''; + print $html->editfieldval("ProductAccountancyBuyCode",'productaccountancycodebuy',$object->accountancy_code_buy,'id',$object->id,$user->rights->produit->creer); + print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.''; - print $object->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; + print $object->getLibStatut(2,0); + print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.''; - print $object->getLibStatut(2,1); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; + print $object->getLibStatut(2,1); + print '
'.$langs->trans("Description").''.(dol_textishtml($object->description)?$object->description:dol_nl2br($object->description,1,true)).'
'.$langs->trans("Description").''.(dol_textishtml($object->description)?$object->description:dol_nl2br($object->description,1,true)).'
'.$langs->trans("Nature").''; - print $object->getLibFinished(); - print '
'.$langs->trans("Nature").''; + print $object->getLibFinished(); + print '
'.$langs->trans("Duration").''.$object->duration_value.' '; - if ($object->duration_value > 1) - { - $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); - } - else if ($object->duration_value > 0) - { - $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); - } - print $langs->trans($dur[$object->duration_unit])." "; + if ($object->isservice()) + { + // Duration + print '
'.$langs->trans("Duration").''.$object->duration_value.' '; + if ($object->duration_value > 1) + { + $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + } + else if ($object->duration_value > 0) + { + $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + print $langs->trans($dur[$object->duration_unit])." "; - print '
'.$langs->trans("Weight").''; - if ($object->weight != '') - { - print $object->weight." ".measuring_units_string($object->weight_units,"weight"); - } - else - { - print ' '; - } - print "
'.$langs->trans("Length").''; - if ($object->length != '') - { - print $object->length." ".measuring_units_string($object->length_units,"size"); - } - else - { - print ' '; - } - print "
'.$langs->trans("Surface").''; - if ($object->surface != '') - { - print $object->surface." ".measuring_units_string($object->surface_units,"surface"); - } - else - { - print ' '; - } - print "
'.$langs->trans("Volume").''; - if ($object->volume != '') - { - print $object->volume." ".measuring_units_string($object->volume_units,"volume"); - } - else - { - print ' '; - } - print "
'.$langs->trans("Weight").''; + if ($object->weight != '') + { + print $object->weight." ".measuring_units_string($object->weight_units,"weight"); + } + else + { + print ' '; + } + print "
'.$langs->trans("Length").''; + if ($object->length != '') + { + print $object->length." ".measuring_units_string($object->length_units,"size"); + } + else + { + print ' '; + } + print "
'.$langs->trans("Surface").''; + if ($object->surface != '') + { + print $object->surface." ".measuring_units_string($object->surface_units,"surface"); + } + else + { + print ' '; + } + print "
'.$langs->trans("Volume").''; + if ($object->volume != '') + { + print $object->volume." ".measuring_units_string($object->volume_units,"volume"); + } + else + { + print ' '; + } + print "
'.$langs->trans("CustomCode").''.$object->customcode.'
'.$langs->trans("CountryOrigin").''.getCountry($object->country_id,0,$db).'
'.$langs->trans("Note").''.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'
'.$langs->trans("Note").''.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'
\n"; + print "\n"; - dol_fiche_end(); - } + dol_fiche_end(); + } } else if ($action != 'create') { - Header("Location: index.php"); - exit; + Header("Location: index.php"); + exit; } } @@ -1139,15 +1142,15 @@ else // Clone confirmation if ($action == 'clone' || $conf->use_javascript_ajax) { - // Create an array for form - $formquestion=array( + // Create an array for form + $formquestion=array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => $langs->trans("CopyOf").' '.$object->ref, 'size'=>24), - array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), - array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestion,'yes','action-clone',230,600); + array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => $langs->trans("CopyOf").' '.$object->ref, 'size'=>24), + array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1), + array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true) + ); + // Paiement incomplet. On demande si motif = escompte ou autre + $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestion,'yes','action-clone',230,600); } @@ -1159,46 +1162,49 @@ if ($action == 'clone' || $conf->use_javascript_ajax) print "\n".'
'."\n"; -if ($action == '') +if ($action == '' || $action == 'view') { - if ($user->rights->produit->creer || $user->rights->service->creer) - { - if ($object->no_button_edit <> 1) - print 'id.'">'.$langs->trans("Modify").''; + if ($user->rights->produit->creer || $user->rights->service->creer) + { + if ($object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; - if ($object->no_button_copy <> 1) { - if ($conf->use_javascript_ajax) { - print ''.$langs->trans('ToClone').''."\n"; - } else { - print 'id.'">'.$langs->trans("ToClone").''; - } - } - } + if ($object->no_button_copy <> 1) + { + if ($conf->use_javascript_ajax) + { + print ''.$langs->trans('ToClone').''."\n"; + } + else + { + print 'id.'">'.$langs->trans("ToClone").''; + } + } + } - $object_is_used = $object->isObjectUsed($object->id); - if (($object->type == 0 && $user->rights->produit->supprimer) - || ($object->type == 1 && $user->rights->service->supprimer)) - { - if (! $object_is_used && $object->no_button_delete <> 1) - { - if ($conf->use_javascript_ajax) - { - print ''.$langs->trans('Delete').''."\n"; - } - else - { - print 'id.'">'.$langs->trans("Delete").''; - } - } - else - { - print ''.$langs->trans("Delete").''; - } - } - else - { - print ''.$langs->trans("Delete").''; - } + $object_is_used = $object->isObjectUsed($object->id); + if (($object->type == 0 && $user->rights->produit->supprimer) + || ($object->type == 1 && $user->rights->service->supprimer)) + { + if (! $object_is_used && $object->no_button_delete <> 1) + { + if ($conf->use_javascript_ajax) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print 'id.'">'.$langs->trans("Delete").''; + } + } + else + { + print ''.$langs->trans("Delete").''; + } + } + else + { + print ''.$langs->trans("Delete").''; + } } print "\n

\n"; @@ -1208,394 +1214,394 @@ print "\n
\n"; * All the "Add to" areas */ -if ($object->id && $action == '' && $object->status) +if ($object->id && ($action == '' || $action == 'view') && $object->status) { - print ''; + print '
'; - // Propals - if($conf->propal->enabled && $user->rights->propale->creer) - { - $propal = new Propal($db); + // Propals + if($conf->propal->enabled && $user->rights->propale->creer) + { + $propal = new Propal($db); - $langs->load("propal"); + $langs->load("propal"); - print ''; + print ''; - if ($user->rights->societe->client->voir) - { - print ''; - } - else - { - print ''; - } + if ($user->rights->societe->client->voir) + { + print ''; + } + else + { + print ''; + } - print ''; + print ''; - // Liste de "Mes propals" - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; + // Liste de "Mes propals" + print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.ref, p.datep as dp"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; - $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND p.fk_statut = 0"; - $sql.= " AND p.fk_user_author = ".$user->id; - $sql.= " ORDER BY p.datec DESC, p.tms DESC"; + $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.ref, p.datep as dp"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; + $sql.= " WHERE p.fk_soc = s.rowid"; + $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.fk_statut = 0"; + $sql.= " AND p.fk_user_author = ".$user->id; + $sql.= " ORDER BY p.datec DESC, p.tms DESC"; - $result=$db->query($sql); - if ($result) - { - $var=true; - $num = $db->num_rows($result); - print '
'; - print $langs->trans("AddToMyProposals") . '
'; + print $langs->trans("AddToMyProposals") . ''; - print $langs->trans("AddToOtherProposals").' '; + print $langs->trans("AddToOtherProposals").' 
'; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ""; - print '\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else { - print ""; - } - print "
'; - print "propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($objp->dp,"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print " ".$object->stock_proposition; - print ''; - print ''; - print '
"; - print $langs->trans("NoOpenedPropals"); - print "
"; - $db->free($result); - } + $result=$db->query($sql); + if ($result) + { + $var=true; + $num = $db->num_rows($result); + print ''; + if ($num) + { + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print ''; + print ""; + print '\n"; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $i++; + } + } + else { + print ""; + } + print "
'; + print "propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($objp->dp,"%d %b")."'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print " ".$object->stock_proposition; + print ''; + print ''; + print '
"; + print $langs->trans("NoOpenedPropals"); + print "
"; + $db->free($result); + } - print ''; + print ''; - if ($user->rights->societe->client->voir) - { - // Liste de "Other propals" - print ''; + if ($user->rights->societe->client->voir) + { + // Liste de "Other propals" + print ''; - $var=true; - $otherprop = $propal->liste_array(1,1,1); - print '
'; - print ''; - print ''; - if (is_array($otherprop) && count($otherprop)) - { - $var=!$var; - print ''; - print ''; - } - else - { - print "'; - } - print '
'; - print ''; - print $langs->trans("OtherPropals").''; - print $html->selectarray("propalid", $otherprop); - print '
'.$langs->trans("Qty"); - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherOpenedPropals"); - print '
'; - print '
'; + $var=true; + $otherprop = $propal->liste_array(1,1,1); + print '
'; + print ''; + print ''; + if (is_array($otherprop) && count($otherprop)) + { + $var=!$var; + print ''; + print ''; + } + else + { + print "'; + } + print '
'; + print ''; + print $langs->trans("OtherPropals").''; + print $html->selectarray("propalid", $otherprop); + print '
'.$langs->trans("Qty"); + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print '
"; + print $langs->trans("NoOtherOpenedPropals"); + print '
'; + print '
'; - print ''; - } + print ''; + } - print ''; - } + print ''; + } - // Commande - if($conf->commande->enabled && $user->rights->commande->creer) - { - $commande = new Commande($db); + // Commande + if($conf->commande->enabled && $user->rights->commande->creer) + { + $commande = new Commande($db); - $langs->load("orders"); + $langs->load("orders"); - print ''; - print $langs->trans("AddToMyOrders").''; + print ''; + print $langs->trans("AddToMyOrders").''; - if ($user->rights->societe->client->voir) - { - print ''; - print $langs->trans("AddToOtherOrders").''; - } - else - { - print ' '; - } + if ($user->rights->societe->client->voir) + { + print ''; + print $langs->trans("AddToOtherOrders").''; + } + else + { + print ' '; + } - print ''; + print ''; - // Liste de "Mes commandes" - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; + // Liste de "Mes commandes" + print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - $sql = "SELECT s.nom, s.rowid as socid, c.rowid as commandeid, c.ref, c.date_commande as dc"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " AND c.fk_statut = 0"; - $sql.= " AND c.fk_user_author = ".$user->id; - $sql.= " ORDER BY c.date_creation DESC"; + $sql = "SELECT s.nom, s.rowid as socid, c.rowid as commandeid, c.ref, c.date_commande as dc"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 0"; + $sql.= " AND c.fk_user_author = ".$user->id; + $sql.= " ORDER BY c.date_creation DESC"; - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objc = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ""; - print '\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - print "'; - } - print "
'; - print "commandeid."\">".img_object($langs->trans("ShowOrder"),"order")." ".$objc->ref."socid."\">".dol_trunc($objc->nom,18)."".dol_print_date($db->jdate($objc->dc),"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print " ".$object->stock_proposition; - print ''; - print ''; - print '
"; - print $langs->trans("NoOpenedOrders"); - print '
"; - $db->free($result); - } + $result=$db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $var=true; + print ''; + if ($num) + { + $i = 0; + while ($i < $num) + { + $objc = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print ''; + print ""; + print '\n"; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $i++; + } + } + else + { + print "'; + } + print "
'; + print "commandeid."\">".img_object($langs->trans("ShowOrder"),"order")." ".$objc->ref."socid."\">".dol_trunc($objc->nom,18)."".dol_print_date($db->jdate($objc->dc),"%d %b")."'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print " ".$object->stock_proposition; + print ''; + print ''; + print '
"; + print $langs->trans("NoOpenedOrders"); + print '
"; + $db->free($result); + } - print ''; + print ''; - if ($user->rights->societe->client->voir) - { - // Liste de "Other orders" - print ''; + if ($user->rights->societe->client->voir) + { + // Liste de "Other orders" + print ''; - $var=true; - $othercom = $commande->liste_array(1, $user); - print '
'; - print ''; - print ''; - if (is_array($othercom) && count($othercom)) - { - $var=!$var; - print ''; - print ''; - } - else - { - print "'; - } - print '
'; - print ''; - print $langs->trans("OtherOrders").''; - print $html->selectarray("commandeid", $othercom); - print '
'.$langs->trans("Qty"); - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherOpenedOrders"); - print '
'; - print '
'; + $var=true; + $othercom = $commande->liste_array(1, $user); + print '
'; + print ''; + print ''; + if (is_array($othercom) && count($othercom)) + { + $var=!$var; + print ''; + print ''; + } + else + { + print "'; + } + print '
'; + print ''; + print $langs->trans("OtherOrders").''; + print $html->selectarray("commandeid", $othercom); + print '
'.$langs->trans("Qty"); + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print '
"; + print $langs->trans("NoOtherOpenedOrders"); + print '
'; + print '
'; - print ''; - } + print ''; + } - print ''; - } + print ''; + } - // Factures - if ($conf->facture->enabled && $user->rights->facture->creer) - { - print ''; - print $langs->trans("AddToMyBills").''; + // Factures + if ($conf->facture->enabled && $user->rights->facture->creer) + { + print ''; + print $langs->trans("AddToMyBills").''; - if ($user->rights->societe->client->voir) - { - print ''; - print $langs->trans("AddToOtherBills").''; - } - else - { - print ' '; - } + if ($user->rights->societe->client->voir) + { + print ''; + print $langs->trans("AddToOtherBills").''; + } + else + { + print ' '; + } - print ''; + print ''; - // Liste de Mes factures - print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; + // Liste de Mes factures + print 'rights->societe->client->voir?' width="50%"':'').' valign="top">'; - $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber, f.datef as df"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut = 0"; - $sql.= " AND f.fk_user_author = ".$user->id; - $sql.= " ORDER BY f.datec DESC, f.rowid DESC"; + $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber, f.datef as df"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql.= " WHERE f.fk_soc = s.rowid"; + $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.fk_statut = 0"; + $sql.= " AND f.fk_user_author = ".$user->id; + $sql.= " ORDER BY f.datec DESC, f.rowid DESC"; - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else { - print "'; - } - print "
"; - print "factureid."\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($db->jdate($objp->df),"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoDraftBills"); - print '
"; - $db->free($result); - } - else - { - dol_print_error($db); - } + $result=$db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $var=true; + print ''; + if ($num) + { + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print ''; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $i++; + } + } + else { + print "'; + } + print "
"; + print "factureid."\">".img_object($langs->trans("ShowBills"),"bill")." ".$objp->facnumber."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($db->jdate($objp->df),"%d %b")."'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print '
"; + print $langs->trans("NoDraftBills"); + print '
"; + $db->free($result); + } + else + { + dol_print_error($db); + } - print ''; + print ''; - if ($user->rights->societe->client->voir) - { + if ($user->rights->societe->client->voir) + { $facture = new Facture($db); - print ''; + print ''; // Liste de Autres factures - $var=true; + $var=true; - $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber, f.datef as df"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut = 0"; - $sql.= " AND f.fk_user_author <> ".$user->id; - $sql.= " ORDER BY f.datec DESC, f.rowid DESC"; + $sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber, f.datef as df"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql.= " WHERE f.fk_soc = s.rowid"; + $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.fk_statut = 0"; + $sql.= " AND f.fk_user_author <> ".$user->id; + $sql.= " ORDER BY f.datec DESC, f.rowid DESC"; - $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $var=true; - print ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); + $result=$db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $var=true; + print '
'; + if ($num) + { + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ""; - print "\n"; - print "\n"; - print ""; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - print "'; - } - print "
factureid."\">$objp->facnumbersocid."\">".dol_trunc($objp->nom,24)."".$langs->trans("Qty"); - print "'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherDraftBills"); - print '
"; - $db->free($result); - } - else - { - dol_print_error($db); - } + $var=!$var; + print '
'; + print ''; + print ''; + print ""; + print "factureid."\">$objp->facnumber\n"; + print "socid."\">".dol_trunc($objp->nom,24)."\n"; + print "".$langs->trans("Qty"); + print ""; + print ''; + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print ''; + print ''; + print '
'; + $i++; + } + } + else + { + print ""; + print $langs->trans("NoOtherDraftBills"); + print ''; + } + print ""; + $db->free($result); + } + else + { + dol_print_error($db); + } - print ''; - } + print ''; + } - print ''; - } + print ''; + } - print ''; + print ''; - print '
'; + print '
'; } diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index a692ad5328f..5be0bee72fc 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -258,7 +258,7 @@ else print ""; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); - if ($conf->barcode->enabled) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "p.barcode",$param,"","",$sortfield,$sortorder); + if ($conf->barcode->enabled) print_liste_field_titre($langs->trans("BarCode"), $_SERVER["PHP_SELF"], "p.barcode",$param,'','',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateModification"), $_SERVER["PHP_SELF"], "p.tms",$param,"",'align="center"',$sortfield,$sortorder); if ($conf->service->enabled && $type != 0) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); if (empty($conf->global->PRODUIT_MULTIPRICES)) print_liste_field_titre($langs->trans("SellingPrice"), $_SERVER["PHP_SELF"], "p.price",$param,"",'align="right"',$sortfield,$sortorder); @@ -368,7 +368,7 @@ else // Barcode if ($conf->barcode->enabled) { - print ''.$objp->barcode.''; + print ''.$objp->barcode.''; } // Date diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 475d5430c0a..e7de512ade1 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -345,9 +345,10 @@ if ($_GET["id"] || $_GET["ref"]) print ''; print ''; - print ' '; - print ''; print ''; + + print '
 '; + print '
'; print ''; } @@ -381,9 +382,11 @@ if ($_GET["id"] || $_GET["ref"]) print ''; print ''; - print ' '; - print ''; print ''; + + print '
 '; + print '
'; + print ''; } From 8976e8e03d5a27c633b970b98b643277f489c28a Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 13:00:57 +0200 Subject: [PATCH 14/41] Look: Uniformize label of login/id --- htdocs/adherents/card_subscriptions.php | 2 +- htdocs/adherents/document.php | 2 +- htdocs/adherents/note.php | 2 +- htdocs/categories/categorie.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index ed9af86d8ad..e9e065125b7 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -495,7 +495,7 @@ if ($rowid) // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").''.$adh->login.' '; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").''.$adh->login.' '; print $showphoto; $showphoto=''; print ''; } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 91f8be836a3..4111d66e0ff 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -151,7 +151,7 @@ if ($id > 0) // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").''.$member->login.' '; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").''.$member->login.' '; } // Morphy diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index c7a2c2f6735..731a2412b83 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -99,7 +99,7 @@ if ($id) // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").''.$adh->login.' '; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").''.$adh->login.' '; } // Morphy diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 2d758fd42b6..ee0bf083dc1 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -382,7 +382,7 @@ else if ($_GET["id"] || $_GET["ref"]) // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").''.$member->login.' '; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").''.$member->login.' '; } // Morphy From 4d4be413afa009ab8b103c6aef431a0e093977b0 Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 13:23:10 +0200 Subject: [PATCH 15/41] Can search on part of barcode --- ChangeLog | 1 + htdocs/cashdesk/affIndex.php | 24 +----------------------- htdocs/cashdesk/facturation.php | 6 +++--- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1aae2199336..208706b57d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ For users: - New: Can build PDF in USLetter format or canada format. - New: Can export into Excel 2007 format. - New: Add hidden option CASHDESK_FORCE_STOCK_ON_BILL +- New: Can search on part of barcode into POS module. For developers: - Qual: Removed no more used external libraries. diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php index 2e6e1adf56a..d6ec051ceb3 100644 --- a/htdocs/cashdesk/affIndex.php +++ b/htdocs/cashdesk/affIndex.php @@ -35,6 +35,7 @@ if ( $_SESSION['uid'] <= 0 ) $langs->load("cashdesk"); + /* * View */ @@ -47,29 +48,6 @@ $arrayofcss=array('/cashdesk/css/style.css'); top_htmlhead($head,$langs->trans("CashDesk"),0,0,$arrayofjs,$arrayofcss); -/* -print ''; - -print ''."\n"; -print ''."\n"; -print ''.$langs->trans("CashDesk").''."\n"; - -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; - -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -*/ print ''."\n"; if (!empty($error)) diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index 7682e89b57d..d61c1cb6f84 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008-2009 Laurent Destailleur + * Copyright (C) 2008-2011 Laurent Destailleur * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -36,9 +36,9 @@ if ( $_GET['filtre'] ) { $sql.= " WHERE p.tosell = 1"; if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0"; $sql.= " AND (p.ref LIKE '%".$_GET['filtre']."%' OR p.label LIKE '%".$_GET['filtre']."%' "; - if ($conf->barcode->enabled) $sql.= " OR p.barcode='".$_GET['filtre']."')"; + if ($conf->barcode->enabled) $sql.= " OR p.barcode LIKE '%".$_GET['filtre']."%')"; else $sql.= ")"; - + $sql.= " ORDER BY label"; dol_syslog("facturation.php sql=".$sql); From 79546fa072d4603663a11c3869246a64cc2579f0 Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 21:55:40 +0200 Subject: [PATCH 16/41] Qual: Uniformize look of supplier invoice with customer invoice --- htdocs/compta/facture.php | 14 +- htdocs/core/class/html.form.class.php | 46 +- htdocs/core/class/html.formfile.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 59 +- htdocs/fourn/facture/fiche.php | 1848 ++++++++--------- htdocs/lib/fourn.lib.php | 11 +- htdocs/lib/invoice.lib.php | 8 +- 7 files changed, 962 insertions(+), 1026 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index da3f0c5adb8..f86d78c14b2 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -79,9 +79,9 @@ $hookmanager=new HookManager($db); $hookmanager->callHooks(array('invoicecard')); -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ +/* + * Actions + */ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -239,7 +239,7 @@ if ($action == 'setmode') { $object->fetch($id); $result=$object->mode_reglement($_POST['mode_reglement_id']); - if ($result < 0) dol_print_error($object->db,$object->error); + if ($result < 0) dol_print_error($db,$object->error); } if ($action == 'setinvoicedate') @@ -248,7 +248,7 @@ if ($action == 'setinvoicedate') $object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']); if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date; $result=$object->update($user); - if ($result < 0) dol_print_error($object->db,$object->error); + if ($result < 0) dol_print_error($db,$object->error); } if ($action == 'setpaymentterm') @@ -256,14 +256,14 @@ if ($action == 'setpaymentterm') $object->fetch($id); $date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']); $result=$object->cond_reglement($object->cond_reglement_id,$date_lim_reglement); - if ($result < 0) dol_print_error($object->db,$object->error); + if ($result < 0) dol_print_error($db,$object->error); } if ($action == 'setconditions') { $object->fetch($id); $result=$object->cond_reglement($_POST['cond_reglement_id']); - if ($result < 0) dol_print_error($object->db,$object->error); + if ($result < 0) dol_print_error($db,$object->error); } if ($action == 'setremisepercent' && $user->rights->facture->creer) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3ea6ccb3d79..4a861d0eb3a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -97,14 +97,14 @@ class Form * @param string $preselected Preselected value for parameter * @param string $paramkey Key of parameter (unique if there is several parameter to show) * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'text', ...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'text', 'day', ...) * @param string $editvalue Use this value instead $preselected * @return string HTML edit field * TODO no GET or POST in class file, use a param */ function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string',$editvalue='') { - global $langs; + global $langs,$db; $ret=''; if (GETPOST('action') == 'edit'.$htmlname) { @@ -123,14 +123,20 @@ class Form { $ret.=''; } + else if ($typeofdata == 'day') + { + $html=new Form($db); + $ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname); + } $ret.=''; - $ret.=''; + if ($typeofdata != 'day') $ret.=''; $ret.=''."\n"; $ret.=''."\n"; } else { if ($typeofdata == 'email') $ret.=dol_print_email($preselected,0,0,0,0,1); + if ($typeofdata == 'day') $ret.=dol_print_date($preselected,'day'); else $ret.=$preselected; } return $ret; @@ -238,7 +244,7 @@ class Form /** * Return combo list of activated countries, into language of user - * + * * @param selected Id or Code or Label of preselected country * @param htmlname Name of html select object * @param htmloption Options html on select object @@ -250,7 +256,7 @@ class Form /** * Return combo list of activated countries, into language of user - * + * * @param selected Id or Code or Label of preselected country * @param htmlname Name of html select object * @param htmloption Options html on select object @@ -320,7 +326,7 @@ class Form /** * Retourne la liste des types de comptes financiers - * + * * @param selected Type pre-selectionne * @param htmlname Nom champ formulaire */ @@ -356,7 +362,7 @@ class Form /** * Return list of social contributions. * Use mysoc->pays_id or mysoc->pays_code so they must be defined. - * + * * @param selected Preselected type * @param htmlname Name of field in form * @param useempty Set to 1 if we want an empty value @@ -426,7 +432,7 @@ class Form /** * Return list of types of lines (product or service) * Example: 0=product, 1=service, 9=other (for external module) - * + * * @param selected Preselected type * @param htmlname Name of field in html form * @param showempty Add an empty field @@ -517,7 +523,7 @@ class Form /** * Output html form to select a third party - * + * * @param selected Preselected type * @param htmlname Name of field in form * @param filter Optionnal filters criteras @@ -532,7 +538,7 @@ class Form /** * Output html form to select a third party - * + * * @param selected Preselected type * @param htmlname Name of field in form * @param filter Optionnal filters criteras @@ -608,7 +614,7 @@ class Form /** * Return HTML combo list of absolute discounts - * + * * @param selected Id remise fixe pre-selectionnee * @param htmlname Nom champ formulaire * @param filter Criteres optionnels de filtre @@ -674,7 +680,7 @@ class Form /** * Return list of all contacts (for a third party or all) - * + * * @param socid Id ot third party or 0 for all * @param selected Id contact pre-selectionne * @param htmlname Name of HTML field ('none' for a not editable field) @@ -900,7 +906,7 @@ class Form /** * Return list of products for customer in Ajax if Ajax activated or go to select_produits_do - * + * * @param selected Preselected products * @param htmlname Name of HTML seletc field (must be unique in page) * @param filtertype Filter on product type (''=nofilter, 0=product, 1=service) @@ -1425,7 +1431,7 @@ class Form /** * Return list of delivery address - * + * * @param string $selected Id contact pre-selectionn * @param int $socid Id of company * @param string $htmlname Name of HTML field @@ -1477,7 +1483,7 @@ class Form /** * Charge dans cache la liste des conditions de paiements possibles - * + * * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko */ function load_cache_conditions_paiements() @@ -1516,7 +1522,7 @@ class Form /** * Charge dans cache la liste des délais de livraison possibles - * + * * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko */ function load_cache_availability() @@ -1555,7 +1561,7 @@ class Form /** * Retourne la liste des types de delais de livraison possibles - * + * * @param selected Id du type de delais pre-selectionne * @param htmlname Nom de la zone select * @param filtertype To add a filter @@ -1588,7 +1594,7 @@ class Form /** * Load into cache cache_demand_reason, array of input reasons - * + * * @return int Nb of lines loaded, 0 if already loaded, <0 if ko */ function load_cache_demand_reason() @@ -1632,7 +1638,7 @@ class Form /** * Return list of events that triggered an object creation - * + * * @param selected Id du type d'origine pre-selectionne * @param htmlname Nom de la zone select * @param exclude To exclude a code value (Example: SRC_PROP) @@ -1667,7 +1673,7 @@ class Form /** * Charge dans cache la liste des types de paiements possibles - * + * * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko */ function load_cache_types_paiements() diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 54a4f7f2bb0..4d842d78c6d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -432,7 +432,7 @@ class FormFile if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && $modulepart != 'unpaid') { $langs->load("errors"); - $out.= ' '.img_warning($langs->trans("WarningNoDocumentModelActivated")); + $out.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); } $out.= ''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 1f529dcedc4..0c8e7e8324b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -57,10 +57,10 @@ class FactureFournisseur extends Facture var $author; var $libelle; - var $datec; - var $tms; - var $date; - var $date_echeance; + var $datec; // Creation date + var $tms; // Last update date + var $date; // Invoice date + var $date_echeance; // Max payment date var $amount; var $remise; var $tva; @@ -184,17 +184,18 @@ class FactureFournisseur extends Facture { $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); - $this->updateline($idligne, - $this->lines[$i]->description, - $this->lines[$i]->pu_ht, - $this->lines[$i]->tva_tx, - $this->lines[$i]->localtax1_tx, - $this->lines[$i]->localtax2_tx, - $this->lines[$i]->qty, - $this->lines[$i]->fk_product, - 'HT', - $this->lines[$i]->info_bits, - $this->lines[$i]->product_type + $this->updateline( + $idligne, + $this->lines[$i]->description, + $this->lines[$i]->pu_ht, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->qty, + $this->lines[$i]->fk_product, + 'HT', + $this->lines[$i]->info_bits, + $this->lines[$i]->product_type ); } } @@ -246,10 +247,12 @@ class FactureFournisseur extends Facture /** * Load object in memory from database - * @param id id object - * @return int <0 if KO, >0 if OK + * + * @param int $id Id supplier invoice + * @param string $ref Ref supplier invoice + * @return int <0 if KO, >0 if OK */ - function fetch($id) + function fetch($id='',$ref='') { global $langs; $sql = "SELECT"; @@ -287,7 +290,9 @@ class FactureFournisseur extends Facture $sql.= " t.import_key,"; $sql.= ' s.nom as socnom, s.rowid as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t,'.MAIN_DB_PREFIX.'societe as s'; - $sql.= ' WHERE t.rowid='.$id.' AND t.fk_soc = s.rowid'; + if ($id) $sql.= " WHERE t.rowid=".$id; + if ($ref) $sql.= " WHERE t.rowid='".$this->db->escape($ref)."'"; // ref is id (facnumber is supplier ref) + $sql.= ' AND t.fk_soc = s.rowid'; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); @@ -369,8 +374,9 @@ class FactureFournisseur extends Facture /** - * \brief Load this->lines - * \return int 1 si ok, < 0 si erreur + * Load this->lines + * + * @return int 1 si ok, < 0 si erreur */ function fetch_lines() { @@ -433,10 +439,11 @@ class FactureFournisseur extends Facture /** - * \brief Update database - * \param user User that modify - * \param notrigger 0=launch triggers after, 1=disable triggers - * \return int <0 if KO, >0 if OK + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK */ function update($user=0, $notrigger=0) { @@ -486,7 +493,7 @@ class FactureFournisseur extends Facture $sql.= " fk_soc=".(isset($this->fk_soc)?$this->fk_soc:"null").","; $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql.= " datef=".(dol_strlen($this->date)!=0 ? "'".$this->db->idate($this->date)."'" : 'null').","; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + if (dol_strlen($this->tms) != 0) $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql.= " libelle=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " paye=".(isset($this->paye)?$this->paye:"null").","; $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 85d1aef932f..99688ccb13e 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -41,15 +41,16 @@ $langs->load('bills'); $langs->load('suppliers'); $langs->load('companies'); -$facid = GETPOST("facid"); +$mesg=''; +$facid=GETPOST("facid"); +$action=GETPOST("action"); // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'fournisseur', $facid, 'facture_fourn', 'facture'); -$html = new Form($db); -$mesg=''; -$action=GETPOST("action"); +$object=new FactureFournisseur($db); + /* @@ -57,7 +58,7 @@ $action=GETPOST("action"); */ // Action clone object -if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes') +if ($action == 'confirm_clone' && $_REQUEST['confirm'] == 'yes') { if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { @@ -65,8 +66,7 @@ if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes') } else { - $object=new FactureFournisseur($db); - $result=$object->createFromClone($_REQUEST['facid']); + $result=$object->createFromClone($facid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); @@ -82,24 +82,22 @@ if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes') } } -if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider) +if ($action == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider) { - $facturefourn=new FactureFournisseur($db); - $facturefourn->fetch($_GET['facid']); - $result = $facturefourn->validate($user); + $object->fetch($facid); + $result = $object->validate($user); if ($result < 0) { - $mesg='
'.$facturefourn->error.'
'; + $mesg='
'.$object->error.'
'; } } -if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') +if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') { if ($user->rights->fournisseur->facture->supprimer ) { - $facturefourn = new FactureFournisseur($db); - $factfournid = $_GET['facid']; - $result=$facturefourn->delete($factfournid); + $object->fetch($facid); + $result=$object->delete($facid); if ($result > 0) { Header('Location: index.php'); @@ -107,54 +105,67 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes') } else { - $mesg='
'.$facturefourn->error.'
'; + $mesg='
'.$object->error.'
'; } } } -if ($_REQUEST['action'] == 'confirm_deleteproductline' && $_REQUEST['confirm'] == 'yes') +if ($action == 'confirm_deleteproductline' && $_REQUEST['confirm'] == 'yes') { if ($user->rights->fournisseur->facture->creer) { - $facturefourn = new FactureFournisseur($db); - $facturefourn->fetch($facid); - $facturefourn->deleteline($_REQUEST['lineid']); + $object->fetch($facid); + $object->deleteline($_REQUEST['lineid']); $_GET['action'] = ''; } } -if ($_REQUEST['action'] == 'confirm_paid' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->facture->creer) +if ($action == 'confirm_paid' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->facture->creer) { - $facturefourn=new FactureFournisseur($db); - $facturefourn->fetch($_GET['facid']); - $result=$facturefourn->set_paid($user); + $object->fetch($facid); + $result=$object->set_paid($user); } // Set supplier ref -if (($_POST['action'] == 'setref_supplier' || $_POST['action'] == 'set_ref_supplier') && $user->rights->fournisseur->facture->creer) +if (($action == 'setref_supplier' || $action == 'set_ref_supplier') && $user->rights->fournisseur->facture->creer) { - $facturefourn = new FactureFournisseur($db); - $facturefourn->fetch($facid); - $result=$facturefourn->set_ref_supplier($user, $_POST['ref_supplier']); + $object->fetch($facid); + $result=$object->set_ref_supplier($user, $_POST['ref_supplier']); $_GET['facid']=$facid; } // Set supplier ref -if (($_POST['action'] == 'setlabel') && $user->rights->fournisseur->facture->creer) +if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) { - $facturefourn = new FactureFournisseur($db); - $facturefourn->fetch($facid); - $facturefourn->label=$_POST['label']; - $result=$facturefourn->update($user); + $object->fetch($facid); + $object->label=$_POST['label']; + $result=$object->update($user); if ($result < 0) dol_print_error($db); $_GET['facid']=$facid; } -if($_GET['action'] == 'deletepaiement') +if ($action == 'setdate' && $user->rights->fournisseur->facture->creer) { - $facfou = new FactureFournisseur($db); - $facfou->fetch($_GET['facid']); - if ($facfou->statut == 1 && $facfou->paye == 0 && $user->societe_id == 0) + $object->fetch($facid); + $object->date=dol_mktime(12,0,0,$_POST['datemonth'],$_POST['dateday'],$_POST['dateyear']); + if ($object->date_echeance < $object->date) $object->date_echeance=$object->date; + $result=$object->update($user); + if ($result < 0) dol_print_error($db,$object->error); +} +if ($action == 'setdate_echeance' && $user->rights->fournisseur->facture->creer) +{ + $object->fetch($facid); + $object->date_echeance=dol_mktime(12,0,0,$_POST['date_echeancemonth'],$_POST['date_echeanceday'],$_POST['date_echeanceyear']); + if ($object->date_echeance < $object->date) $object->date_echeance=$object->date; + $result=$object->update($user); + if ($result < 0) dol_print_error($db,$object->error); +} + +// Delete payment +if($action == 'deletepaiement') +{ + $object->fetch($_GET['facid']); + if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) { $paiementfourn = new PaiementFourn($db); $paiementfourn->fetch($_GET['paiement_id']); @@ -162,7 +173,7 @@ if($_GET['action'] == 'deletepaiement') } } -if ($_POST['action'] == 'update' && ! $_POST['cancel']) +if ($action == 'update' && ! $_POST['cancel']) { $error=0; @@ -194,24 +205,24 @@ if ($_POST['action'] == 'update' && ! $_POST['cancel']) /* * Action creation */ -if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) +if ($action == 'add' && $user->rights->fournisseur->facture->creer) { - $error=0; + $error=0; - $datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); $datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); if ($datefacture == '') { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')).'
'; - $_GET['action']='create'; + $action='create'; $_GET['socid']=$_POST['socid']; $error++; } if (! GETPOST('facnumber')) { $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')).'
'; - $_GET['action']='create'; + $action='create'; $_GET['socid']=$_POST['socid']; $error++; } @@ -221,104 +232,102 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) $db->begin(); // Creation facture - $facfou = new FactureFournisseur($db); - - $facfou->ref = $_POST['facnumber']; - $facfou->socid = $_POST['socid']; - $facfou->libelle = $_POST['libelle']; - $facfou->date = $datefacture; - $facfou->date_echeance = $datedue; - $facfou->note_public = $_POST['note']; + $object->ref = $_POST['facnumber']; + $object->socid = $_POST['socid']; + $object->libelle = $_POST['libelle']; + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = $_POST['note']; // If creation from another object of another module - if ($_POST['origin'] && $_POST['originid']) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = $_POST['origin']; - /*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - }*/ + if ($_POST['origin'] && $_POST['originid']) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $_POST['origin']; + /*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + }*/ - // For compatibility - if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } - if ($element == 'contract') { $element = $subelement = 'contrat'; } - if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } + // For compatibility + if ($element == 'order') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + if ($element == 'contract') { $element = $subelement = 'contrat'; } + if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } - $facfou->origin = $_POST['origin']; - $facfou->origin_id = $_POST['originid']; + $object->origin = $_POST['origin']; + $object->origin_id = $_POST['originid']; - $facid = $facfou->create($user); + $facid = $object->create($user); - // Add lines - if ($facid > 0) - { - require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'); - $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; - $srcobject = new $classname($db); + // Add lines + if ($facid > 0) + { + require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'); + $classname = ucfirst($subelement); + if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + $srcobject = new $classname($db); - $result=$srcobject->fetch($_POST['originid']); - if ($result > 0) - { - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + $result=$srcobject->fetch($_POST['originid']); + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); - $num=count($lines); - for ($i = 0; $i < $num; $i++) - { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $num=count($lines); + for ($i = 0; $i < $num; $i++) + { + $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); - // Dates - // TODO mutualiser - $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + // Dates + // TODO mutualiser + $date_start=$lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_end=$lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - $result = $facfou->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->qty, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->qty, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, 'HT', - $product_type - ); + $product_type + ); - if ($result < 0) - { - $error++; - break; - } - } - } - else - { - $error++; - } - } - else - { - $error++; - } - } - // If some invoice's lines already known - else - { - $facid = $facfou->create($user); + if ($result < 0) + { + $error++; + break; + } + } + } + else + { + $error++; + } + } + else + { + $error++; + } + } + // If some invoice's lines already known + else + { + $facid = $object->create($user); if ($facid < 0) { $error++; @@ -326,7 +335,7 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) if (! $error) { - for ($i = 1 ; $i < 9 ; $i++) + for ($i = 1 ; $i < 9 ; $i++) { $label = $_POST['label'.$i]; $amountht = price2num($_POST['amount'.$i]); @@ -346,22 +355,22 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) } $atleastoneline=1; - $product=new Product($db); - $product->fetch($_POST['idprod'.$i]); + $product=new Product($db); + $product->fetch($_POST['idprod'.$i]); - $ret=$facfou->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base); - if ($ret < 0) $error++; - } + $ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base); + if ($ret < 0) $error++; + } } - } + } } if ($error) { $langs->load("errors"); $db->rollback(); - $mesg='
'.$langs->trans($facfou->error).'
'; - $_GET['action']='create'; + $mesg='
'.$langs->trans($object->error).'
'; + $action='create'; $_GET['socid']=$_POST['socid']; } else @@ -373,21 +382,19 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) } } -if ($_GET['action'] == 'del_ligne') +if ($action == 'del_ligne') { - $facfou = new FactureFournisseur($db); - $facfou->fetch($_GET['facid']); - $facfou->deleteline($_GET['lineid']); - $_GET['action'] = 'edit'; + $object->fetch($_GET['facid']); + $object->deleteline($_GET['lineid']); + $action = 'edit'; } // Modification d'une ligne -if ($_REQUEST['action'] == 'update_line') +if ($action == 'update_line') { - if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification + if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification { - $facfou = new FactureFournisseur($db); - $facfou->fetch($_GET['facid']); + $object->fetch($_GET['facid']); if ($_POST['puht']) { @@ -413,18 +420,18 @@ if ($_REQUEST['action'] == 'update_line') } else { - if ($facfou->socid) - { - $societe=new Societe($db); - $societe->fetch($facfou->socid); - } + if ($object->socid) + { + $societe=new Societe($db); + $societe->fetch($object->socid); + } $label = $_POST['label']; $type = $_POST["type"]?$_POST["type"]:0; $localtax1tx= get_localtax($_POST['tauxtva'], 1, $societe); - $localtax2tx= get_localtax($_POST['tauxtva'], 2, $societe); + $localtax2tx= get_localtax($_POST['tauxtva'], 2, $societe); } - $result=$facfou->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type); + $result=$object->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type); if ($result >= 0) { unset($_POST['label']); @@ -432,25 +439,23 @@ if ($_REQUEST['action'] == 'update_line') } } -if ($_GET['action'] == 'addline') +if ($action == 'addline') { - $facfou = new FactureFournisseur($db); - $ret=$facfou->fetch($_GET['facid']); + $ret=$object->fetch($_GET['facid']); if ($ret < 0) { - dol_print_error($db,$facfou->error); + dol_print_error($db,$object->error); exit; } - if ($facfou->socid) - { - $societe=new Societe($db); - $societe->fetch($facfou->socid); - } + if ($object->socid) + { + $societe=new Societe($db); + $societe->fetch($object->socid); + } if ($_POST['idprodfournprice']) // > 0 or -1 { - $product = new ProductFournisseur($db); $idprod=$product->get_buyprice($_POST['idprodfournprice'], $_POST['qty']); if ($idprod > 0) { @@ -465,11 +470,11 @@ if ($_GET['action'] == 'addline') $tvatx=get_default_tva($societe,$mysoc,$product->id); $localtax1tx= get_localtax($tvatx, 1, $societe); - $localtax2tx= get_localtax($tvatx, 2, $societe); + $localtax2tx= get_localtax($tvatx, 2, $societe); $type = $product->type; - $result=$facfou->addline($label, $product->fourn_pu, $tvatx, $localtax2tx, $localtax2tx, $_POST['qty'], $idprod); + $result=$object->addline($label, $product->fourn_pu, $tvatx, $localtax2tx, $localtax2tx, $_POST['qty'], $idprod); } if ($idprod == -1) { @@ -481,8 +486,8 @@ if ($_GET['action'] == 'addline') else { $tauxtva = price2num($_POST['tauxtva']); - $localtax1tx= get_localtax($tauxtva, 1, $societe); - $localtax2tx= get_localtax($tauxtva, 2, $societe); + $localtax1tx= get_localtax($tauxtva, 1, $societe); + $localtax2tx= get_localtax($tauxtva, 2, $societe); if (! $_POST['label']) { @@ -497,14 +502,14 @@ if ($_GET['action'] == 'addline') $price_base_type = 'HT'; //$desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0) - $result=$facfou->addline($_POST['label'], $ht, $tauxtva, $localtax1tx, $localtax2tx, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type); + $result=$object->addline($_POST['label'], $ht, $tauxtva, $localtax1tx, $localtax2tx, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type); } else { $ttc = price2num($_POST['amountttc']); $ht = $ttc / (1 + ($tauxtva / 100)); $price_base_type = 'HT'; - $result=$facfou->addline($_POST['label'], $ht, $tauxtva,$localtax1tx, $localtax2tx, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type); + $result=$object->addline($_POST['label'], $ht, $tauxtva,$localtax1tx, $localtax2tx, $_POST['qty'], 0, 0, $datestart, $dateend, 0, 0, $price_base_type, $type); } } } @@ -529,35 +534,33 @@ if ($_GET['action'] == 'addline') unset($_POST['pu']); unset($_POST['tva_tx']); unset($_POST['label']); - unset($localtax1_tx); - unset($localtax2_tx); + unset($localtax1_tx); + unset($localtax2_tx); } else if (empty($mesg)) { - $mesg='
'.$facfou->error.'
'; + $mesg='
'.$object->error.'
'; } - $_GET['action'] = ''; + $action = ''; } -if ($_POST['action'] == 'classin') +if ($action == 'classin') { - $facture = new FactureFournisseur($db); - $facture->fetch($_GET['facid']); - $result=$facture->setProject($_POST['projectid']); + $object->fetch($_GET['facid']); + $result=$object->setProject($_POST['projectid']); } // Repasse la facture en mode brouillon -if ($_GET['action'] == 'edit' && $user->rights->fournisseur->facture->creer) +if ($action == 'edit' && $user->rights->fournisseur->facture->creer) { - $fac = new FactureFournisseur($db); - $fac->fetch($_GET['facid']); + $object->fetch($_GET['facid']); // On verifie si la facture a des paiements $sql = 'SELECT pf.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf'; - $sql.= ' WHERE pf.fk_facturefourn = '.$fac->id; + $sql.= ' WHERE pf.fk_facturefourn = '.$object->id; $result = $db->query($sql); if ($result) @@ -573,15 +576,15 @@ if ($_GET['action'] == 'edit' && $user->rights->fournisseur->facture->creer) } } - $resteapayer = $fac->total_ttc - $totalpaye; + $resteapayer = $object->total_ttc - $totalpaye; // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees - //$ventilExportCompta = $fac->getVentilExportCompta(); + //$ventilExportCompta = $object->getVentilExportCompta(); // On verifie si aucun paiement n'a ete effectue - if ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0) + if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) { - $fac->set_draft($user); + $object->set_draft($user); $outputlangs = $langs; if (! empty($_REQUEST['lang_id'])) @@ -589,18 +592,17 @@ if ($_GET['action'] == 'edit' && $user->rights->fournisseur->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - //supplier_invoice_pdf_create($db, $fac->id, $fac->modelpdf, $outputlangs); + //supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); } } -if ($_GET['action'] == 'reopen' && $user->rights->fournisseur->facture->creer) +if ($action == 'reopen' && $user->rights->fournisseur->facture->creer) { - $fac = new FactureFournisseur($db); - $result = $fac->fetch($_GET['facid']); - if ($fac->statut == 2 - || ($fac->statut == 3 && $fac->close_code != 'replaced')) + $result = $object->fetch($_GET['facid']); + if ($object->statut == 2 + || ($object->statut == 3 && $object->close_code != 'replaced')) { - $result = $fac->set_unpaid($user); + $result = $object->set_unpaid($user); if ($result > 0) { Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_GET['facid']); @@ -608,18 +610,11 @@ if ($_GET['action'] == 'reopen' && $user->rights->fournisseur->facture->creer) } else { - $mesg='
'.$fac->error.'
'; + $mesg='
'.$object->error.'
'; } } } - -/********************************************************************* - * - * Mail Actions - * - **********************************************************************/ - /* * Add file in email form */ @@ -633,8 +628,7 @@ if ($_POST['addfile']) $mesg=dol_add_file_process($upload_dir_tmp,0,0); - $_GET["action"]='presend'; - $_POST["action"]='presend'; + $action='presend'; } /* @@ -650,23 +644,21 @@ if (! empty($_POST['removedfile'])) $mesg=dol_remove_file_process($_POST['removedfile'],0); - $_GET["action"]='presend'; - $_POST["action"]='presend'; + $action='presend'; } /* * Send mail */ -if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) +if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { $langs->load('mails'); - $facturefourn=new FactureFournisseur($db); - $facturefourn->fetch($_GET['facid']); - $result=$facturefourn->fetch_thirdparty(); + $object->fetch($_GET['facid']); + $result=$object->fetch_thirdparty(); if ($result > 0) { - $ref = dol_sanitizeFileName($facturefourn->ref); + $ref = dol_sanitizeFileName($object->ref); $file = $conf->fournisseur->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; if (is_readable($file)) @@ -682,12 +674,12 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] // Recipient was provided from combo list if ($_POST['receiver'] == 'thirdparty') // Id of third party { - $sendto = $facturefourn->client->email; + $sendto = $object->client->email; $sendtoid = 0; } else // Id du contact { - $sendto = $facturefourn->client->contact_get_property($_POST['receiver'],'email'); + $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); $sendtoid = $_POST['receiver']; } } @@ -702,10 +694,10 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] $sendtocc = $_POST['sendtocc']; $deliveryreceipt = $_POST['deliveryreceipt']; - if ($_POST['action'] == 'send') + if ($action == 'send') { if (dol_strlen($_POST['subject'])) $subject=$_POST['subject']; - else $subject = $langs->transnoentities('CustomerOrder').' '.$facturefourn->ref; + else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref; $actiontypecode='AC_SUP_ORD'; $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; if ($message) @@ -743,17 +735,17 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] $error=0; // Initialisation donnees - $facturefourn->sendtoid = $sendtoid; - $facturefourn->actiontypecode = $actiontypecode; - $facturefourn->actionmsg = $actionmsg; - $facturefourn->actionmsg2 = $actionmsg2; - $facturefourn->fk_element = $facturefourn->id; - $facturefourn->elementtype = $facturefourn->element; + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($db); - $result=$interface->run_triggers('BILL_SUPPLIER_SENTBYMAIL',$facturefourn,$user,$langs,$conf); + $result=$interface->run_triggers('BILL_SUPPLIER_SENTBYMAIL',$object,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers @@ -765,7 +757,7 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] { // Redirect here // This avoid sending mail twice if going out and then back to page - Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facturefourn->id.'&mesg='.urlencode($mesg)); + Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&mesg='.urlencode($mesg)); exit; } } @@ -808,26 +800,20 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] dol_syslog('Unable to read data from the invoice. The invoice file has perhaps not been generated.'); } - //$_GET['action'] = 'presend'; + //$action = 'presend'; } /* * Build document */ -if ($_REQUEST['action'] == 'builddoc') +if ($action == 'builddoc') { - /* - * Generation de la facture - * definit dans /includes/modules/supplier_invoice/modules_facturefournisseur.php - */ - // Save modele used - $facture=new FactureFournisseur($db); - $facture->fetch($_REQUEST['facid']); + $object->fetch($_REQUEST['facid']); if ($_REQUEST['model']) { - $facture->setDocModel($user, $_REQUEST['model']); + $object->setDocModel($user, $_REQUEST['model']); } $outputlangs = $langs; @@ -836,7 +822,7 @@ if ($_REQUEST['action'] == 'builddoc') $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - $result=supplier_invoice_pdf_create($db, $facture,$facture->modelpdf,$outputlangs); + $result=supplier_invoice_pdf_create($db, $object,$object->modelpdf,$outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -844,18 +830,17 @@ if ($_REQUEST['action'] == 'builddoc') } else { - Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facture->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } // Delete file in doc form -if ($action=='remove_file') +if ($action == 'remove_file') { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); - $facture = new FactureFournisseur($db); - if ($facture->fetch($id)) + if ($object->fetch($id)) { $upload_dir = $conf->fournisseur->facture->dir_output . "/"; $file = $upload_dir . '/' . $_GET['file']; @@ -869,17 +854,17 @@ if ($action=='remove_file') * View */ -llxHeader('','',''); - +$html = new Form($db); $formfile = new FormFile($db); +llxHeader('','',''); // Mode creation -if ($_GET['action'] == 'create') +if ($action == 'create') { print_fiche_titre($langs->trans('NewBill')); - if ($mesg) { print $mesg.'
'; } + dol_htmloutput_mesg($mesg); $societe=''; if ($_GET['socid']) @@ -888,53 +873,53 @@ if ($_GET['action'] == 'create') $societe->fetch($_GET['socid']); } - if (GETPOST('origin') && GETPOST('originid')) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = GETPOST('origin'); + if (GETPOST('origin') && GETPOST('originid')) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = GETPOST('origin'); - if ($element == 'project') - { + if ($element == 'project') + { $projectid=GETPOST('originid'); - } - else if (in_array($element,array('order_supplier'))) - { - // For compatibility - if ($element == 'order') { $element = $subelement = 'commande'; } - if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } - if ($element == 'contract') { $element = $subelement = 'contrat'; } - if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } + } + else if (in_array($element,array('order_supplier'))) + { + // For compatibility + if ($element == 'order') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + if ($element == 'contract') { $element = $subelement = 'contrat'; } + if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } - require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'); - $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; - $objectsrc = new $classname($db); - $objectsrc->fetch(GETPOST('originid')); - $objectsrc->fetch_thirdparty(); + require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'); + $classname = ucfirst($subelement); + if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + $objectsrc = new $classname($db); + $objectsrc->fetch(GETPOST('originid')); + $objectsrc->fetch_thirdparty(); - $projectid = (!empty($objectsrc->fk_project)?$object->fk_project:''); - //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); + $projectid = (!empty($objectsrc->fk_project)?$object->fk_project:''); + //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); - $soc = $objectsrc->client; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $soc = $objectsrc->client; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); + $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); - $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); - } - } - else - { - $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); - $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); - } + $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); + $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + $datedue=($datetmp==''?-1:$datetmp); + } + } + else + { + $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); + $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + $datedue=($datetmp==''?-1:$datetmp); + } print '
'; print ''; @@ -943,10 +928,10 @@ if ($_GET['action'] == 'create') print ''; print ''; - // Ref - print ''; + // Ref + print ''; - // Third party + // Third party print ''; print ''; print ''; - print ''; - // Label + // Label print ''; // Date invoice @@ -1058,7 +1043,7 @@ if ($_GET['action'] == 'create') print ''; // Due date - print ''; @@ -1066,68 +1051,68 @@ if ($_GET['action'] == 'create') print ''; print ''; - if (is_object($objectsrc)) - { - print "\n"; - print "\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; + if (is_object($objectsrc)) + { + print "\n"; + print "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; - $txt=$langs->trans($classname); - if ($classname=='CommandeFournisseur') $txt=$langs->trans("SupplierOrder"); - print ''; - print ''; - print '"; - if ($mysoc->pays_code=='ES') - { - if ($mysoc->localtax1_assuj=="1") //Localtax1 RE - { - print '"; - } + $txt=$langs->trans($classname); + if ($classname=='CommandeFournisseur') $txt=$langs->trans("SupplierOrder"); + print ''; + print ''; + print '"; + if ($mysoc->pays_code=='ES') + { + if ($mysoc->localtax1_assuj=="1") //Localtax1 RE + { + print '"; + } - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF - { - print '"; - } - } - print '"; - } + if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF + { + print '"; + } + } + print '"; + } else { - if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - for ($i = 1 ; $i < 9 ; $i++) - { - $value_qty = '1'; - $value_tauxtva = ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } + for ($i = 1 ; $i < 9 ; $i++) + { + $value_qty = '1'; + $value_tauxtva = ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + } } - // Bouton "Create Draft" - print "
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('ThirdParty').''; @@ -965,91 +950,91 @@ if ($_GET['action'] == 'create') print '
'.$langs->trans('RefSupplier').'
'.$langs->trans('Type').''; - print ''."\n"; + print ''; + // Credit note + print ''."\n"; + */ + print '
'.$langs->trans('Type').''; + print ''."\n"; - // Standard invoice - print ''."\n"; + // Standard invoice + print ''."\n"; - /* - // Deposit - print ''."\n"; + /* + // Deposit + print ''."\n"; - // Proforma - if ($conf->global->FACTURE_USE_PROFORMAT) - { - print ''."\n"; - } + // Proforma + if ($conf->global->FACTURE_USE_PROFORMAT) + { + print ''."\n"; + } - // Replacement - print ''; + // Replacement + print ''; - // Credit note - print ''."\n"; -*/ - print '
'; - print ''; - print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); + print $desc; + print '
'; - print ''; - print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $desc=$html->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); + print $desc; + print '
'; - print ''; - print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceProForma"),$langs->transnoentities("InvoiceProFormaDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $desc=$html->textwithpicto($langs->trans("InvoiceProForma"),$langs->transnoentities("InvoiceProFormaDesc"),1); + print $desc; + print '
'; - print ''; - print ''; - $text=$langs->trans("InvoiceReplacementAsk").' '; - $text.=''; - $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); - print $desc; - print '
'; + print ''; + print ''; + $text=$langs->trans("InvoiceReplacementAsk").' '; + $text.=''; + $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + print $desc; + print '
'; - print ''; - print ''; - $text=$langs->transnoentities("InvoiceAvoirAsk").' '; - // $text.=''; - $text.=''; - $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); - //.' ('.$langs->trans("FeatureNotYetAvailable").')',$langs->transnoentities("InvoiceAvoirDesc"),1); - print $desc; - print '
'; - print '
'; + print ''; + print ''; + $text=$langs->transnoentities("InvoiceAvoirAsk").' '; + // $text.=''; + $text.=''; + $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); + //.' ('.$langs->trans("FeatureNotYetAvailable").')',$langs->transnoentities("InvoiceAvoirDesc"),1); + print $desc; + print '
'; + print '
'.$langs->trans('Label').'
'.$langs->trans('DateEcheance').''; + print '
'.$langs->trans('DateMaxPayment').''; $html->select_date($datedue,'ech','','','',"add",1,1); print '
'.$txt.''.$objectsrc->getNomUrl(1).'
'.$langs->trans('TotalHT').''.price($objectsrc->total_ht).'
'.$langs->trans('TotalVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1",$mysoc->pays_code).''.price($objectsrc->total_localtax1)."
'.$txt.''.$objectsrc->getNomUrl(1).'
'.$langs->trans('TotalHT').''.price($objectsrc->total_ht).'
'.$langs->trans('TotalVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1",$mysoc->pays_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2",$mysoc->pays_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
'.$langs->transcountry("AmountLT2",$mysoc->pays_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
 '.$langs->trans('Label').''.$langs->trans('PriceUHT').''.$langs->trans('VAT').''.$langs->trans('Qty').''.$langs->trans('PriceUTTC').'
 '.$langs->trans('Label').''.$langs->trans('PriceUHT').''.$langs->trans('VAT').''.$langs->trans('Qty').''.$langs->trans('PriceUTTC').'
'.$i.''; - print $html->load_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc); - print '
'.$i.''; + print $html->load_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc); + print '
\n"; + // Bouton "Create Draft" + print "\n"; - print '
'; + print '
'; - print "
\n"; + print "\n"; } else { @@ -1149,598 +1134,529 @@ else $societe = new Fournisseur($db); $societe->fetch($fac->socid); - if ($_GET['action'] == 'edit') + /* + * View card + */ + $head = facturefourn_prepare_head($fac); + $titre=$langs->trans('SupplierInvoice'); + dol_fiche_head($head, 'card', $titre, 0, 'bill'); + + dol_htmloutput_mesg($mesg); + + // Confirmation de la suppression d'une ligne produit + if ($action == 'confirm_delete_line') { - print_fiche_titre($langs->trans('SupplierInvoice')); - - print '
'; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - // Ref - print ''; - $rownb=10; - print ''; - - // Ref supplier - print ''; - print ''; - - // Label - print ''; - - // Date invoice - print ''; - - // Due date - print ''; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print '
'.$langs->trans('Company').''.$societe->getNomUrl(1).''.$langs->trans('NotePublic').'
'.$langs->trans('Ref').''; - print $fac->ref.''; - print '
'.$langs->trans('RefSupplier').''; - print '
'.$langs->trans('Label').''; - print '
'.$langs->trans('DateInvoice').''; - $html->select_date($fac->datep,'','','','',"update",1,1); - print '
'.$langs->trans('DateEcheance').''; - $html->select_date($fac->date_echeance,'ech','','','',"update",1,1); - if (($fac->paye == 0) && ($fac->statut > 0) && $fac->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning"); - print '
'.$langs->trans('AmountHT').''.price($fac->total_ht).'
'.$langs->trans('AmountVAT').''.price($fac->total_tva).'
'.$langs->trans('AmountTTC').''.price($fac->total_ttc).'
'.$langs->trans('Status').''.$fac->getLibStatut(4).'
'; - print ''; - print '     '; - print ''; - - print '
'; - print '
'; - - print ''; + $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline', '', 1, 1); + if ($ret == 'html') print '
'; } - else + + // Clone confirmation + if ($action == 'clone') { - /* - * View card - */ - $head = facturefourn_prepare_head($fac); - $titre=$langs->trans('SupplierInvoice'); - dol_fiche_head($head, 'card', $titre, 0, 'bill'); + // Create an array for form + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) + ); + // Paiement incomplet. On demande si motif = escompte ou autre + $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$fac->ref),'confirm_clone',$formquestion,'yes', 1); + if ($ret == 'html') print '
'; + } - if ($mesg) { print $mesg.'
'; } + // Confirmation de la validation + if ($action == 'valid') + { + $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $fac->ref), 'confirm_valid', '', 0, 1); + if ($ret == 'html') print '
'; + } - // Confirmation de la suppression d'une ligne produit - if ($_GET['action'] == 'confirm_delete_line') + // Confirmation set paid + if ($action == 'paid') + { + $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $fac->ref), 'confirm_paid', '', 0, 1); + if ($ret == 'html') print '
'; + } + + /* + * Confirmation de la suppression de la facture fournisseur + */ + if ($action == 'delete') + { + $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); + if ($ret == 'html') print '
'; + } + + + /* + * Facture + */ + print ''; + + // Ref + print ''; + print "\n"; + + // Ref supplier + print ''; + + // Third party + print ''; + print ''; + + // Type + print ''; - /* - * Facture - */ - print '
'.$langs->trans("Ref").''; + print $html->showrefnav($fac,'facid','',1,'rowid','ref',$morehtmlref); + print '
'.$html->editfieldkey("RefSupplier",'ref_supplier',$fac->ref_supplier,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)).''; + print $html->editfieldval("RefSupplier",'ref_supplier',$fac->ref_supplier,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)); + print '
'.$langs->trans('Supplier').''.$societe->getNomUrl(1); + print '   ('.$langs->trans('OtherBills').')
'.$langs->trans('Type').''; + print $fac->getLibType(); + if ($fac->type == 1) + { + $facreplaced=new FactureFournisseur($db); + $facreplaced->fetch($fac->fk_facture_source); + print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; + } + if ($fac->type == 2) + { + $facusing=new FactureFournisseur($db); + $facusing->fetch($fac->fk_facture_source); + print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')'; + } + + $facidavoir=$fac->getListIdAvoirFromInvoice(); + if (count($facidavoir) > 0) + { + print ' ('.$langs->transnoentities("InvoiceHasAvoir"); + $i=0; + foreach($facidavoir as $id) { - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline', '', 1, 1); - if ($ret == 'html') print '
'; - } - - // Clone confirmation - if ($_GET["action"] == 'clone') - { - // Create an array for form - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$fac->ref),'confirm_clone',$formquestion,'yes', 1); - if ($ret == 'html') print '
'; - } - - // Confirmation de la validation - if ($_GET['action'] == 'valid') - { - $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ValidateBill'), $langs->trans('ConfirmValidateBill', $fac->ref), 'confirm_valid', '', 0, 1); - if ($ret == 'html') print '
'; - } - - // Confirmation set paid - if ($_GET['action'] == 'paid') - { - $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $fac->ref), 'confirm_paid', '', 0, 1); - if ($ret == 'html') print '
'; - } - - /* - * Confirmation de la suppression de la facture fournisseur - */ - if ($_GET['action'] == 'delete') - { - $ret=$html->form_confirm('fiche.php?facid='.$fac->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1); - if ($ret == 'html') print '
'; + if ($i==0) print ' '; + else print ','; + $facavoir=new FactureFournisseur($db); + $facavoir->fetch($id); + print $facavoir->getNomUrl(1); } + print ')'; + } + if ($facidnext > 0) + { + $facthatreplace=new FactureFournisseur($db); + $facthatreplace->fetch($facidnext); + print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; + } + print '
'; + // Label + print ''; - // Ref - print ''; - print "\n"; + /* + * List of payments + */ + $nbrows=7; + if ($conf->projet->enabled) $nbrows++; - // Ref supplier - print ''; + // Local taxes + if ($mysoc->pays_code=='ES') + { + if($mysoc->localtax1_assuj=="1") $nbrow++; + if($mysoc->localtax2_assuj=="1") $nbrow++; + } - // Third party - print ''; + print ''; + print ''; - /* - * Lines - */ - print '
'; - print '
'.$html->editfieldkey("Label",'label',$fac->label,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)).''; + print $html->editfieldval("Label",'label',$fac->label,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)); + print '
'.$langs->trans("Ref").''; - print $html->showrefnav($fac,'facid','',1,'rowid','ref',$morehtmlref); - print '
'.$html->editfieldkey("RefSupplier",'ref_supplier',$fac->ref_supplier,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)).''; - print $html->editfieldval("RefSupplier",'ref_supplier',$fac->ref_supplier,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)); - print '
'.$langs->trans('Supplier').''.$societe->getNomUrl(1); - print '   ('.$langs->trans('OtherBills').')'; + $sql = 'SELECT datep as dp, pf.amount,'; + $sql .= ' c.libelle as paiement_type, p.num_paiement, p.rowid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; + $sql .= ' WHERE pf.fk_facturefourn = '.$fac->id; + $sql .= ' ORDER BY dp DESC'; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; $totalpaye = 0; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - // Type - print ''; - - - // Label - print ''; - - /* - * List of payments - */ - $nbrows=7; - if ($conf->projet->enabled) $nbrows++; - - // Local taxes - if ($mysoc->pays_code=='ES') - { - if($mysoc->localtax1_assuj=="1") $nbrow++; - if($mysoc->localtax2_assuj=="1") $nbrow++; - } - - print ''; - - - print ''; - - // Date - print ''; - - // Due date - print ''; - print ''; - - // Status - $alreadypaid=$fac->getSommePaiement(); - print ''; - - print ''; - print ''; - - // Amount Local Taxes - if ($mysoc->pays_code=='ES') - { - if ($mysoc->localtax1_assuj=="1") //Localtax1 RE - { - print ''; - print ''; - print ''; - } - if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF - { - print ''; - print ''; - print ''; - } - } - print ''; - - // Project - if ($conf->projet->enabled) - { - $langs->load('projects'); - print ''; - print ''; print ''; + $totalpaye += $objp->amount; + $i++; } + if ($fac->paye == 0) + { + print ''; + print ''; + + $resteapayer = $fac->total_ttc - $totalpaye; + + print ''; + print ''; + } print '
'.$langs->trans('Payments').''.$langs->trans('Type').''.$langs->trans('Amount').' 
'.$langs->trans('Type').''; - print $fac->getLibType(); - if ($fac->type == 1) + $var=True; + while ($i < $num) { - $facreplaced=new FactureFournisseur($db); - $facreplaced->fetch($fac->fk_facture_source); - print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; - } - if ($fac->type == 2) - { - $facusing=new FactureFournisseur($db); - $facusing->fetch($fac->fk_facture_source); - print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')'; - } - - $facidavoir=$fac->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) - { - print ' ('.$langs->transnoentities("InvoiceHasAvoir"); - $i=0; - foreach($facidavoir as $id) - { - if ($i==0) print ' '; - else print ','; - $facavoir=new FactureFournisseur($db); - $facavoir->fetch($id); - print $facavoir->getNomUrl(1); - } - print ')'; - } - if ($facidnext > 0) - { - $facthatreplace=new FactureFournisseur($db); - $facthatreplace->fetch($facidnext); - print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; - } - print '
'.$html->editfieldkey("Label",'label',$fac->label,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)).''; - print $html->editfieldval("Label",'label',$fac->label,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer)); - print ''; - $sql = 'SELECT datep as dp, pf.amount,'; - $sql .= ' c.libelle as paiement_type, p.num_paiement, p.rowid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid'; - $sql .= ' WHERE pf.fk_facturefourn = '.$fac->id; - $sql .= ' ORDER BY dp DESC'; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $totalpaye = 0; - print ''; - print ''; - print ''; - print ''; - + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print '\n"; + print ''; + print ''; + print ' '; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print '\n"; - print ''; - print ''; - - if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) - { - print ''; - } - - print ''; - $totalpaye += $objp->amount; - $i++; - } - - if ($fac->paye == 0) - { - print ''; - print ''; - - $resteapayer = $fac->total_ttc - $totalpaye; - - print ''; - print ''; - } - print '
'.$langs->trans('Payments').''.$langs->trans('Type').'
'.img_object($langs->trans('ShowPayment'),'payment').' '.dol_print_date($db->jdate($objp->dp),'day')."'.$objp->paiement_type.' '.$objp->num_paiement.''.price($objp->amount).''; if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) { - $tdsup=' colspan="2"'; - } - print ''.$langs->trans('AmountTTC').'
'.img_object($langs->trans('ShowPayment'),'payment').' '.dol_print_date($db->jdate($objp->dp),'day')."'.$objp->paiement_type.' '.$objp->num_paiement.''.price($objp->amount).' '.$langs->trans('Currency'.$conf->monnaie).''; - print ''; - print img_delete(); - print '
'.$langs->trans('AlreadyPaid').' :'.price($totalpaye).' '.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans("Billed").' :'.price($fac->total_ttc).' '.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('RemainderToPay').' :'.price($resteapayer).' '.$langs->trans('Currency'.$conf->monnaie).'
'; - $db->free($result); - } - else - { - dol_print_error($db); - } - print '
'.$langs->trans('Date').''; - print dol_print_date($fac->datep,'daytext').'
'.$langs->trans('DateEcheance').''; - print dol_print_date($fac->date_echeance,'daytext'); - if (($fac->paye == 0) && ($fac->statut > 0) && $fac->date_echeance && $fac->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning"); - print '
'.$langs->trans('Status').''.$fac->getLibStatut(4,$alreadypaid).'
'.$langs->trans('AmountHT').''.price($fac->total_ht).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountVAT').''.price($fac->total_tva).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->transcountry("AmountLT1",$mysoc->pays_code).''.price($fac->total_localtax1).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->transcountry("AmountLT2",$mysoc->pays_code).''.price($fac->total_localtax2).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($fac->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'
'; - - print ''; - if ($_GET['action'] != 'classify') - { - print ''; - } - print '
'; - print $langs->trans('Project'); - print 'id.'">'; - print img_edit($langs->trans('SetProject'),1); - print '
'; - - print '
'; - if ($_GET['action'] == 'classify') - { - $html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->fk_project,'projectid'); - } - else - { - $html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->fk_project,'none'); + print ''; + print img_delete(); + print ''; } print '
'.$langs->trans('AlreadyPaid').' :'.price($totalpaye).'
'.$langs->trans("Billed").' :'.price($fac->total_ttc).'
'.$langs->trans('RemainderToPay').' :'.price($resteapayer).'
'; + $db->free($result); + } + else + { + dol_print_error($db); + } + print '
'; - $var=1; - $num=count($fac->lines); - for ($i = 0; $i < $num; $i++) + // Date + print ''; + + // Due date + print ''; + + // Status + $alreadypaid=$fac->getSommePaiement(); + print ''; + + print ''; + print ''; + + // Amount Local Taxes + if ($mysoc->pays_code=='ES') + { + if ($mysoc->localtax1_assuj=="1") //Localtax1 RE { - if ($i == 0) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - - // Show product and description - $type=$fac->lines[$i]->product_type?$fac->lines[$i]->product_type:$fac->lines[$i]->fk_product_type; - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fac->lines[$i]->date_start)) $type=1; - if (! empty($fac->lines[$i]->date_end)) $type=1; - - $var=!$var; - - // Edit line - if ($fac->statut == 0 && $_GET['action'] == 'mod_ligne' && $_GET['etat'] == '0' && $_GET['lineid'] == $fac->lines[$i]->rowid) - { - print 'lines[$i]->rowid.'" method="post">'; - print ''; - print ''; - print ''; - - // Show product and description - print ''; - - // VAT - print ''; - - // Unit price - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - print ''; - } - else // Affichage simple de la ligne - { - print ''; - - // Show product and description - print ''; - - // VAT - print ''; - - // Unit price - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - } - + print ''; + print ''; + print ''; } - - /* - * Form to add new line - */ - - if ($fac->statut == 0 && $_GET['action'] != 'mod_ligne') + if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF { - print ''; - print ''; + print ''; + print ''; + print ''; + } + } + print ''; + + // Project + if ($conf->projet->enabled) + { + $langs->load('projects'); + print ''; + print ''; + print ''; + } + + print '
'.$html->editfieldkey("Date",'date',$fac->datep,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer && $fac->getSommePaiement() <= 0)).''; + print $html->editfieldval("Date",'date',$fac->datep,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer && $fac->getSommePaiement() <= 0),'day'); + print '
'.$html->editfieldkey("DateMaxPayment",'date_echeance',$fac->date_echeance,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer && $fac->getSommePaiement() <= 0)).''; + print $html->editfieldval("DateMaxPayment",'date_echeance',$fac->date_echeance,'facid',$fac->id,($fac->statut<2 && $user->rights->fournisseur->facture->creer && $fac->getSommePaiement() <= 0),'day'); + print '
'.$langs->trans('Status').''.$fac->getLibStatut(4,$alreadypaid).'
'.$langs->trans('AmountHT').''.price($fac->total_ht).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountVAT').''.price($fac->total_tva).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Label').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('TotalHTShort').''.$langs->trans('TotalTTCShort').'  
'; - if (($conf->product->enabled || $conf->service->enabled) && $fac->lines[$i]->fk_product) - { - print ''; - $product_static=new ProductFournisseur($db); - $product_static->fetch($fac->lines[$i]->fk_product); - $text=$product_static->getNomUrl(1); - $text.= ' - '.$product_static->libelle; - print $text; - print '
'; - } - else - { - print $html->select_type_of_lines($fac->lines[$i]->product_type,'type',1); - if ($conf->product->enabled && $conf->service->enabled) print '
'; - } - - // Description - Editor wysiwyg - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('label',$fac->lines[$i]->description,'',128,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); - $doleditor->Create(); - print '
'; - print $html->load_tva('tauxtva',$fac->lines[$i]->tva_tx,$societe,$mysoc); - print '  '; - print '
'; - if ($fac->lines[$i]->fk_product) - { - print ''; // ancre pour retourner sur la ligne - - $product_static=new ProductFournisseur($db); - $product_static->fetch($fac->lines[$i]->fk_product); - $text=$product_static->getNomUrl(1); - $text.= ' - '.$product_static->libelle; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($fac->lines[$i]->description)); - print $html->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end); - - // Add description in form - if ($conf->global->PRODUIT_DESC_IN_FORM) print ($fac->lines[$i]->description && $fac->lines[$i]->description!=$product_static->libelle)?'
'.dol_htmlentitiesbr($fac->lines[$i]->description):''; - } - - // Description - Editor wysiwyg - if (! $fac->lines[$i]->fk_product) - { - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($fac->lines[$i]->description); - - // Show range - print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end); - } - print '
'.vatrate($fac->lines[$i]->tva_tx).'%'.price($fac->lines[$i]->pu_ht,'MU').''.($fac->lines[$i]->pu_ttc?price($fac->lines[$i]->pu_ttc,'MU'):' ').''.$fac->lines[$i]->qty.''.price($fac->lines[$i]->total_ht).''.price($fac->lines[$i]->total_ttc).''; - if ($fac->statut == 0) print ''.img_edit().''; - else print ' '; - print ''; - if ($fac->statut == 0) print ''.img_delete().''; - else print ' '; - print '
'.$langs->transcountry("AmountLT1",$mysoc->pays_code).''.price($fac->total_localtax1).''.$langs->trans("Currency".$conf->monnaie).'
'; - print ''; // ancre - print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").'
'.$langs->transcountry("AmountLT2",$mysoc->pays_code).''.price($fac->total_localtax2).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($fac->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'
'; + + print ''; + if ($action != 'classify') + { + print ''; + } + print '
'; + print $langs->trans('Project'); + print 'id.'">'; + print img_edit($langs->trans('SetProject'),1); + print '
'; + + print '
'; + if ($action == 'classify') + { + $html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->fk_project,'projectid'); + } + else + { + $html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->fk_project,'none'); + } + print '
'; + + + /* + * Lines + */ + print '
'; + print ''; + $var=1; + $num=count($fac->lines); + for ($i = 0; $i < $num; $i++) + { + if ($i == 0) + { + print ''; print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; + } - // Add free products/services form - print ''; + // Show product and description + $type=$fac->lines[$i]->product_type?$fac->lines[$i]->product_type:$fac->lines[$i]->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fac->lines[$i]->date_start)) $type=1; + if (! empty($fac->lines[$i]->date_end)) $type=1; + + $var=!$var; + + // Edit line + if ($fac->statut == 0 && $action == 'mod_ligne' && $_GET['etat'] == '0' && $_GET['lineid'] == $fac->lines[$i]->rowid) + { + print 'lines[$i]->rowid.'" method="post">'; print ''; - print ''; - print ''; - - $var=true; + print ''; print ''; + + // Show product and description print ''; - print ''; + // VAT print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + + // Unit price + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; print ''; + } + else // Affichage simple de la ligne + { + print ''; - // Ajout de produits/services predefinis - if ($conf->product->enabled || $conf->service->enabled) + // Show product and description + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; // ancre pour retourner sur la ligne - print ''; - print ''; - print ''; - print ''; - print ''; - $var=! $var; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $product_static=new ProductFournisseur($db); + $product_static->fetch($fac->lines[$i]->fk_product); + $text=$product_static->getNomUrl(1); + $text.= ' - '.$product_static->libelle; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($fac->lines[$i]->description)); + print $html->textwithtooltip($text,$description,3,'','',$i); + + // Show range + print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end); + + // Add description in form + if ($conf->global->PRODUIT_DESC_IN_FORM) print ($fac->lines[$i]->description && $fac->lines[$i]->description!=$product_static->libelle)?'
'.dol_htmlentitiesbr($fac->lines[$i]->description):''; } + + // Description - Editor wysiwyg + if (! $fac->lines[$i]->fk_product) + { + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.nl2br($fac->lines[$i]->description); + + // Show range + print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end); + } + print ''; + + // VAT + print ''; + + // Unit price + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; } - print '
'.$langs->trans('Label').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').'  '.$langs->trans('TotalHTShort').''.$langs->trans('TotalTTCShort').'  
'; + if (($conf->product->enabled || $conf->service->enabled) && $fac->lines[$i]->fk_product) + { + print ''; + $product_static=new ProductFournisseur($db); + $product_static->fetch($fac->lines[$i]->fk_product); + $text=$product_static->getNomUrl(1); + $text.= ' - '.$product_static->libelle; + print $text; + print '
'; + } + else + { + print $html->select_type_of_lines($fac->lines[$i]->product_type,'type',1); + if ($conf->product->enabled && $conf->service->enabled) print '
'; + } - $forceall=1; // For suppliers, we always show all types - print $html->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1,0,$forceall); - if ($forceall || ($conf->product->enabled && $conf->service->enabled) - || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '
'; - - // Editor wysiwyg + // Description - Editor wysiwyg require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $nbrows=ROWS_2; if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('label',GETPOST("label"),'',100,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor=new DolEditor('label',$fac->lines[$i]->description,'',128,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); $doleditor->Create(); + print '
'; - print $html->load_tva('tauxtva',($_POST["tauxtva"]?$_POST["tauxtva"]:-1),$societe,$mysoc); + print $html->load_tva('tauxtva',$fac->lines[$i]->tva_tx,$societe,$mysoc); print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '  
  '; + print '
'; + if ($fac->lines[$i]->fk_product) { - print '
'; - print $langs->trans("AddNewLine").' - '; - if ($conf->service->enabled) - { - print $langs->trans('RecordedProductsAndServices'); - } - else - { - print $langs->trans('RecordedProducts'); - } - print ''.$langs->trans('Qty').'  
'; - $html->select_produits_fournisseurs($fac->socid,'','idprodfournprice','',$filtre); - print '  
'.vatrate($fac->lines[$i]->tva_tx).'%'.price($fac->lines[$i]->pu_ht,'MU').''.($fac->lines[$i]->pu_ttc?price($fac->lines[$i]->pu_ttc,'MU'):' ').''.$fac->lines[$i]->qty.''.price($fac->lines[$i]->total_ht).''.price($fac->lines[$i]->total_ttc).''; + if ($fac->statut == 0) print ''.img_edit().''; + else print ' '; + print ''; + if ($fac->statut == 0) print ''.img_delete().''; + else print ' '; + print '
'; - - print ''; } - if ($_GET['action'] != 'presend') + /* + * Form to add new line + */ + + if ($fac->statut == 0 && $action != 'mod_ligne') + { + print ''; + print ''; + print ''; // ancre + print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").''; + print ''.$langs->trans('VAT').''; + print ''.$langs->trans('PriceUHT').''; + print ''.$langs->trans('PriceUTTC').''; + print ''.$langs->trans('Qty').''; + print ' '; + print ' '; + print ' '; + print ' '; + print ''; + + // Add free products/services form + print '
'; + print ''; + print ''; + print ''; + + $var=true; + print ''; + print ''; + + $forceall=1; // For suppliers, we always show all types + print $html->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1,0,$forceall); + if ($forceall || ($conf->product->enabled && $conf->service->enabled) + || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '
'; + + // Editor wysiwyg + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $doleditor=new DolEditor('label',GETPOST("label"),'',100,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor->Create(); + + print ''; + print ''; + print $html->load_tva('tauxtva',($_POST["tauxtva"]?$_POST["tauxtva"]:-1),$societe,$mysoc); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ' '; + print ' '; + print ''; + print '
'; + + // Ajout de produits/services predefinis + if ($conf->product->enabled || $conf->service->enabled) + { + print ''; + print ''; + print $langs->trans("AddNewLine").' - '; + if ($conf->service->enabled) + { + print $langs->trans('RecordedProductsAndServices'); + } + else + { + print $langs->trans('RecordedProducts'); + } + print ''; + print ''.$langs->trans('Qty').''; + print ' '; + print ' '; + print ''; + + print '
'; + print ''; + print ''; + print ''; + print ''; + $var=! $var; + print ''; + print ''; + $html->select_produits_fournisseurs($fac->socid,'','idprodfournprice','',$filtre); + print ''; + print ''; + print ' '; + print ' '; + print ''; + print ''; + print '
'; + } + } + + print ''; + + print ''; + + if ($action != 'presend') { /* @@ -1762,12 +1678,6 @@ else } } - //Modify - if ($_GET['action'] != 'edit' && $fac->statut <= 1 && $fac->getSommePaiement() <= 0 && $user->rights->fournisseur->facture->creer) - { - print ''.$langs->trans('Modify').''; - } - // Send by mail if (($fac->statut == 1 || $fac->statut == 2)) { @@ -1780,13 +1690,13 @@ else //Make payments - if ($_GET['action'] != 'edit' && $fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) + if ($action != 'edit' && $fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) { print ''.$langs->trans('DoPayment').''; } //Classify paid - if ($_GET['action'] != 'edit' && $fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) + if ($action != 'edit' && $fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) { print ''.$langs->trans('ClassifyPaid').''; @@ -1795,7 +1705,7 @@ else } //Validate - if ($_GET['action'] != 'edit' && $fac->statut == 0) + if ($action != 'edit' && $fac->statut == 0) { if (count($fac->lines)) { @@ -1813,19 +1723,19 @@ else } //Clone - if ($_GET['action'] != 'edit' && $user->rights->fournisseur->facture->creer) + if ($action != 'edit' && $user->rights->fournisseur->facture->creer) { print ''.$langs->trans('ToClone').''; } //Delete - if ($_GET['action'] != 'edit' && $user->rights->fournisseur->facture->supprimer) + if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) { print ''.$langs->trans('Delete').''; } print ''; - if ($_GET['action'] != 'edit') + if ($action != 'edit') { print '"; From 47bb2171e0f32b56472f1756778939f890729db1 Mon Sep 17 00:00:00 2001 From: eldy Date: Tue, 4 Oct 2011 01:26:07 +0200 Subject: [PATCH 24/41] Fix: Fix a serious database default. Table llx_product_fournisseur was linked with llx_product_fournisseur_price with a link 1-1 so was useless. I removed it. This reduce a lot of sophisticated code and will make import of prices easier. This also increase speed. --- htdocs/core/class/html.form.class.php | 29 +-- htdocs/fourn/class/fournisseur.class.php | 10 +- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 2 - .../fourn/class/fournisseur.product.class.php | 246 ++++-------------- htdocs/fourn/facture/fiche.php | 4 +- htdocs/fourn/product/liste.php | 13 +- .../install/mysql/migration/3.1.0-3.2.0.sql | 16 ++ .../tables/llx_product_fournisseur.key.sql | 27 -- .../mysql/tables/llx_product_fournisseur.sql | 39 --- .../llx_product_fournisseur_price.key.sql | 11 +- .../tables/llx_product_fournisseur_price.sql | 9 +- .../service/actions_card_service.class.php | 4 +- htdocs/product/class/product.class.php | 75 +++--- htdocs/product/fournisseurs.php | 55 ++-- htdocs/product/liste.php | 6 +- htdocs/product/reassort.php | 13 +- 17 files changed, 178 insertions(+), 383 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_product_fournisseur.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_product_fournisseur.sql diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bda5bddf78c..dc96679132e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1207,16 +1207,14 @@ class Form $langs->load('stocks'); $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,"; - $sql.= " pf.ref_fourn,"; - $sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,"; + $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,"; $sql.= " s.nom"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pf.fk_soc = s.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pf.rowid = pfp.fk_product_fournisseur"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; $sql.= " WHERE p.entity = ".$conf->entity; $sql.= " AND p.tobuy = 1"; - if ($socid) $sql.= " AND pf.fk_soc = ".$socid; + if ($socid) $sql.= " AND pfp.fk_soc = ".$socid; if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype; if (! empty($filtre)) $sql.=" ".$filtre; // Add criteria on ref/label @@ -1224,14 +1222,14 @@ class Form { if (! empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) { - $sql.=" AND (pf.ref_fourn LIKE '".$filterkey."%' OR p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%')"; + $sql.=" AND (pfp.ref_fourn LIKE '".$filterkey."%' OR p.ref LIKE '".$filterkey."%' OR p.label LIKE '".$filterkey."%')"; } else { - $sql.=" AND (pf.ref_fourn LIKE '%".$filterkey."%' OR p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%')"; + $sql.=" AND (pfp.ref_fourn LIKE '%".$filterkey."%' OR p.ref LIKE '%".$filterkey."%' OR p.label LIKE '%".$filterkey."%')"; } } - $sql.= " ORDER BY pf.ref_fourn DESC"; + $sql.= " ORDER BY pfp.ref_fourn DESC"; // Build output string $outselect=''; @@ -1354,17 +1352,16 @@ class Form $langs->load('stocks'); $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,"; - $sql.= " pf.ref_fourn,"; - $sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,"; + $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,"; $sql.= " s.nom"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = pf.fk_soc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pf.rowid = pfp.fk_product_fournisseur"; - $sql.= " WHERE p.tobuy = 1"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; + $sql.= " WHERE p.entity = ".$conf->entity; + $sql.= " AND p.tobuy = 1"; $sql.= " AND s.fournisseur = 1"; $sql.= " AND p.rowid = ".$productid; - $sql.= " ORDER BY s.nom, pf.ref_fourn DESC"; + $sql.= " ORDER BY s.nom, pfp.ref_fourn DESC"; dol_syslog("Form::select_product_fourn_price sql=".$sql,LOG_DEBUG); $result=$this->db->query($sql); diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 05f29d6956a..8d94a59f270 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -78,12 +78,14 @@ class Fournisseur extends Societe return $num; } + /** + * FIXME This returns number of prices, not number of products. Is it what we want ? + */ function NbProduct() { - $sql = "SELECT count(pf.rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur as pf,"; - $sql.= " ".MAIN_DB_PREFIX."product_fournisseur_price as ppf"; - $sql .= " WHERE fk_soc = ".$this->id." AND ppf.fk_product_fournisseur = pf.rowid"; + $sql = "SELECT count(pfp.rowid)"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= " WHERE pfp.fk_soc = ".$this->id; $resql = $this->db->query($sql); if ( $resql ) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7ee68dd62e2..f92cd5b2f00 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1822,7 +1822,7 @@ class CommandeFournisseurLigne extends OrderLine var $libelle; // Label produit var $product_desc; // Description produit - // From llx_product_fournisseur + // From llx_product_fournisseur_price var $ref_fourn; // Ref supplier diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 0c8e7e8324b..f407958435a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -384,10 +384,8 @@ class FactureFournisseur extends Facture $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; - //$sql.= ', pf.ref_fourn'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; - //$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur as pf ON f.fk_product = pf.fk_product'; $sql.= ' WHERE fk_facture_fourn='.$this->id; dol_syslog("FactureFournisseur::fetch_lines sql=".$sql, LOG_DEBUG); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index bf522ab6680..7582969cd99 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -72,87 +72,31 @@ class ProductFournisseur extends Product $this->db->begin(); - // Search all links - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; dol_syslog(get_class($this)."::remove_fournisseur sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) + $resql2=$this->db->query($sql); + if (! $resql2) { - // For each link, delete price line - while ($obj=$this->db->fetch_object($resql)) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_product_fournisseur = ".$obj->rowid; - - dol_syslog(get_class($this)."::remove_fournisseur sql=".$sql); - $resql2=$this->db->query($sql); - if (! $resql2) - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::remove_fournisseur ".$this->error, LOG_ERR); - $ok=0; - } - } - - // Now delete all link supplier-product (they have no more childs) - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur"; - $sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; - - dol_syslog(get_class($this)."::remove_fournisseur sql=".$sql); - $resql=$this->db->query($sql); - if (! $resql) - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::remove_fournisseur ".$this->error, LOG_ERR); - $ok=0; - } - - if ($ok) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::remove_fournisseur ".$this->error, LOG_ERR); + $ok=0; } - else - { - $this->db->rollback(); - dol_print_error($this->db); - return -2; - } - } - - - /** - * Remove supplier product - * - * @param rowid Product id - * @return int < 0 if error, > 0 if ok - */ - function remove_product_fournisseur($rowid) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur"; - $sql.= " WHERE rowid = ".$rowid; - - dol_syslog(get_class($this)."::remove_product_fournisseur sql=".$sql); - $resql = $this->db->query($sql); - if ($resql) + + if ($ok) { + $this->db->commit(); return 1; } else { + $this->db->rollback(); return -1; } } + /** * Remove a price for a couple supplier-product * @@ -172,54 +116,8 @@ class ProductFournisseur extends Product $resql = $this->db->query($sql); if ($resql) { - // Remove all entries with no childs - $sql = "SELECT pf.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur as pf"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pfp.fk_product_fournisseur = pf.rowid"; - $sql.= " WHERE pfp.rowid IS NULL"; - $sql.= " AND pf.entity = ".$conf->entity; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price sql=".$sql); - $resql = $this->db->query($sql); - if ($resql) - { - $ok=1; - - while ($obj=$this->db->fetch_object($resql)) - { - $rowidpf=$obj->rowid; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur"; - $sql.= " WHERE rowid = ".$rowidpf; - - dol_syslog(get_class($this)."::remove_product_fournisseur_price sql=".$sql); - $resql2 = $this->db->query($sql); - if (! $resql2) - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::remove_product_fournisseur_price ".$this->error,LOG_ERR); - $ok=0; - } - } - - if ($ok) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -3; - } - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::remove_product_fournisseur_price ".$this->error,LOG_ERR); - $this->db->rollback(); - return -2; - } + $this->db->commit(); + return 1; } else { @@ -234,16 +132,18 @@ class ProductFournisseur extends Product /** * Modify the purchase price for a supplier * - * @param qty Min quantity for which price is valid - * @param buyprice Purchase price for the quantity min - * @param user Object user user made changes - * @param price_base_type HT or TTC - * @param fourn Supplier - * @param availability Product availability + * @param int $qty Min quantity for which price is valid + * @param float $buyprice Purchase price for the quantity min + * @param User $user Object user user made changes + * @param string $price_base_type HT or TTC + * @param Societe $fourn Supplier + * @param int $availability Product availability + * @param string $ref_fourn Supplier ref + * @return int >0 if KO, >0 if OK */ - function update_buyprice($qty, $buyprice, $user, $price_base_type='HT', $fourn, $availability) + function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn) { - global $mysoc; + global $conf,$mysoc; // Clean parameter $buyprice=price2num($buyprice); @@ -259,11 +159,6 @@ class ProductFournisseur extends Product { $sql.= " WHERE rowid = ".$this->product_fourn_price_id; } - else - { - $sql.= " WHERE fk_product_fournisseur = ".$this->product_fourn_id; - $sql.= " AND quantity = ".$qty; - } $resql=$this->db->query($sql); if ($resql) @@ -279,14 +174,17 @@ class ProductFournisseur extends Product // Ajoute prix courant du fournisseur pour cette quantite $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql.= "datec, fk_product_fournisseur, fk_user, price, quantity, unitprice, fk_availability)"; + $sql.= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, unitprice, fk_availability, entity)"; $sql.= " values('".$this->db->idate($now)."',"; - $sql.= " ".$this->product_fourn_id.","; + $sql.= " ".$this->id.","; + $sql.= " ".$fourn->id.","; + $sql.= " '".$this->db->escape($ref_fourn)."',"; $sql.= " ".$user->id.","; $sql.= " ".price2num($buyprice).","; $sql.= " ".$qty.","; $sql.= " ".$unitBuyPrice.","; - $sql.= " ".$availability; + $sql.= " ".$availability.","; + $sql.= $conf->entity; $sql.=")"; dol_syslog(get_class($this)."::update_buyprice sql=".$sql); @@ -295,7 +193,7 @@ class ProductFournisseur extends Product $error++; } - if (! $error) + /*if (! $error) { // Ajoute modif dans table log $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; @@ -313,6 +211,7 @@ class ProductFournisseur extends Product $error++; } } + */ if (! $error) { @@ -335,44 +234,6 @@ class ProductFournisseur extends Product } - /** - * Changes the purchase price for a supplier of the product in the reference supplier - * - * @param id_fourn Supplier ID - * @param product_fourn_ref Supplier ref product - * @param qty Amount for which the price is valid - * @param buyprice Purchase price for the quantity - * @param user Object user user made changes - * @return int <0 if KO, >0 if OK - */ - function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user, $price_base_type='HT') - { - global $conf; - - $result=0; - - // Recherche id produit pour cette ref et fournisseur - $sql = "SELECT fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur"; - $sql.= " WHERE fk_soc = '".$id_fourn."'"; - $sql.= " AND ref_fourn = '".$product_fourn_ref."'"; - $sql.= " AND entity = ".$conf->entity; - - $resql=$this->db->query($sql); - if ($resql) - { - if ($obj = $this->db->fetch_object($resql)) - { - // Met a jour prix pour la qte - $this->id = $obj->fk_product; - $result = $this->update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type); - } - } - - return $result; - } - - /** * Load information about a provider * @@ -387,7 +248,7 @@ class ProductFournisseur extends Product if (empty($fournid)) return -1; $sql = "SELECT rowid, ref_fourn"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur "; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE fk_product = ".$this->id; $sql.= " AND fk_soc = ".$fournid; $sql.= " AND entity = ".$conf->entity; @@ -398,7 +259,7 @@ class ProductFournisseur extends Product { $result = $this->db->fetch_array($result); $this->ref_fourn = $result["ref_fourn"]; - $this->product_fourn_id = $result["rowid"]; + $this->product_fourn_price_id = $result["rowid"]; return 1; } else @@ -417,12 +278,10 @@ class ProductFournisseur extends Product */ function fetch_product_fournisseur_price($rowid) { - $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability"; - $sql.= ", pf.rowid as product_fourn_id, pf.fk_soc, pf.ref_fourn, pf.fk_product"; + $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability,"; + $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf"; $sql.= " WHERE pfp.rowid = ".$rowid; - $sql.= " AND pf.rowid = pfp.fk_product_fournisseur"; dol_syslog(get_class($this)."::fetch_product_fournisseur_price sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -432,7 +291,6 @@ class ProductFournisseur extends Product if ($obj) { $this->product_fourn_price_id = $rowid; - $this->product_fourn_id = $obj->product_fourn_id; $this->fourn_ref = $obj->ref_fourn; $this->fourn_price = $obj->price; $this->fourn_qty = $obj->quantity; @@ -462,26 +320,24 @@ class ProductFournisseur extends Product * @param int $rowid id du produit * @return array Array of ProductFournisseur */ - function fetch_product_fournisseur($prodid) + function list_product_fournisseur_price($prodid) { global $conf; // Suppliers list $sql = "SELECT s.nom as supplier_name, "; $sql.= " s.rowid as fourn_id,"; - $sql.= " pf.ref_fourn,"; + $sql.= " pfp.ref_fourn,"; $sql.= " pfp.rowid as product_fourn_pri_id, "; - $sql.= " pf.rowid as product_fourn_id, "; $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON pf.fk_soc = s.rowid "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " ON pf.rowid = pfp.fk_product_fournisseur"; + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql.= " ON pfp.fk_soc = s.rowid"; $sql.= " WHERE s.entity = ".$conf->entity; - $sql.= " AND pf.fk_product = ".$prodid; + $sql.= " AND pfp.fk_product = ".$prodid; $sql.= " ORDER BY s.nom, pfp.quantity"; - dol_syslog(get_class($this)."::fetch_product_fournisseur sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::list_product_fournisseur_price sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -526,7 +382,7 @@ class ProductFournisseur extends Product else { $this->error=$this->db->error(); - dol_syslog(get_class($this)."::fetch_product_fournisseur error=".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::list_product_fournisseur_price error=".$this->error, LOG_ERR); return -1; } } @@ -551,18 +407,15 @@ class ProductFournisseur extends Product $this->fourn_name = ''; $this->id = ''; - $sql = "SELECT s.nom as supplier_name, "; + $sql = "SELECT s.nom as supplier_name,"; $sql.= " s.rowid as fourn_id,"; - $sql.= " pf.ref_fourn,"; - $sql.= " pfp.rowid as product_fourn_pri_id, "; - $sql.= " pf.rowid as product_fourn_id, "; + $sql.= " pfp.ref_fourn,"; + $sql.= " pfp.rowid as product_fourn_price_id,"; $sql.= " pfp.price, pfp.quantity, pfp.unitprice"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " ON pf.rowid = pfp.fk_product_fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE s.entity = ".$conf->entity; - $sql.= " AND pf.fk_product = ".$prodid; - $sql.= " AND pf.fk_soc = s.rowid"; + $sql.= " AND pfp.fk_product = ".$prodid; + $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " ORDER BY pfp.unitprice"; $sql.= $this->db->plimit(1); @@ -572,8 +425,7 @@ class ProductFournisseur extends Product if ($resql) { $record = $this->db->fetch_array($resql); - $this->product_fourn_price_id = $record["product_fourn_pri_id"]; - $this->product_fourn_id = $record["product_fourn_id"]; + $this->product_fourn_price_id = $record["product_fourn_price_id"]; $this->fourn_ref = $record["ref_fourn"]; $this->fourn_price = $record["price"]; $this->fourn_qty = $record["quantity"]; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 99688ccb13e..54bfe5806a3 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -456,7 +456,9 @@ if ($action == 'addline') if ($_POST['idprodfournprice']) // > 0 or -1 { + $product=new Product($db); $idprod=$product->get_buyprice($_POST['idprodfournprice'], $_POST['qty']); + if ($idprod > 0) { $result=$product->fetch($idprod); @@ -465,8 +467,6 @@ if ($action == 'addline') // $label = '['.$product->ref.'] - '. $product->libelle; $label = $product->libelle; - - $tvatx=get_default_tva($societe,$mysoc,$product->id); $localtax1tx= get_localtax($tvatx, 1, $societe); diff --git a/htdocs/fourn/product/liste.php b/htdocs/fourn/product/liste.php index aa9da42af53..d8ffeaf3f14 100644 --- a/htdocs/fourn/product/liste.php +++ b/htdocs/fourn/product/liste.php @@ -88,17 +88,15 @@ if ($fourn_id) } $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type,"; -$sql .= " pf.fk_soc, pf.ref_fourn,"; -$sql .= " ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; +$sql .= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; $sql .= " s.rowid as socid, s.nom"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if ($catid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; } -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = pf.fk_soc"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON ppf.fk_product_fournisseur = pf.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as ppf ON p.rowid = ppf.fk_product"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ppf.fk_soc = s.rowid"; if ($_POST["mode"] == 'search') { @@ -118,7 +116,7 @@ else } if ($sRefSupplier) { - $sql .= " AND pf.ref_fourn like '%".$sRefSupplier."%'"; + $sql .= " AND ppf.ref_fourn like '%".$sRefSupplier."%'"; } if ($snom) { @@ -128,11 +126,10 @@ else { $sql .= " AND cp.fk_categorie = ".$catid; } - } if ($fourn_id > 0) { - $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; + $sql .= " AND ppf.fk_soc = ".$fourn_id; } $sql .= " ORDER BY ".$sortfield." ".$sortorder; $sql .= $db->plimit($limit + 1 ,$offset); diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index 7b42303d9ba..a60961dee63 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -48,3 +48,19 @@ INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (220, 'CAP5', 'Format Canadian P5', '140', '215', 'mm', 1); INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (225, 'CAP6', 'Format Canadian P6', '107', '140', 'mm', 1); + + +ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_product integer after tms; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN fk_soc integer after fk_product; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN ref_fourn varchar(30) after fk_soc; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN entity integer DEFAULT 1 NOT NULL; + +UPDATE llx_product_fournisseur_price as a, llx_product_fournisseur as b SET a.fk_product = b.fk_product, a.fk_soc = b.fk_soc, a.ref_fourn = b.ref_fourn, a.entity = b.entity WHERE a.fk_product_fournisseur = b.rowid AND (a.fk_product IS NULL OR a.fk_soc IS NULL OR a.fk_product = 0 OR a.fk_soc = 0); + +ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, entity); +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_product (fk_product, entity); +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity); +ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); + +ALTER TABLE llx_product_fournisseur_price DROP FOREIGN KEY fk_product_fournisseur_price_fk_product_fournisseur; + diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur.key.sql b/htdocs/install/mysql/tables/llx_product_fournisseur.key.sql deleted file mode 100644 index 6f1f25a8640..00000000000 --- a/htdocs/install/mysql/tables/llx_product_fournisseur.key.sql +++ /dev/null @@ -1,27 +0,0 @@ --- ============================================================================ --- Copyright (C) 2002-2004 Rodolphe Quiedeville --- Copyright (C) 2004-2011 Laurent Destailleur --- Copyright (C) 2005-2009 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 2 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 . --- --- ============================================================================ - - -ALTER TABLE llx_product_fournisseur ADD UNIQUE INDEX uk_product_fournisseur_ref (ref_fourn, fk_soc, entity); - -ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_product (fk_product, entity); -ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_soc (fk_soc, entity); - -ALTER TABLE llx_product_fournisseur ADD CONSTRAINT fk_product_fournisseur_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur.sql b/htdocs/install/mysql/tables/llx_product_fournisseur.sql deleted file mode 100644 index 733ab67a082..00000000000 --- a/htdocs/install/mysql/tables/llx_product_fournisseur.sql +++ /dev/null @@ -1,39 +0,0 @@ --- ============================================================================ --- Copyright (C) 2003 Rodolphe Quiedeville --- Copyright (C) 2009 Laurent Destailleur --- Copyright (C) 2009 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 2 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_product_fournisseur -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime, - tms timestamp, - fk_product integer, - fk_soc integer, - ref_fourn varchar(30), - entity integer DEFAULT 1 NOT NULL, -- multi company id - fk_user_author integer -)ENGINE=innodb; - --- --- List of codes for the field entity --- --- 1 : first company product --- 2 : second company product --- 3 : etc... --- \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql index 67ddb3cd150..7d3dc962152 100644 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql @@ -19,9 +19,16 @@ ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_user (fk_user); -ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_product_fournisseur (fk_product_fournisseur); +--ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fournisseur_price_fk_product_fournisseur (fk_product_fournisseur); ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); -ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product_fournisseur FOREIGN KEY (fk_product_fournisseur) REFERENCES llx_product_fournisseur (rowid); +--ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product_fournisseur FOREIGN KEY (fk_product_fournisseur) REFERENCES llx_product_fournisseur (rowid); +-- Added to remove table llx_product_fournisseur +ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, entity); + +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_product (fk_product, entity); +ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity); + +ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 0d49d733a28..42f9f836471 100644 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -22,11 +22,14 @@ create table llx_product_fournisseur_price rowid integer AUTO_INCREMENT PRIMARY KEY, datec datetime, tms timestamp, - fk_product_fournisseur integer NOT NULL, + fk_product_fournisseur integer NOT NULL, -- deprecated + fk_product integer, + fk_soc integer, + ref_fourn varchar(30), fk_availability integer, price double(24,8) DEFAULT 0, quantity double, unitprice double(24,8) DEFAULT 0, - fk_user integer - + fk_user integer, + entity integer DEFAULT 1 NOT NULL, -- multi company id )ENGINE=innodb; diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 591e220c22b..984edc8002f 100755 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -310,7 +310,7 @@ class ActionsCardService extends Product if ($_GET["fourn_id"] > 0) { $fourn_id = $_GET["fourn_id"]; - $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf"; + $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; } $sql.= " WHERE p.entity = ".$conf->entity; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ @@ -335,7 +335,7 @@ class ActionsCardService extends Product } if ($fourn_id > 0) { - $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; + $sql.= " AND p.rowid = pfp.fk_product AND pfp.fk_soc = ".$fourn_id; } // Insert categ filter if ($search_categ) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cb662f912e9..e5d0e712536 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -37,7 +37,7 @@ class Product extends CommonObject public $element='product'; public $table_element='product'; public $fk_element='fk_product'; - public $childtables=array('propaldet','commandedet','facturedet','contratdet','product_fournisseur'); + public $childtables=array('propaldet','commandedet','facturedet','contratdet','product_fournisseur_price'); protected $isnolinkedbythird = 1; // No field fk_soc protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -519,11 +519,11 @@ class Product extends CommonObject $this->db->begin(); // Delete supplier prices log - if (! $error) + /*if (! $error) { $sql = 'DELETE pfpl'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price_log as pfpl, '.MAIN_DB_PREFIX.'product_fournisseur as pf'; - $sql.= ' WHERE pfpl.fk_product_fournisseur = pf.rowid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price_log as pfpl, '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp'; + $sql.= ' WHERE pfpl.fk_product_fournisseur = pfp.rowid'; $sql.= ' AND pf.fk_product = '.$id; dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG); $result = $this->db->query($sql); @@ -533,15 +533,14 @@ class Product extends CommonObject $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR); } - } + }*/ // Delete supplier prices if (! $error) { $sql = 'DELETE pfp'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp, '.MAIN_DB_PREFIX.'product_fournisseur as pf'; - $sql.= ' WHERE pfp.fk_product_fournisseur = pf.rowid'; - $sql.= ' AND pf.fk_product = '.$id; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp'; + $sql.= ' WHERE pfp.fk_product = '.$id; dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG); $result = $this->db->query($sql); if (! $result) @@ -819,10 +818,9 @@ class Product extends CommonObject { $result = 0; $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity,"; - $sql.= " pf.fk_product, pf.ref_fourn"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product_fournisseur as pf"; - $sql.= " WHERE pf.rowid = pfp.fk_product_fournisseur"; - $sql.= " AND pfp.rowid = ".$prodfournprice; + $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql.= " WHERE pfp.rowid = ".$prodfournprice; $sql.= " AND pfp.quantity <= ".$qty; dol_syslog("Product::get_buyprice sql=".$sql); @@ -841,13 +839,12 @@ class Product extends CommonObject else { // On refait le meme select sur la ref et l'id du produit - $sql = "SELECT pfp.price as price, pfp.quantity as quantity, pf.fk_soc,"; - $sql.= " pf.fk_product, pf.ref_fourn"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product_fournisseur as pf"; - $sql.= " WHERE pf.rowid = pfp.fk_product_fournisseur"; - $sql.= " AND pf.ref_fourn = '".$fourn_ref."'"; - $sql.= " AND pf.fk_product = ".$product_id; - $sql.= " AND quantity <= ".$qty; + $sql = "SELECT pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; + $sql.= " pfp.fk_product, pfp.ref_fourn"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'"; + $sql.= " AND pfp.fk_product = ".$product_id; + $sql.= " AND pfp.quantity <= ".$qty; $sql.= " ORDER BY pfp.quantity DESC"; $sql.= " LIMIT 1"; @@ -1774,8 +1771,10 @@ class Product extends CommonObject { global $conf; + $now=dol_now(); + $sql = "SELECT rowid, fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE fk_soc = ".$id_fourn; $sql.= " AND ref_fourn = '".$ref_fourn."'"; $sql.= " AND entity = ".$conf->entity; @@ -1789,15 +1788,15 @@ class Product extends CommonObject // The reference supplier does not exist, we create it for this product. if (! $obj) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price ("; $sql.= "datec"; $sql.= ", entity"; $sql.= ", fk_product"; $sql.= ", fk_soc"; $sql.= ", ref_fourn"; - $sql.= ", fk_user_author"; + $sql.= ", fk_user"; $sql.= ") VALUES ("; - $sql.= $this->db->idate(mktime()); + $sql.= $this->db->idate($now); $sql.= ", ".$conf->entity; $sql.= ", ".$this->id; $sql.= ", ".$id_fourn; @@ -1808,7 +1807,7 @@ class Product extends CommonObject dol_syslog("Product::add_fournisseur sql=".$sql); if ($this->db->query($sql)) { - $this->product_fourn_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur"); + $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); return 1; } else @@ -1821,15 +1820,13 @@ class Product extends CommonObject // If the supplier ref already exists for this product else if ($obj->fk_product == $this->id) { - $this->product_fourn_id = $obj->rowid; - + $this->product_fourn_price_id = $obj->rowid; return 0; } // If the supplier ref already exists but for another product else { $this->product_id_already_linked = $obj->fk_product; - return -3; } } @@ -1852,8 +1849,8 @@ class Product extends CommonObject $list = array(); - $sql = "SELECT fk_soc"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur as p"; + $sql = "SELECT p.fk_soc"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p"; $sql.= " WHERE p.fk_product = ".$this->id; $sql.= " AND p.entity = ".$conf->entity; @@ -1925,16 +1922,16 @@ class Product extends CommonObject /** * Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre * - * @param fromId Id produit source - * @param toId Id produit cible - * @return int < 0 si erreur, > 0 si ok + * @param int $fromId Id produit source + * @param int $toId Id produit cible + * @return int < 0 si erreur, > 0 si ok */ function clone_fournisseurs($fromId, $toId) { $this->db->begin(); // les fournisseurs - $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur (" + /*$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur (" . " datec, fk_product, fk_soc, ref_fourn, fk_user_author )" . " SELECT '".$this->db->idate(mktime())."', ".$toId.", fk_soc, ref_fourn, fk_user_author" . " FROM ".MAIN_DB_PREFIX."product_fournisseur" @@ -1944,7 +1941,7 @@ class Product extends CommonObject { $this->db->rollback(); return -1; - } + }*/ // les prix de fournisseurs. $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price (" @@ -1953,13 +1950,17 @@ class Product extends CommonObject . " FROM ".MAIN_DB_PREFIX."product_fournisseur_price" . " WHERE fk_product = ".$fromId; - if ( ! $this->db->query($sql ) ) + $resql=$this->db->query($sql); + if (! $resql) { $this->db->rollback(); return -1; } - $this->db->commit(); - return 1; + else + { + $this->db->commit(); + return 1; + } } /** diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index fcc5398b196..95647c1ca4f 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -34,6 +34,8 @@ $langs->load("products"); $langs->load("suppliers"); $langs->load("bills"); +$action=GETPOST('action'); + // If socid provided by ajax company selector if (! empty($_REQUEST['search_fourn_id'])) { @@ -43,10 +45,7 @@ if (! empty($_REQUEST['search_fourn_id'])) } // Security check -if (isset($_GET["id"]) || isset($_GET["ref"])) -{ - $id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:''); -} +$id = GETPOST('id')?GETPOST('id'):GETPOST('ref'); $fieldid = isset($_GET["ref"])?'ref':'rowid'; if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service&fournisseur',$id,'product','','',$fieldid); @@ -75,19 +74,6 @@ if ($_GET["action"] == 'remove_pf') $_GET["action"] = ''; $mesg = '
'.$langs->trans("PriceRemoved").'.
'; } - else - { - // Deprecated. Should not occurs - if ($product->remove_fournisseur($_GET["socid"]) > 0) - { - $_GET["action"] = ''; - $mesg = '
'.$langs->trans("SupplierRemoved").'.
'; - } - else - { - $_GET["action"] = ''; - } - } } } @@ -145,7 +131,7 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc $supplier=new Fournisseur($db); $result=$supplier->fetch($id_fourn); - $ret=$product->update_buyprice($_POST["qty"], $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"]); + $ret=$product->update_buyprice($_POST["qty"], $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn); if ($ret < 0) { $error++; @@ -169,6 +155,7 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc { $db->commit(); $_POST['action']=''; + $action=''; } else { @@ -259,17 +246,22 @@ if ($_GET["id"] || $_GET["ref"]) { $langs->load("suppliers"); - if ($_GET["rowid"]) { + if ($_GET["rowid"]) + { $product->fetch_product_fournisseur_price($_GET["rowid"]); print_fiche_titre($langs->trans("ChangeSupplierPrice")); - } else { + } + else + { print_fiche_titre($langs->trans("AddSupplierPrice")); } - print '
'; print ''; // ancre @@ -1865,7 +1775,7 @@ else /* * Show mail form */ - if ($_GET['action'] == 'presend') + if ($action == 'presend') { $ref = dol_sanitizeFileName($fac->ref); $file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($fac->id,2).$ref.'.pdf'; diff --git a/htdocs/lib/fourn.lib.php b/htdocs/lib/fourn.lib.php index 8f4695ab885..9987d260112 100644 --- a/htdocs/lib/fourn.lib.php +++ b/htdocs/lib/fourn.lib.php @@ -19,9 +19,16 @@ /** * \file htdocs/lib/fourn.lib.php - * \brief Ensemble de fonctions de base pour le module fournisseur + * \brief Functions used by supplier invoice module + * \ingroup supplier */ +/** + * Initialize the array of tabs for supplier invoice + * + * @param Facture $object Invoice object + * @return array Array of head tabs + */ function facturefourn_prepare_head($object) { global $langs, $conf; @@ -29,7 +36,7 @@ function facturefourn_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$object->id; - $head[$h][1] = $langs->trans('Card'); + $head[$h][1] = $langs->trans('CardBill'); $head[$h][2] = 'card'; $h++; diff --git a/htdocs/lib/invoice.lib.php b/htdocs/lib/invoice.lib.php index 39f1d508e73..22b0b276571 100644 --- a/htdocs/lib/invoice.lib.php +++ b/htdocs/lib/invoice.lib.php @@ -18,10 +18,16 @@ /** * \file htdocs/lib/invoice.lib.php - * \brief Ensemble de fonctions de base pour le module factures + * \brief Functions used by invoice module * \ingroup invoice */ +/** + * Initialize the array of tabs for customer invoice + * + * @param Facture $object Invoice object + * @return array Array of head tabs + */ function facture_prepare_head($object) { global $langs, $conf; From fe30491a452acf9fef796f95a220648911b92b26 Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 23:24:39 +0200 Subject: [PATCH 17/41] Qual: Mutualize a lot of code between supplier and customer payments --- htdocs/compta/facture.php | 1 - .../compta/paiement/class/paiement.class.php | 176 +++++++++++++----- htdocs/compta/paiement/fiche.php | 51 ++++- htdocs/fourn/class/paiementfourn.class.php | 66 +------ htdocs/fourn/paiement/fiche.php | 172 ++++++++--------- 5 files changed, 254 insertions(+), 212 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f86d78c14b2..cc4d8b5c441 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -501,7 +501,6 @@ if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->f } - /* * Insert new invoice in database */ diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 3c673da95d0..7754a370ecd 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -54,8 +54,9 @@ class Paiement extends CommonObject /** - * \brief Constructeur de la classe - * \param DB handler acces base de donnees + * Constructor + * + * @param DoliDB $DB Database handler */ function Paiement($DB) { @@ -64,8 +65,9 @@ class Paiement extends CommonObject /** * Load payment from database - * @param id id of payment to get - * @return int <0 if KO, 0 if not found, >0 if OK + * + * @param int $id Id of payment to get + * @return int <0 if KO, 0 if not found, >0 if OK */ function fetch($id) { @@ -120,9 +122,10 @@ class Paiement extends CommonObject /** * Create payment of invoices into database. * Use this->amounts to have list of invoices for the payment - * @param user object user - * @param closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more - * @return int id of created payment, < 0 if error + * + * @param User $user Object user + * @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more + * @return int id of created payment, < 0 if error */ function create($user,$closepaidinvoices=0) { @@ -252,7 +255,9 @@ class Paiement extends CommonObject * Supprime un paiement ainsi que les lignes qu'il a genere dans comptes * Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse * Si le paiement porte sur au moins une facture a "payee", on refuse - * @return int <0 si ko, >0 si ok + * + * @param int $notrigger No trigger + * @return int <0 si ko, >0 si ok */ function delete($notrigger=0) { @@ -351,13 +356,15 @@ class Paiement extends CommonObject /** * A record into bank for payment with links between this bank record and invoices of payment. * All payment properties must have been set first like after a call to create(). - * @param user Object of user making payment - * @param mode 'payment', 'payment_supplier' - * @param label Label to use in bank record - * @param accountid Id of bank account to do link with - * @param emetteur_nom Name of transmitter - * @param emetteur_banque Name of bank - * @return int <0 if KO, bank_line_id if OK + * + * @param User $user Object of user making payment + * @param string $mode 'payment', 'payment_supplier' + * @param string $label Label to use in bank record + * @param int $accountid Id of bank account to do link with + * @param string $emetteur_nom Name of transmitter + * @param string $emetteur_banque Name of bank + * @param int $notrigger No trigger + * @return int <0 if KO, bank_line_id if OK */ function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque,$notrigger=0) { @@ -382,15 +389,17 @@ class Paiement extends CommonObject if ($mode == 'payment_supplier') $totalamount=-$totalamount; // Insert payment into llx_bank - $bank_line_id = $acc->addline($this->datepaye, - $this->paiementid, // Payment mode id or code ("CHQ or VIR for example") - $label, - $totalamount, - $this->num_paiement, - '', - $user, - $emetteur_nom, - $emetteur_banque); + $bank_line_id = $acc->addline( + $this->datepaye, + $this->paiementid, // Payment mode id or code ("CHQ or VIR for example") + $label, + $totalamount, + $this->num_paiement, + '', + $user, + $emetteur_nom, + $emetteur_banque + ); // Mise a jour fk_bank dans llx_paiement // On connait ainsi le paiement qui a genere l'ecriture bancaire @@ -433,8 +442,13 @@ class Paiement extends CommonObject $fac->fetch_thirdparty(); if (! in_array($fac->thirdparty->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty { - $result=$acc->add_url_line($bank_line_id, $fac->thirdparty->id, - DOL_URL_ROOT.'/comm/fiche.php?socid=', $fac->thirdparty->nom, 'company'); + $result=$acc->add_url_line( + $bank_line_id, + $fac->thirdparty->id, + DOL_URL_ROOT.'/comm/fiche.php?socid=', + $fac->thirdparty->nom, + 'company' + ); if ($result <= 0) dol_print_error($this->db); $linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty } @@ -446,8 +460,13 @@ class Paiement extends CommonObject $fac->fetch_thirdparty(); if (! in_array($fac->thirdparty->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty { - $result=$acc->add_url_line($bank_line_id, $fac->thirdparty->id, - DOL_URL_ROOT.'/fourn/fiche.php?socid=', $fac->thirdparty->nom, 'company'); + $result=$acc->add_url_line( + $bank_line_id, + $fac->thirdparty->id, + DOL_URL_ROOT.'/fourn/fiche.php?socid=', + $fac->thirdparty->nom, + 'company' + ); if ($result <= 0) dol_print_error($this->db); $linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty } @@ -485,7 +504,9 @@ class Paiement extends CommonObject /** * Mise a jour du lien entre le paiement et la ligne generee dans llx_bank - * @param id_bank Id compte bancaire + * + * @param int $id_bank Id compte bancaire + * @return int <0 if KO, >0 if OK */ function update_fk_bank($id_bank) { @@ -506,8 +527,72 @@ class Paiement extends CommonObject } } + /** + * Updates the payment date + * + * @param timestamp $date New date + * @return int <0 if KO, 0 if OK + */ + function update_date($date) + { + if (!empty($date) && $this->statut!=1) + { + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " SET datep = ".$this->db->idate($date); + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::update_date sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + $this->datepaye = $date; + $this->date = $date; + return 0; + } + else + { + $this->error='Error -1 '.$this->db->error(); + dol_syslog(get_class($this)."::update_date ".$this->error, LOG_ERR); + return -2; + } + } + return -1; //no date given or already validated + } + + /** + * Updates the payment number + * + * @param string $num New num + * @return int <0 if KO, 0 if OK + */ + function update_num($num) + { + if(!empty($num) && $this->statut!=1) + { + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " SET num_paiement = '".$this->db->escape($num)."'"; + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::update_num sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + $this->numero = $this->db->escape($num); + return 0; + } + else + { + $this->error='Error -1 '.$this->db->error(); + dol_syslog(get_class($this)."::update_num ".$this->error, LOG_ERR); + return -2; + } + } + return -1; //no num given or already validated + } + /** * Validate payment + * * @return int <0 if KO, >0 if OK */ function valide() @@ -572,9 +657,10 @@ class Paiement extends CommonObject } /** - * \brief Retourne la liste des factures sur lesquels porte le paiement - * \param filter Critere de filtre - * \return array Tableau des id de factures + * Retourne la liste des factures sur lesquels porte le paiement + * + * @param string $filter Critere de filtre + * @return array Tableau des id de factures */ function getBillsArray($filter='') { @@ -608,10 +694,11 @@ class Paiement extends CommonObject /** - * \brief Renvoie nom clicable (avec eventuellement le picto) - * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - * \param option Sur quoi pointe le lien - * \return string Chaine avec URL + * Renvoie nom clicable (avec eventuellement le picto) + * + * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * @param string $option Sur quoi pointe le lien + * @return string Chaine avec URL */ function getNomUrl($withpicto=0,$option='') { @@ -629,9 +716,10 @@ class Paiement extends CommonObject } /** - * \brief Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * \return string Libelle + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle */ function getLibStatut($mode=0) { @@ -639,14 +727,16 @@ class Paiement extends CommonObject } /** - * \brief Renvoi le libelle d'un statut donne - * \param status Statut - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * \return string Libelle du statut + * Renvoi le libelle d'un statut donne + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut */ function LibStatut($status,$mode=0) { global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + $langs->load('compta'); if ($mode == 0) { diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index 390ef0984f0..26707aeb6fa 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -126,6 +126,37 @@ if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights- } } +if ($action == 'setnum' && !empty($_POST['num'])) +{ + $paiement = new Paiement($db); + $paiement->fetch($id); + $res = $paiement->update_num($_POST['num']); + if ($res === 0) + { + $mesg = '
'.$langs->trans('PaymentNumberUpdateSucceeded').'
'; + } + else + { + $mesg = '
'.$langs->trans('PaymentNumberUpdateFailed').'
'; + } +} + +if ($action == 'setdate' && !empty($_POST['dateday'])) +{ + $paiement = new Paiement($db); + $paiement->fetch($id); + $datepaye = dol_mktime(12, 0, 0, $_POST['datemonth'], $_POST['dateday'], $_POST['dateyear']); + $res = $paiement->update_date($datepaye); + if ($res === 0) + { + $mesg = '
'.$langs->trans('PaymentDateUpdateSucceeded').'
'; + } + else + { + $mesg = '
'.$langs->trans('PaymentDateUpdateFailed').'
'; + } +} + /* * View @@ -185,25 +216,25 @@ dol_htmloutput_mesg($mesg); print ''; // Ref -print ''; +print ''; -// Date -print ''; +// Date payment +print ''; // Payment type (VIR, LIQ, ...) $labeltype=$langs->trans("PaymentType".$paiement->type_code)!=("PaymentType".$paiement->type_code)?$langs->trans("PaymentType".$paiement->type_code):$paiement->type_libelle; -print ''; +print ''; -// Numero -//if ($paiement->montant) -//{ - print ''; -//} +// Payment numero +print ''; // Amount print ''; - // Note print ''; print ''; print "\n"; $var=true; -$var=!$var; -print ''; -print ''; $var=!$var; -print ''; -print ''; +print ''; print "'; +$var=!$var; +print ''; +print ''; +print "'; + print "
'.$langs->trans('Ref').''.$paiement->id.'
'.$langs->trans('Ref').''.$paiement->id.'
'.$langs->trans('Date').''.dol_print_date($paiement->date,'day').'
'.$html->editfieldkey("Date",'date',$paiement->date,'id',$paiement->id,$user->rights->facture->paiement).''; +print $html->editfieldval("Date",'date',$paiement->date,'id',$paiement->id,$user->rights->facture->paiement,'day'); +print '
'.$langs->trans('Mode').''.$labeltype.'
'.$langs->trans('PaymentMode').''.$labeltype.'
'.$langs->trans('Numero').''.$paiement->numero.'
'.$html->editfieldkey("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).''; +print $html->editfieldval("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string'); +print '
'.$langs->trans('Amount').''.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).'
'.$html->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement).''; print $html->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->facture->paiement,'text'); diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index ec97237457f..0c08c282767 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -55,10 +55,10 @@ class PaiementFourn extends Paiement // fk_paiement dans llx_paiement_facture est le rowid du paiement /** - * \brief Constructeur de la classe - * \param DB handler acces base de donnees + * Constructor + * + * @param DoliDB $DB Database handler */ - function PaiementFourn($DB) { $this->db = $DB ; @@ -475,65 +475,5 @@ class PaiementFourn extends Paiement if ($withpicto != 2) $result.=$lien.$text.$lienfin; return $result; } - - /** - * \brief Updates the payment number - * \param string New num - * \return int -1 on error, 0 otherwise - */ - function update_num($num) - { - if(!empty($num) && $this->statut!=1) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn"; - $sql.= " SET num_paiement = '".$this->db->escape($num)."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog("PaiementFourn::update_num sql=".$sql); - $result = $this->db->query($sql); - if ($result) - { - $this->numero = $this->db->escape($num); - return 0; - } - else - { - $this->error='PaiementFourn::update_num Error -1 '.$this->db->error(); - dol_syslog('PaiementFourn::update_num error '.$this->error, LOG_ERR); - return -1; - } - } - return -1; //no num given or already validated - } - /** - * \brief Updates the payment date - * \param string New date - * \return int -1 on error, 0 otherwise - */ - function update_date($date) - { - if(!empty($date) && $this->statut!=1) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn"; - $sql.= " SET datep = ".$this->db->idate($date); - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog("PaiementFourn::update_date sql=".$sql); - $result = $this->db->query($sql); - if ($result) - { - $this->datepaye = $date; - $this-> date = $date; - return 0; - } - else - { - $this->error='PaiementFourn::update_date Error -1 '.$this->db->error(); - dol_syslog('PaiementFourn::update_date error '.$this->error, LOG_ERR); - return -1; - } - } - return -1; //no date given or already validated - } } ?> diff --git a/htdocs/fourn/paiement/fiche.php b/htdocs/fourn/paiement/fiche.php index c03e72e44b7..56692542365 100644 --- a/htdocs/fourn/paiement/fiche.php +++ b/htdocs/fourn/paiement/fiche.php @@ -35,18 +35,38 @@ $langs->load('companies'); $langs->load("suppliers"); $mesg=''; +$action=GETPOST('action'); +$id=GETPOST('id'); /* * Actions */ -if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer) +if ($action == 'setnote' && $user->rights->fournisseur->facture->creer) +{ + $db->begin(); + $paiement = new PaiementFourn($db); + $paiement->fetch($id); + $result = $paiement->update_note(GETPOST('note')); + if ($result > 0) + { + $db->commit(); + $action=''; + } + else + { + $mesg='
'.$paiement->error.'
'; + $db->rollback(); + } +} + +if ($action == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer) { $db->begin(); $paiement = new PaiementFourn($db); - $paiement->fetch($_GET['id']); + $paiement->fetch($id); $result = $paiement->delete(); if ($result > 0) { @@ -61,12 +81,12 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user- } } -if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider) +if ($action == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->valider) { $db->begin(); $paiement = new PaiementFourn($db); - $paiement->id = $_GET['id']; + $paiement->fetch($id); if ($paiement->valide() >= 0) { $db->commit(); @@ -80,6 +100,37 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user- } } +if ($action == 'setnum' && !empty($_POST['num'])) +{ + $paiement = new PaiementFourn($db); + $paiement->fetch($id); + $res = $paiement->update_num($_POST['num']); + if ($res === 0) + { + $mesg = '
'.$langs->trans('PaymentNumberUpdateSucceeded').'
'; + } + else + { + $mesg = '
'.$langs->trans('PaymentNumberUpdateFailed').'
'; + } +} + +if ($action == 'setdate' && !empty($_POST['dateday'])) +{ + $paiement = new PaiementFourn($db); + $paiement->fetch($id); + $datepaye = dol_mktime(12, 0, 0, $_POST['datemonth'], $_POST['dateday'], $_POST['dateyear']); + $res = $paiement->update_date($datepaye); + if ($res === 0) + { + $mesg = '
'.$langs->trans('PaymentDateUpdateSucceeded').'
'; + } + else + { + $mesg = '
'.$langs->trans('PaymentDateUpdateFailed').'
'; + } +} + /* * View @@ -91,12 +142,12 @@ $html = new Form($db); $h=0; -$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$_GET['id']; +$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$id; $head[$h][1] = $langs->trans('Card'); $hselected = $h; $h++; -$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$_GET['id']; +$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$id; $head[$h][1] = $langs->trans('Info'); $h++; @@ -104,14 +155,13 @@ $h++; dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment'); $paiement = new PaiementFourn($db); -$result=$paiement->fetch($_GET['id']); +$result=$paiement->fetch($id); if ($result > 0) { - /* * Confirmation de la suppression du paiement */ - if ($_GET['action'] == 'delete') + if ($action == 'delete') { $ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete'); if ($ret == 'html') print '
'; @@ -120,102 +170,31 @@ if ($result > 0) /* * Confirmation de la validation du paiement */ - if ($_GET['action'] == 'valide') + if ($action == 'valide') { $ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide'); if ($ret == 'html') print '
'; } - if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num'])) - { - $res = $paiement->update_num($_POST['new_num']); - if ($res === 0) { - $mesg = '
'.$langs->trans('PaymentNumberUpdateSucceeded').'
'; - } else { - $mesg = '
'.$langs->trans('PaymentNumberUpdateFailed').'
'; - } - } - - if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday'])) - { - $datepaye = dol_mktime(12, 0 , 0, - $_POST['remonth'], - $_POST['reday'], - $_POST['reyear']); - $res = $paiement->update_date($datepaye); - if ($res === 0) { - $mesg = '
'.$langs->trans('PaymentDateUpdateSucceeded').'
'; - } else { - $mesg = '
'.$langs->trans('PaymentDateUpdateFailed').'
'; - } - } - - print ''; print ''; print ''; - //switch through edition options for date (only available when statut is -not 1- (=validated)) - if (empty($_GET['action']) || $_GET['action']!='edit_date') - { - print ''; - print ''; - } - else - { - print ''; - print ''; - print ''; - print ''; - } + // Date payment + print ''; - print ''; + // Payment mode + print ''; - //switch through edition options for number (only available when statut is -not 1- (=validated)) - if (empty($_GET['action']) || $_GET['action'] != 'edit_num') - { - print ''; - print ''; - } - else - { - print ''; - print ''; - print ''; - print ''; - } + // Payment numero + print ''; + + // Amount print ''; if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) @@ -223,7 +202,10 @@ if ($result > 0) print ''; } - print ''; + // Note + print ''; // Bank account if ($conf->banque->enabled) @@ -244,7 +226,7 @@ if ($result > 0) print '
'.$langs->trans('Ref').''.$paiement->id.'
'; - print ''; - if ($paiement->statut == 0 && $_GET['action'] != 'edit_date') print ''; - print '
'; - print $langs->trans('Date'); - print ''.img_edit($langs->trans('Modify')).'
'; - print '
'.dol_print_date($paiement->date,'day').'
'.$langs->trans('Date').''; - print '
'; - print ''; - if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear'])) - $sel_date=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - else - $sel_date=$paiement->date; - $html->select_date($sel_date,'','','','',"addpaiement"); - print ''; - print '
'; - print '
'.$html->editfieldkey("Date",'date',$paiement->date,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).''; + print $html->editfieldval("Date",'date',$paiement->date,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'day'); + print '
'.$langs->trans('Type').''.$paiement->type_libelle.'
'.$langs->trans('PaymentMode').''.$paiement->type_libelle.'
'; - print ''; - if ($paiement->statut == 0 && $_GET['action'] != 'edit_num') print ''; - print '
'; - print $langs->trans('Numero'); - print ''.img_edit($langs->trans('Modify')).'
'; - print '
'.$paiement->numero.'
'.$langs->trans('Numero').''; - print '
'; - print ''; - if (!empty($_POST['new_num'])) - $num = $this->db->escape($_POST['new_num']); - else - $num = $paiement->numero; - print ''; - print ''; - print '
'.$html->editfieldkey("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer).''; + print $html->editfieldval("Numero",'num',$paiement->numero,'id',$paiement->id,$paiement->statut == 0 && $user->rights->fournisseur->facture->creer,'string'); + print '
'.$langs->trans('Amount').''.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Status').''.$paiement->getLibStatut(4).'
'.$langs->trans('Note').''.nl2br($paiement->note).'
'.$html->editfieldkey("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->fournisseur->facture->creer).''; + print $html->editfieldval("Note",'note',$paiement->note,'id',$paiement->id,$user->rights->fournisseur->facture->creer,'text'); + print '
'; - if ($mesg) print '
'.$mesg; + dol_htmloutput_mesg($mesg); print '
'; From 409fd169cf398c542aae8ec58aed0058103125df Mon Sep 17 00:00:00 2001 From: eldy Date: Sun, 2 Oct 2011 01:23:57 +0200 Subject: [PATCH 18/41] New: Add webservice to create a product --- ChangeLog | 3 +- htdocs/product/class/product.class.php | 35 +-- htdocs/webservices/server_invoice.php | 58 ++--- .../webservices/server_productorservice.php | 189 +++++++++++++-- test/soapui/Dolibarr-soapui-project.xml | 228 +++++++++++++++++- 5 files changed, 436 insertions(+), 77 deletions(-) diff --git a/ChangeLog b/ChangeLog index 208706b57d9..e377db27912 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,12 +22,13 @@ For users: - New: Can search on part of barcode into POS module. For developers: +- New: Add webservice to get or create a prodcut or service. - Qual: Removed no more used external libraries. - Qual: Cleaned a lot of dead code. - Qual: Parent templates classes were moved as abstract classes. - Qual: Add more "hooks". - Qual: Add "canvas" feature to overwrite page of thirdparty, contact, product with yours. -- More OOP (usage of "abstract", "static", ...), unifformize constructors. +- More OOP (usage of "abstract", "static", ...), uniformize constructors. ***** ChangeLog for 3.1 compared to 3.0 ***** diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fbf38befc79..cb662f912e9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -45,7 +45,8 @@ class Product extends CommonObject var $id ; //! Ref var $ref; - var $libelle; + var $libelle; // TODO deprecated + var $label; var $description; //! Prix de vente var $price; // Price without tax @@ -68,14 +69,14 @@ class Product extends CommonObject var $localtax2_tx; //! Type 0 for regular product, 1 for service (Advanced feature: 2 for assembly kit, 3 for stock kit) var $type; - var $typestring; //! Stock var $stock_reel; //! Average price value for product entry into stock (PMP) var $pmp; - + //! Stock alert var $seuil_stock_alerte; + //! Duree de validite du service var $duration_value; //! Unite de duree @@ -188,9 +189,9 @@ class Product extends CommonObject /** * Insert product into database * - * @param user User making insert - * @param notrigger Disable triggers - * @return int Id of product/service if OK or number of error < 0 + * @param User $user User making insert + * @param int $notrigger Disable triggers + * @return int Id of product/service if OK or number of error < 0 */ function create($user,$notrigger=0) { @@ -255,6 +256,7 @@ class Product extends CommonObject dol_syslog("Product::Create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type." Category : ".$this->catid, LOG_DEBUG); + $now=dol_now(); $this->db->begin(); @@ -287,7 +289,7 @@ class Product extends CommonObject $sql.= ", canvas"; $sql.= ", finished"; $sql.= ") VALUES ("; - $sql.= $this->db->idate(mktime()); + $sql.= $this->db->idate($now); $sql.= ", ".$conf->entity; $sql.= ", '".$this->ref."'"; $sql.= ", ".price2num($price_min_ht); @@ -357,7 +359,8 @@ class Product extends CommonObject else { // Product already exists with this ref - $langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists",$this->ref); + $langs->load("products"); + $this->error = $langs->transnoentitiesnoconv("ErrorProductAlreadyExists",$this->ref); } } else @@ -391,9 +394,9 @@ class Product extends CommonObject /** * Update a record into database * - * @param id Id of product - * @param user Object user making update - * @return int 1 if OK, -1 if ref already exists, -2 if other error + * @param int $id Id of product + * @param User $user Object user making update + * @return int 1 if OK, -1 if ref already exists, -2 if other error */ function update($id, $user) { @@ -1047,6 +1050,11 @@ class Product extends CommonObject $this->label = $object->label; $this->description = $object->description; $this->note = $object->note; + + $this->type = $object->fk_product_type; + $this->status = $object->tosell; + $this->status_buy = $object->tobuy; + $this->customcode = $object->customcode; $this->country_id = $object->fk_country; $this->country_code = getCountry($this->country_id,2,$this->db); @@ -1062,14 +1070,10 @@ class Product extends CommonObject $this->localtax1_tx = $object->localtax1_tx; $this->localtax2_tx = $object->localtax2_tx; - $this->type = $object->fk_product_type; - $this->status = $object->tosell; - $this->status_buy = $object->tobuy; $this->finished = $object->finished; $this->duration = $object->duration; $this->duration_value = substr($object->duration,0,dol_strlen($object->duration)-1); $this->duration_unit = substr($object->duration,-1); - $this->seuil_stock_alerte = $object->seuil_stock_alerte; $this->canvas = $object->canvas; $this->weight = $object->weight; $this->weight_units = $object->weight_units; @@ -1085,6 +1089,7 @@ class Product extends CommonObject $this->accountancy_code_buy = $object->accountancy_code_buy; $this->accountancy_code_sell= $object->accountancy_code_sell; + $this->seuil_stock_alerte = $object->seuil_stock_alerte; $this->stock_reel = $object->stock; $this->pmp = $object->pmp; diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 030b8c234a2..05e8b93ad7d 100755 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -246,8 +246,8 @@ $server->register( /** * Get invoice from id, ref or ref_ext * - * @param object $authentication - * + * @param array $authentication Array of authentication information + * @return array Array result */ function getInvoice($authentication,$id='',$ref='',$ref_ext='') { @@ -352,6 +352,9 @@ function getInvoice($authentication,$id='',$ref='',$ref_ext='') /** * Get list of invoices for third party + * + * @param array $authentication Array of authentication information + * @return array Array result */ function getInvoicesForThirdParty($authentication,$idthirdparty) { @@ -467,7 +470,11 @@ function getInvoicesForThirdParty($authentication,$idthirdparty) /** - * Get list of invoices for third party + * Create an invoice + * + * @param array $authentication Array of authentication information + * @param Facture $invoice Invoice + * @return array Array result */ function createInvoice($authentication,$invoice) { @@ -475,7 +482,7 @@ function createInvoice($authentication,$invoice) $now=dol_now(); - dol_syslog("Function: createInvoiceForThirdParty login=".$authentication['login']." idthirdparty=".$idthirdparty); + dol_syslog("Function: createInvoiceForThirdParty login=".$authentication['login']); if ($authentication['entity']) $conf->entity=$authentication['entity']; @@ -488,17 +495,17 @@ function createInvoice($authentication,$invoice) if (! $error) { - $newinvoice=new Facture($db); - $newinvoice->socid=$invoice['thirdparty_id']; - $newinvoice->type=$invoice['type']; - $newinvoice->ref_ext=$invoice['ref_ext']; - $newinvoice->date=$invoice['date']; - $newinvoice->date_lim_reglement=$invoice['date_due']; - $newinvoice->note=$invoice['note']; - $newinvoice->note_public=$invoice['note_public']; - $newinvoice->statut=$invoice['status']; - $newinvoice->fk_project=$invoice['project_id']; - $newinvoice->date_creation=$now; + $newobject=new Facture($db); + $newobject->socid=$invoice['thirdparty_id']; + $newobject->type=$invoice['type']; + $newobject->ref_ext=$invoice['ref_ext']; + $newobject->date=$invoice['date']; + $newobject->date_lim_reglement=$invoice['date_due']; + $newobject->note=$invoice['note']; + $newobject->note_public=$invoice['note_public']; + $newobject->statut=$invoice['status']; + $newobject->fk_project=$invoice['project_id']; + $newobject->date_creation=$now; foreach($invoice['lines'] as $line) { $newline=new FactureLigne($db); @@ -517,35 +524,32 @@ function createInvoice($authentication,$invoice) $db->begin(); - $result=$newinvoice->create($user,0,0); + $result=$newobject->create($fuser,0,0); if ($result < 0) { $error++; } - if ($newinvoice->statut == 1) // We want invoice validated + if ($newobject->statut == 1) // We want invoice validated { - $newinvoice->validate($user); + $result=$newobject->validate($fuser); + if ($result < 0) + { + $error++; + } } - $result=$newinvoice->create($user,0,0); - if ($result < 0) - { - $error++; - } - - if (! $error) { $db->commit(); - $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newinvoice->id,'ref'=>$newinvoice->ref); + $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref); } else { $db->rollback(); $error++; $errorcode='KO'; - $errorlabel=$newinvoice->error; + $errorlabel=$newobject->error; } } diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 59676e34395..35c69f98352 100755 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -89,18 +89,31 @@ $server->wsdl->addComplexType( '', array( 'id' => array('name'=>'id','type'=>'xsd:string'), - 'ref' => array('name'=>'name','type'=>'xsd:string'), + 'ref' => array('name'=>'ref','type'=>'xsd:string'), 'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'), - 'label' => array('name'=>'label','type'=>'xsd:string'), + 'type' => array('name'=>'type','type'=>'xsd:string'), + 'label' => array('name'=>'label','type'=>'xsd:string'), 'description' => array('name'=>'description','type'=>'xsd:string'), 'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'), 'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'), 'note' => array('name'=>'note','type'=>'xsd:string'), - 'tobuy' => array('name'=>'tobuy','type'=>'xsd:string'), - 'tosell' => array('name'=>'tosell','type'=>'xsd:string'), - 'type' => array('name'=>'type','type'=>'xsd:string'), + 'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'), + 'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'), 'barcode' => array('name'=>'barcode','type'=>'xsd:string'), - 'country_id' => array('name'=>'country_id','type'=>'xsd:string') + 'barcode_type' => array('name'=>'barcode_type','type'=>'xsd:string'), + 'country_id' => array('name'=>'country_id','type'=>'xsd:string'), + 'country_code' => array('name'=>'country_code','type'=>'xsd:string'), + 'customcode' => array('name'=>'customcode','type'=>'xsd:string'), + + 'price_net' => array('name'=>'price_net','type'=>'xsd:string'), + 'price' => array('name'=>'price','type'=>'xsd:string'), + 'price_base_type' => array('name'=>'price_base_type','type'=>'xsd:string'), + + 'stock_alert' => array('name'=>'stock_alert','type'=>'xsd:string'), + 'stock_real' => array('name'=>'stock_real','type'=>'xsd:string'), + 'stock_pmp' => array('name'=>'stock_pmp','type'=>'xsd:string'), + 'canvas' => array('name'=>'canvas','type'=>'xsd:string'), + 'import_key' => array('name'=>'import_key','type'=>'xsd:string') ) ); @@ -113,19 +126,6 @@ $styledoc='rpc'; // rpc/document (document is an extend into SOAP 1.0 to s $styleuse='encoded'; // encoded/literal/literal wrapped // Better choice is document/literal wrapped but literal wrapped not supported by nusoap. -// Register WSDL -$server->register( - 'createProductOrService', - // Entry values - array('authentication'=>'tns:authentication','product'=>'tns:product'), - // Exit values - array('result'=>'tns:result','id'=>'xsd:string'), - $ns, - $ns.'#createProductOrService', - $styledoc, - $styleuse, - 'WS to create a product or service' -); // Register WSDL $server->register( @@ -141,8 +141,26 @@ $server->register( 'WS to get product or service' ); +// Register WSDL +$server->register( + 'createProductOrService', + // Entry values + array('authentication'=>'tns:authentication','product'=>'tns:product'), + // Exit values + array('result'=>'tns:result','id'=>'xsd:string'), + $ns, + $ns.'#createProductOrService', + $styledoc, + $styleuse, + 'WS to create a product or service' +); -// Full methods code + +/** + * Get produt or service + * + * @param array $authentication Array of authentication information + */ function getProductOrService($authentication,$id='',$ref='',$ref_ext='') { global $db,$conf,$langs; @@ -178,18 +196,31 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='') 'result'=>array('result_code'=>'OK', 'result_label'=>''), 'product'=>array( 'id' => $product->id, - 'ref' => $product->name, + 'ref' => $product->ref, 'ref_ext' => $product->ref_ext, 'label' => $product->label, 'description' => $product->description, 'date_creation' => $product->date_creation, 'date_modification' => $product->date_modification, 'note' => $product->note, - 'tobuy' => $product->tobuy, - 'tosell' => $product->tosell, - 'type' => $product->type, + 'status_tosell' => $product->status, + 'status_tobuy' => $product->status_buy, + 'type' => $product->type, 'barcode' => $product->barcode, - 'country_id' => $product->country_id + 'barcode_type' => $product->barcode_type, + 'country_id' => $product->country_id>0?$product->country_id:'', + 'country_code' => $product->country_code, + 'custom_code' => $product->customcode, + + 'price_net' => $product->price, + 'price' => ($product->price_ttc-$product->price), + 'vat_rate' => $product->tva_tx, + 'price_base_type' => $product->price_base_type, + + 'stock_real' => $product->stock_reel, + 'stock_alert' => $product->seuil_stock_alerte, + 'pmp' => $product->pmp, + 'import_key' => $product->import_key )); } else @@ -214,6 +245,114 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='') } +/** + * Create an invoice + * + * @param array $authentication Array of authentication information + * @param Product $product Product + * @return array Array result + */ +function createProductOrService($authentication,$product) +{ + global $db,$conf,$langs; + + $now=dol_now(); + + dol_syslog("Function: createProductOrService login=".$authentication['login']); + + if ($authentication['entity']) $conf->entity=$authentication['entity']; + + // Init and check authentication + $objectresp=array(); + $errorcode='';$errorlabel=''; + $error=0; + $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); + // Check parameters + if ($product['price_net'] > 0) $product['price_base_type']='HT'; + if ($product['price'] > 0) $product['price_base_type']='TTC'; + + if ($product['price_net'] > 0 && $product['price'] > 0) + { + $error++; $errorcode='KO'; $errorlabel="You must choose between price or price_net to provide price."; + } + + + if (! $error) + { + include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php'); + + $newobject=new Product($db); + $newobject->ref=$product['ref']; + $newobject->ref_ext=$product['ref_ext']; + $newobject->type=$product['type']; + $newobject->libelle=$product['label']; // TODO deprecated + $newobject->label=$product['label']; + $newobject->description=$product['description']; + $newobject->note=$product['note']; + $newobject->status=$product['status_tosell']; + $newobject->status_buy=$product['status_tobuy']; + $newobject->price=$product['price_net']; + $newobject->price_ttc=$product['price']; + $newobject->tva_tx=$product['vat_rate']; + $newobject->price_base_type=$product['price_base_type']; + $newobject->date_creation=$now; + + $newobject->stock_reel=$product['stock_real']; + $newobject->pmp=$product['pmp']; + $newobject->seuil_stock_alert=$product['stock_alert']; + + $newobject->country_id=$product['country_id']; + if ($product['country_code']) $newobject->country_id=getCountry($product['country_code'],3); + $newobject->customcode=$product['customcode']; + + $newobject->canvas=$product['canvas']; + /*foreach($product['lines'] as $line) + { + $newline=new FactureLigne($db); + $newline->type=$line['type']; + $newline->desc=$line['desc']; + $newline->fk_product=$line['fk_product']; + $newline->total_ht=$line['total_net']; + $newline->total_vat=$line['total_vat']; + $newline->total_ttc=$line['total']; + $newline->vat=$line['vat_rate']; + $newline->qty=$line['qty']; + $newline->fk_product=$line['product_id']; + }*/ + //var_dump($product['ref_ext']); + //var_dump($product['lines'][0]['type']); + + $db->begin(); + + $result=$newobject->create($fuser,0); + if ($result <= 0) + { + $error++; + } + + if (! $error) + { + $db->commit(); + $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref); + } + else + { + $db->rollback(); + $error++; + $errorcode='KO'; + $errorlabel=$newobject->error; + } + + } + + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } + + return $objectresp; +} + // Return the results. $server->service($HTTP_RAW_POST_DATA); diff --git a/test/soapui/Dolibarr-soapui-project.xml b/test/soapui/Dolibarr-soapui-project.xml index d24736ccde3..71f1e13f5bd 100755 --- a/test/soapui/Dolibarr-soapui-project.xml +++ b/test/soapui/Dolibarr-soapui-project.xml @@ -55,16 +55,16 @@ -]]>http://schemas.xmlsoap.org/wsdl/http://localhost/dolibarrnew/webservices/server_other.php<xml-fragment/>UTF-8http://localhost/dolibarrnew/webservices/server_other.php +]]>http://schemas.xmlsoap.org/wsdl/http://localhostdolibarr/dolibarrnew/webservices/server_other.php<xml-fragment/>UTF-8http://localhostdolibarr/dolibarrnew/webservices/server_other.php - ? + dolibarrkey ? - ? - ? + admin + admin @@ -341,7 +341,7 @@ -]]>http://schemas.xmlsoap.org/wsdl/http://localhost/dolibarrnew/webservices/server_invoice.php<xml-fragment/>UTF-8http://localhost/dolibarrnew/webservices/server_invoice.php +]]>http://schemas.xmlsoap.org/wsdl/http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php<xml-fragment/>UTF-8http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php @@ -394,13 +394,71 @@ -]]><xml-fragment/>UTF-8http://localhost/dolibarrnew/webservices/server_invoice.php +]]>UTF-8http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php + + + + + + ? + ? + ? + ? + ? + + + + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + + + + + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + + + + + +]]><xml-fragment/>UTF-8http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php - ? + dolibarrkey ? admin admin @@ -411,7 +469,7 @@ -]]><xml-fragment/>UTF-8http://localhost/dolibarrnew/webservices/server_invoice.php +]]><xml-fragment/>UTF-8http://localhostdolibarr/dolibarrnew/webservices/server_invoice.php @@ -601,4 +659,156 @@ all -]]> \ No newline at end of file +]]>http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php?wsdl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WS to create a product or service + + + + + WS to get product or service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]>http://schemas.xmlsoap.org/wsdl/http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php<xml-fragment/>UTF-8http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php + + + + + + ? + ? + ? + ? + ? + + + + PPP + + + Description of PPP + xxxxx + 1 + 0 + 1 + 123456 + FR + 10 + + + +]]><xml-fragment/>UTF-8http://localhostdolibarr/dolibarrnew/webservices/server_productorservice.php + + + + + + dolibarrkey + ? + admin + admin + + + 1 + + + + +]]> \ No newline at end of file From ac8b80d30284609ea7b881630e0163dd7c26ac9a Mon Sep 17 00:00:00 2001 From: eldy Date: Sun, 2 Oct 2011 01:36:05 +0200 Subject: [PATCH 19/41] Removed SCM files from packages --- build/makepack-dolibarr.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index a59bd5fc136..f26b7fe129e 100644 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -262,6 +262,7 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/pom.xml`; $ret=`rm -f $BUILDROOT/$PROJECT/default.properties`; $ret=`rm -f $BUILDROOT/$PROJECT/git2cvs.sh`; + $ret=`rm -f $BUILDROOT/$PROJECT/README.md`; $ret=`rm -fr $BUILDROOT/$PROJECT/build/html`; $ret=`rm -f $BUILDROOT/$PROJECT/build/DoliW*-*`; From 190adf2d4900938582846b1fd628f294fbf8c1a5 Mon Sep 17 00:00:00 2001 From: eldy Date: Mon, 3 Oct 2011 17:19:39 +0200 Subject: [PATCH 20/41] New: Log module outputs can be setup with "or" rule (not only "xor"). --- ChangeLog | 1 + htdocs/admin/syslog.php | 165 +++++++++--------- htdocs/admin/tools/purge.php | 5 +- htdocs/core/class/conf.class.php | 2 +- .../filemanagerdol/connectors/php/config.php | 7 - htdocs/includes/dolibarr_changes.txt | 7 - htdocs/includes/modules/modSyslog.class.php | 2 +- htdocs/install/inc.php | 16 +- htdocs/langs/en_US/admin.lang | 10 +- htdocs/langs/fr_FR/admin.lang | 8 +- htdocs/lib/functions.lib.php | 47 +++-- 11 files changed, 128 insertions(+), 142 deletions(-) diff --git a/ChangeLog b/ChangeLog index e377db27912..a41c49c6a43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ For users: For developers: - New: Add webservice to get or create a prodcut or service. +- New: Log module outputs can be setup with "or" rule (not only "xor"). - Qual: Removed no more used external libraries. - Qual: Cleaned a lot of dead code. - Qual: Parent templates classes were moved as abstract classes. diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index dc41e048ba6..149f537dabb 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Rodolphe Quiedeville * @@ -20,7 +20,7 @@ /** * \file htdocs/admin/syslog.php * \ingroup syslog - * \brief Setup page for syslog module + * \brief Setup page for logs module */ require("../main.inc.php"); @@ -31,13 +31,83 @@ if (!$user->admin) accessforbidden(); $langs->load("admin"); $langs->load("other"); +$error=0; $mesg=''; $action = GETPOST("action"); +$syslog_file_on=(defined('SYSLOG_FILE_ON') && constant('SYSLOG_FILE_ON'))?1:0; +$syslog_syslog_on=(defined('SYSLOG_SYSLOG_ON') && constant('SYSLOG_SYSLOG_ON'))?1:0; + /* * Actions */ -if ($action== 'setlevel') +// Set modes +if ($action == 'set') +{ + $db->begin(); + + $res = dolibarr_del_const($db,"SYSLOG_FILE_ON",0); + $res = dolibarr_del_const($db,"SYSLOG_SYSLOG_ON",0); + + if (! $error && GETPOST("filename")) + { + $filename=GETPOST("filename"); + $filelog=GETPOST("filename"); + $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog); + $file=@fopen($filelog,"a+"); + if ($file) + { + fclose($file); + + dol_syslog("admin/syslog: file ".$filename); + $res = dolibarr_set_const($db,"SYSLOG_FILE",$filename,'chaine',0,'',0); + if (! $res > 0) $error++; + $syslog_file_on=GETPOST('SYSLOG_FILE_ON'); + if (! $error) $res = dolibarr_set_const($db,"SYSLOG_FILE_ON",$syslog_file_on,'chaine',0,'',0); + } + else + { + $error++; + $mesg = "".$langs->trans("ErrorFailedToOpenFile",$filename).""; + } + } + + if (! $error && GETPOST("facility")) + { + $facility=GETPOST("facility"); + if (defined($_POST["facility"])) + { + // Only LOG_USER supported on Windows + if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER'; + + dol_syslog("admin/syslog: facility ".$facility); + $res = dolibarr_set_const($db,"SYSLOG_FACILITY",$facility,'chaine',0,'',0); + if (! $res > 0) $error++; + $syslog_syslog_on=GETPOST('SYSLOG_SYSLOG_ON'); + if (! $error) $res = dolibarr_set_const($db,"SYSLOG_SYSLOG_ON",$syslog_syslog_on,'chaine',0,'',0); + } + else + { + $error++; + $mesg = "".$langs->trans("ErrorUnknownSyslogConstant",$facility).""; + } + } + + if (! $error) + { + $db->commit(); + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $db->rollback(); + if (empty($mesg)) $mesg = "".$langs->trans("Error").""; + } + +} + +// Set level +if ($action == 'setlevel') { $level = GETPOST("level"); $res = dolibarr_set_const($db,"SYSLOG_LEVEL",$level,'chaine',0,'',0); @@ -54,75 +124,6 @@ if ($action== 'setlevel') } } -if ($action == 'set') -{ - $optionlogoutput=GETPOST("optionlogoutput"); - $facility=GETPOST("facility"); - if ($optionlogoutput == "syslog") - { - if (defined($_POST["facility"])) - { - $db->begin; - // Only LOG_USER supported on Windows - if (! empty($_SERVER["WINDIR"])) $facility='LOG_USER'; - - $res = dolibarr_del_const($db,"SYSLOG_FILE",0); - if (! $res > 0) $error++; - $res = dolibarr_set_const($db,"SYSLOG_FACILITY",$facility,'chaine',0,'',0); - if (! $res > 0) $error++; - dol_syslog("admin/syslog: facility ".$facility); - if (! $error) - { - $db->commit(); - $mesg = "".$langs->trans("SetupSaved").""; - } - else - { - $db->rollback(); - $mesg = "".$langs->trans("Error").""; - } - } - else - { - $mesg = "".$langs->trans("ErrorUnknownSyslogConstant",$facility).""; - } - } - - if ($optionlogoutput == "file") - { - $filename=GETPOST("filename"); - $filelog=GETPOST("filename"); - $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog); - $file=fopen($filelog,"a+"); - if ($file) - { - fclose($file); - $db->begin; - $res = dolibarr_del_const($db,"SYSLOG_FACILITY",0); - if (! $res > 0) $error++; - $res = dolibarr_set_const($db,"SYSLOG_FILE",$filename,'chaine',0,'',0); - if (! $res > 0) $error++; - dol_syslog("admin/syslog: file ".$filename); - if (! $res > 0) $error++; - if (! $error) - { - $db->commit(); - $mesg = "".$langs->trans("SetupSaved").""; - } - else - { - $db->rollback(); - $mesg = "".$langs->trans("Error").""; - } - } - else - { - $mesg = "".$langs->trans("ErrorFailedToOpenFile",$filename).""; - } - } -} - - /* * View */ @@ -162,22 +163,28 @@ print '
'.$langs->trans("Type").''.$langs->trans("Value").'
'.$langs->trans("SyslogSyslog").''.$langs->trans("SyslogFacility").': '; -print ' '.img_info('Only LOG_USER supported on Windows'); -print '
'.$langs->trans("SyslogSimpleFile").''.$langs->trans("SyslogFilename").': '; +print '
'.$langs->trans("SyslogSimpleFile").''.$langs->trans("SyslogFilename").': '; print '".$html->textwithpicto('',$langs->trans("YouCanUseDOL_DATA_ROOT")); print '
'.$langs->trans("SyslogSyslog").''.$langs->trans("SyslogFacility").': '; +print '".$html->textwithpicto('','Only LOG_USER supported on Windows'); +print '
\n"; print "\n"; +print '
'; + +print_titre($langs->trans("SyslogLevel")); + // Level print '
'; print ''; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index 2f229a00eee..de654b71832 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -25,8 +25,9 @@ include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); $langs->load("admin"); -if (! $user->admin) -accessforbidden(); +$action=GETPOST('action'); + +if (! $user->admin) accessforbidden(); if ($_GET["msg"]) $message='
'.$_GET["msg"].'
'; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 601d31dc199..9b21460fef5 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -121,7 +121,7 @@ class Conf $value=$objp->value; if ($key) { - if (! defined("$key")) define ("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE during install) + if (! defined("$key")) define ("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE_ON and SYSLOG_FILE during install) $this->global->$key=$value; if ($value && preg_match('/^MAIN_MODULE_/',$key)) diff --git a/htdocs/core/filemanagerdol/connectors/php/config.php b/htdocs/core/filemanagerdol/connectors/php/config.php index e638095379e..87dc899465c 100755 --- a/htdocs/core/filemanagerdol/connectors/php/config.php +++ b/htdocs/core/filemanagerdol/connectors/php/config.php @@ -36,13 +36,6 @@ $pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' define('DOL_URL_ROOT', $pos); -/* -$conf->syslog->enabled=1; -define('SYSLOG_FILE','c:/log/dolibarr/dolibarr.log'); -require_once("../../../../../../lib/functions.lib.php"); -dol_syslog("eee".$conf->fckeditor->dir_output); -*/ - // SECURITY: You must explicitly enable this "connector". (Set it to "true"). // WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only // authenticated users can access this file or use some kind of session checking. diff --git a/htdocs/includes/dolibarr_changes.txt b/htdocs/includes/dolibarr_changes.txt index 9e0164ecdf8..d3caf076520 100644 --- a/htdocs/includes/dolibarr_changes.txt +++ b/htdocs/includes/dolibarr_changes.txt @@ -106,13 +106,6 @@ $pos = strstr ($uri, '/'); // $pos contient alors url sans nom domaine if ($pos == '/') $pos = ''; // si $pos vaut /, on le met a '' define('DOL_URL_ROOT', $pos); -/* -$conf->syslog->enabled=1; -define('SYSLOG_FILE','c:/log/dolibarr/dolibarr.log'); -require_once("../../../../../../lib/functions.lib.php"); -dol_syslog("eee".$conf->fckeditor->dir_output); -*/ - // SECURITY: You must explicitelly enable this "connector". (Set it to "true"). $Config['Enabled'] = true ; diff --git a/htdocs/includes/modules/modSyslog.class.php b/htdocs/includes/modules/modSyslog.class.php index 3ba470b055f..1a362f43079 100644 --- a/htdocs/includes/modules/modSyslog.class.php +++ b/htdocs/includes/modules/modSyslog.class.php @@ -28,7 +28,7 @@ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); /** * \class modSyslog - * \brief Classe de description et activation du module Syslog + * \brief Class to enable/disable module Logs */ class modSyslog extends DolibarrModules { diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 062ce74d612..e2bfa1307c9 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -200,9 +200,10 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile)) } -// Forcage du log pour les install et mises a jour +// Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); +if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -212,10 +213,7 @@ if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant alrea else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } -if (! defined('SYSLOG_FILE_NO_ERROR')) -{ - define('SYSLOG_FILE_NO_ERROR',1); -} +if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); // Removed magic_quotes if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6 @@ -285,9 +283,10 @@ function conf($dolibarr_main_document_root) if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; - // Forcage du log pour les install et mises a jour + // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); + if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -297,10 +296,7 @@ function conf($dolibarr_main_document_root) else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } - if (! defined('SYSLOG_FILE_NO_ERROR')) - { - define('SYSLOG_FILE_NO_ERROR',1); - } + if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); return 1; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b25406bcfcf..2af977d0d17 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -338,8 +338,8 @@ Module30Name=Invoices Module30Desc=Invoices and credit note's management for customers. Invoice's management for suppliers Module40Name=Suppliers Module40Desc=Supplier's management and buying (orders and invoices) -Module42Name=Syslog -Module42Desc=Logging facilities (syslog) +Module42Name=Logs +Module42Desc=Logging facilities (file, syslog, ...) Module49Name=Editors Module49Desc=Editor's management Module50Name=Products @@ -1112,15 +1112,15 @@ UseEcoTaxeAbility=Support Eco-Taxe (WEEE) SetDefaultBarcodeTypeProducts=Default barcode type to use for products SetDefaultBarcodeTypeThirdParties=Default barcode type to use for third parties ##### Syslog ##### -SyslogSetup=Syslog module setup -SyslogOutput=Log output +SyslogSetup=Logs module setup +SyslogOutput=Logs outputs SyslogSyslog=Syslog SyslogFacility=Facility SyslogLevel=Level SyslogSimpleFile=File SyslogFilename=File name and path YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file. -ErrorUnknownSyslogConstant=Constant %s is not a known syslog constant +ErrorUnknownSyslogConstant=Constant %s is not a known Syslog constant ##### Donations ##### DonationsSetup=Donation module setup DonationsReceiptModel=Template of donation receipt diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index af60ee973ac..7e9589e035d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -128,7 +128,7 @@ SystemTools= Outils Système SystemToolsArea= Espace outils systèmes SystemToolsAreaDesc= Cet espace offre des fonctions d'administration diverses. Utilisez le menu pour choisir la fonctionnalité recherchée. PurgeAreaDesc= Cette page vous permet d'effacer tous les fichiers construits ou stockés par Dolibarr (fichiers temporaires ou tous les fichiers du répertoire %s). L'utilisation de cette fonction n'est pas nécessaire. Elle est fournie pour les utilisateurs qui hébergent Dolibarr chez un hébergeur qui n'offre pas les permissions de supprimer les fichiers sauvegardés par le serveur Web. -PurgeDeleteLogFile= Effacer le fichier log %s défini pour le module Syslog (pas de risque de perte de données) +PurgeDeleteLogFile= Effacer le fichier log %s défini pour le module 'Logs et traces' (pas de risque de perte de données) PurgeDeleteTemporaryFiles= Effacer tous les fichiers temporaires (pas de risque de perte de données) PurgeDeleteAllFilesInDocumentsDir= Effacer tous les fichiers du répertoire %s. Les fichiers temporaires mais aussi les fichiers dumps de sauvegardes de bases, les fichiers joints aux éléments (tiers, factures, ...) ou fichiers stockés dans le module GED seront irrémédiablement effacés. PurgeRunNow= Lancer la purge maintenant @@ -339,8 +339,8 @@ Module30Name= Factures et avoirs Module30Desc= Gestion des factures et avoirs clients. Gestion des factures fournisseurs Module40Name= Fournisseurs Module40Desc= Gestion des fournisseurs et achats (commandes et factures) -Module42Name= Syslog -Module42Desc= Utilisation de logs (syslog) +Module42Name= Logs et traces +Module42Desc= Génération de logs (fichiers, syslog, ...) Module49Name= Éditeurs Module49Desc= Gestion des éditeurs Module50Name= Produits @@ -1120,7 +1120,7 @@ UseEcoTaxeAbility= Prise en charge des éco-taxes (DEEE) SetDefaultBarcodeTypeProducts= Type de code-barres utilisé par défaut pour les produits SetDefaultBarcodeTypeThirdParties= Type de code-barres utilisé par défaut pour les tiers ##### Syslog ##### -SyslogSetup= Configuration du module Syslog +SyslogSetup= Configuration du module Logs et traces SyslogOutput= Sortie des log SyslogSyslog= Syslog SyslogFacility= Facility diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index bb6923f8697..7ee01dbf299 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -371,20 +371,22 @@ function dol_escape_htmltag($stringtoescape,$keepb=0) } /** - * Write log message in a file or to syslog process - * Pour fichier: fichier defined by SYSLOG_FILE - * Pour syslog: facility defined by SYSLOG_FACILITY + * Write log message into outputs. Possible outputs can be: + * A file if SYSLOG_FILE_ON defined: file name is then defined by SYSLOG_FILE + * Syslog if SYSLOG_SYSLOG_ON defined: facility is then defined by SYSLOG_FACILITY * Warning, les fonctions syslog sont buggues sous Windows et generent des * fautes de protection memoire. Pour resoudre, utiliser le loggage fichier, * au lieu du loggage syslog (configuration du module). - * Si SYSLOG_FILE_NO_ERROR defini, on ne gere pas erreur ecriture log - * This function works only if syslog module is enabled. - * This must must not use any call to other function calling dol_syslog (avoid infinite loop). - * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr - * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7 + * Note: If SYSLOG_FILE_NO_ERROR defined, we never output error message when writing to log fails. * - * @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR - * @param int $level Log level + * This function works only if syslog module is enabled. + * This must not use any call to other function calling dol_syslog (avoid infinite loop). + * + * @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR + * @param int $level Log level + * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr + * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7 + * @return void */ function dol_syslog($message, $level=LOG_INFO) { @@ -421,8 +423,8 @@ function dol_syslog($message, $level=LOG_INFO) if (is_object($user) && $user->id) $login=$user->login; $message=sprintf("%-8s",$login)." ".$message; - // Check if log is to a file (SYSLOG_FILE defined) or to syslog - if (defined("SYSLOG_FILE") && SYSLOG_FILE) + // Check if log is to a file (SYSLOG_FILE_ON defined) + if (defined("SYSLOG_FILE_ON") && constant("SYSLOG_FILE_ON")) { $filelog=SYSLOG_FILE; $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog); @@ -458,33 +460,26 @@ function dol_syslog($message, $level=LOG_INFO) } elseif (! defined("SYSLOG_FILE_NO_ERROR")) { - // Do not use call to functions that make call to dol_syslog, so no call to langs. + // Do not use here a call to functions that make call to dol_syslog so making call to langs. A simple print is enough. print "Error, failed to open file ".$filelog."\n"; } } - else + + // Check if log is to syslog (SYSLOG_SYSLOG_ON defined) + if (defined("SYSLOG_SYSLOG_ON") && constant("SYSLOG_SYSLOG_ON")) { if (function_exists('openlog')) // This function does not exists on some ISP (Ex: Free in France) { $facility = LOG_USER; - - if (defined("SYSLOG_FACILITY") && SYSLOG_FACILITY) + if (defined("SYSLOG_FACILITY") && constant("SYSLOG_FACILITY")) { // Exemple: SYSLOG_FACILITY vaut LOG_USER qui vaut 8. On a besoin de 8 dans $facility. $facility = constant("SYSLOG_FACILITY"); } openlog("dolibarr", LOG_PID | LOG_PERROR, (int) $facility); // (int) is required to avoid error parameter 3 expected to be long - - if (! $level) - { - syslog(LOG_ERR, $message); - } - else - { - syslog($level, $message); - } - + if (! $level) syslog(LOG_ERR, $message); + else syslog($level, $message); closelog(); } } From c05ad3b4da5dd801c8df1b3ae7eb4a631ddd59ef Mon Sep 17 00:00:00 2001 From: eldy Date: Mon, 3 Oct 2011 18:10:50 +0200 Subject: [PATCH 21/41] Doxygen --- htdocs/lib/functions.lib.php | 281 ++++++++++++++++--------------- htdocs/paybox/lib/paybox.lib.php | 34 +++- htdocs/paypal/lib/paypal.lib.php | 152 +++++++++-------- 3 files changed, 259 insertions(+), 208 deletions(-) diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 7ee01dbf299..e05aea66fe4 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -604,18 +604,19 @@ function dolibarr_print_date($time,$format='',$to_gmt=false,$outputlangs='',$enc * Output date in a string format according to outputlangs (or langs if not defined). * Return charset is always UTF-8, except if encodetoouput is defined. In this cas charset is output charset * - * @param time GM Timestamps date (or deprecated strings 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS') - * @param format Output date format - * "%d %b %Y", - * "%d/%m/%Y %H:%M", - * "%d/%m/%Y %H:%M:%S", - * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext" - * @param tzoutput true=output or 'gmt' => string is for Greenwich location - * false or 'tzserver' => output string is for local PHP server TZ usage - * 'tzuser' => output string is for local browser TZ usage - * @param outputlangs Object lang that contains language for text translation. - * @param encodetooutput false=no convert into output pagecode - * @return string Formated date or '' if time is null + * @param timestamp $time GM Timestamps date (or deprecated strings 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS') + * @param string $format Output date format + * "%d %b %Y", + * "%d/%m/%Y %H:%M", + * "%d/%m/%Y %H:%M:%S", + * "day", "daytext", "dayhour", "dayhourldap", "dayhourtext" + * @param string $tzoutput true=output or 'gmt' => string is for Greenwich location + * false or 'tzserver' => output string is for local PHP server TZ usage + * 'tzuser' => output string is for local browser TZ usage + * @param Tranlsate $outputlangs Object lang that contains language for text translation. + * @param boolean $encodetooutput false=no convert into output pagecode + * @return string Formated date or '' if time is null + * * @see dol_mktime, dol_stringtotime, dol_getdate */ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$encodetooutput=false) @@ -751,15 +752,16 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e /** * Convert a string date into a GM Timestamps date * - * @param string Date in a string - * YYYYMMDD + * @param string $string Date in a string + * YYYYMMDD * YYYYMMDDHHMMSS * YYYY-MM-DDTHH:MM:SSZ (RFC3339) * DD/MM/YY or DD/MM/YYYY (this format should not be used anymore) * DD/MM/YY HH:MM:SS or DD/MM/YYYY HH:MM:SS (this format should not be used anymore) * 19700101020000 -> 7200 - * @param gm 1=Input date is GM date, 0=Input date is local date - * @return date Date + * @param int $gm 1=Input date is GM date, 0=Input date is local date + * @return date Date + * * @see dol_print_date, dol_mktime, dol_getdate */ function dol_stringtotime($string, $gm=1) @@ -803,30 +805,30 @@ function dol_stringtotime($string, $gm=1) * Return an array with date info * PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows * - * @param timestamp Timestamp - * @param fast Fast mode - * @return array Array of informations - * If no fast mode: - * 'seconds' => $secs, - * 'minutes' => $min, - * 'hours' => $hour, - * 'mday' => $day, - * 'wday' => $dow, - * 'mon' => $month, - * 'year' => $year, - * 'yday' => floor($secsInYear/$_day_power), - * 'weekday' => gmdate('l',$_day_power*(3+$dow)), - * 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)), - * If fast mode: - * 'seconds' => $secs, - * 'minutes' => $min, - * 'hours' => $hour, - * 'mday' => $day, - * 'mon' => $month, - * 'year' => $year, - * 'yday' => floor($secsInYear/$_day_power), - * 'leap' => $leaf, - * 'ndays' => $ndays + * @param timestamp $timestamp Timestamp + * @param boolean $fast Fast mode + * @return array Array of informations + * If no fast mode: + * 'seconds' => $secs, + * 'minutes' => $min, + * 'hours' => $hour, + * 'mday' => $day, + * 'wday' => $dow, + * 'mon' => $month, + * 'year' => $year, + * 'yday' => floor($secsInYear/$_day_power), + * 'weekday' => gmdate('l',$_day_power*(3+$dow)), + * 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)), + * If fast mode: + * 'seconds' => $secs, + * 'minutes' => $min, + * 'hours' => $hour, + * 'mday' => $day, + * 'mon' => $month, + * 'year' => $year, + * 'yday' => floor($secsInYear/$_day_power), + * 'leap' => $leaf, + * 'ndays' => $ndays */ function dol_getdate($timestamp,$fast=false) { @@ -1064,13 +1066,13 @@ function dolibarr_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$s /** * Format phone numbers according to country * - * @param phone Phone number to format - * @param country Country to use for formatting - * @param cid Id of contact if known - * @param socid Id of third party if known - * @param addlink 0=no link to create action - * @param separ separation between numbers for a better visibility example : xx.xx.xx.xx.xx - * @return string Formated phone number + * @param string $phone Phone number to format + * @param string $country Country code to use for formatting + * @param int $cid Id of contact if known + * @param int $socid Id of third party if known + * @param int $addlink 0=no link to create action + * @param string $separ separation between numbers for a better visibility example : xx.xx.xx.xx.xx + * @return string Formated phone number */ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ=" ") { @@ -1143,9 +1145,9 @@ function dol_print_phone($phone,$country="FR",$cid=0,$socid=0,$addlink=0,$separ= /** * Return an IP formated to be shown on screen * - * @param ip IP - * @param mode 1=return only country/flag,2=return only IP - * @return string Formated IP, with country if GeoIP module is enabled + * @param string $ip IP + * @param int $mode 1=return only country/flag,2=return only IP + * @return string Formated IP, with country if GeoIP module is enabled */ function dol_print_ip($ip,$mode=0) { @@ -1183,7 +1185,7 @@ function dol_print_ip($ip,$mode=0) * Return country code for current user. * If software is used inside a local network, detection may fails (we need a public ip) * - * @return string country code (fr, es, it, us, ...) + * @return string Country code (fr, es, it, us, ...) */ function dol_user_country() { @@ -1208,11 +1210,11 @@ function dol_user_country() /** * Format address string * - * @param address Address - * @param htmlid Html ID - * @param mode thirdparty|contact|member|other - * @param id Id of object - * @param address Address string + * @param string $address Address + * @param int $htmlid Html ID + * @param int $mode thirdparty|contact|member|other + * @param int $id Id of object + * @return void */ function dol_print_address($address, $htmlid='gmap', $mode, $id) { @@ -1303,13 +1305,13 @@ function dol_strlen($string,$stringencoding='UTF-8') } /** - * Make a substring. Works even in mbstring module not enabled + * Make a substring. Works even in mbstring module is not enabled. * - * @param $string - * @param $start - * @param $length - * @param $stringencoding - * @return string + * @param string $string String to scan + * @param string $start Start position + * @param int $length Length + * @param string $stringencoding Page code used for input string encoding + * @return string substring */ function dol_substr($string,$start,$length,$stringencoding='') { @@ -2742,6 +2744,7 @@ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath * @param totalnboflines Total number of records/lines for all pages (if known) * @param picto Icon to use before title (should be a 32x32 transparent png file) * @param pictoisfullpath 1=Icon name is a full absolute url of image + * @return void */ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title.png', $pictoisfullpath=0) { @@ -2841,11 +2844,12 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so /** * Fonction servant a afficher les fleches de navigation dans les pages de listes * - * @param page Numero of page - * @param file Lien - * @param options Autres parametres d'url a propager dans les liens ("" par defaut) - * @param nextpage Faut-il une page suivante - * @param betweenarrows HTML Content to show between arrows + * @param int $page Numero of page + * @param string $file Lien + * @param string $options Autres parametres d'url a propager dans les liens ("" par defaut) + * @param int $nextpage Faut-il une page suivante + * @param string $betweenarrows HTML Content to show between arrows + * @return void */ function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrows='') { @@ -2866,10 +2870,10 @@ function print_fleche_navigation($page,$file,$options='',$nextpage,$betweenarrow * Fonction qui retourne un taux de tva formate pour visualisation * Utilisee dans les pdf et les pages html * - * @param rate Rate value to format (19.6 19,6 19.6% 19,6%,...) - * @param addpercent Add a percent % sign in output - * @param info_bits Miscellanous information on vat - * @return string Chaine avec montant formate (19,6 ou 19,6% ou 8.5% *) + * @param float $rate Rate value to format (19.6 19,6 19.6% 19,6%,...) + * @param boolean $addpercent Add a percent % sign in output + * @param int $info_bits Miscellanous information on vat + * @return string Chaine avec montant formate (19,6 ou 19,6% ou 8.5% *) */ function vatrate($rate,$addpercent=false,$info_bits=0) { @@ -2895,14 +2899,15 @@ function vatrate($rate,$addpercent=false,$info_bits=0) * Fonction qui formate un montant pour visualisation * Fonction utilisee dans les pdf et les pages html * - * @param amount Montant a formater - * @param html Type de formatage, html ou pas (par defaut) - * @param outlangs Objet langs pour formatage text - * @param trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage - * @param rounding Minimum number of decimal. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL) - * @param forcerounding Force the number of decimal - * @return string Chaine avec montant formate - * @see price2num Revert function of price + * @param float $amount Montant a formater + * @param string $html Type de formatage, html ou pas (par defaut) + * @param Translate $outlangs Objet langs pour formatage text + * @param int $trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage + * @param int $rounding Minimum number of decimal. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL) + * @param int $forcerounding Force the number of decimal + * @return string Chaine avec montant formate + * + * @see price2num Revert function of price */ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1) { @@ -2969,14 +2974,15 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou * an amount typed by a user. * Function to use on each input amount before any numeric test or database insert * - * @param amount Amount to convert/clean - * @param rounding ''=No rounding + * @param float $amount Amount to convert/clean + * @param string $rounding ''=No rounding * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) * 'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN) - * @param alreadysqlnb Put 1 if you know that content is already universal format number - * @return string Amount with universal numeric format (Example: '99.99999') - * @see price Opposite function of price2num + * @param int $alreadysqlnb Put 1 if you know that content is already universal format number + * @return string Amount with universal numeric format (Example: '99.99999') + * + * @see price Opposite function of price2num */ function price2num($amount,$rounding='',$alreadysqlnb=0) { @@ -3054,10 +3060,10 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) /** * Return localtaxe rate for a particular tva * - * @param tva Vat taxe - * @param local Local taxe to search and return - * @param societe_acheteuse Object of buying third party - * @return int 0 if not found, localtax if found + * @param float $tva Vat taxe + * @param int $local Local taxe to search and return + * @param Societe $societe_acheteuse Object of buying third party + * @return int 0 if not found, localtax if found */ function get_localtax($tva, $local, $societe_acheteuse="") { @@ -3076,7 +3082,7 @@ function get_localtax($tva, $local, $societe_acheteuse="") $sql = "SELECT t.localtax1, t.localtax2"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'"; - $sql .= " AND t.taux =".$tva." AND t.active = 1"; + $sql .= " AND t.taux = ".$tva." AND t.active = 1"; $sql .= " ORDER BY t.localtax1 ASC, t.localtax2 ASC"; $resql=$db->query($sql); @@ -3094,9 +3100,9 @@ function get_localtax($tva, $local, $societe_acheteuse="") * Return vat rate of a product in a particular selling country or default country * vat if product is unknown * - * @param idprod Id of product or 0 if not a predefined product - * @param countrycode Country code (FR, US, IT, ...) - * @return int <0 if KO, Vat rate if OK + * @param int $idprod Id of product or 0 if not a predefined product + * @param string $countrycode Country code (FR, US, IT, ...) + * @return int <0 if KO, Vat rate if OK * TODO May be this should be better as a method of product class */ function get_product_vat_for_country($idprod, $countrycode) @@ -3684,9 +3690,9 @@ function dol_microtime_float() /** * Return if a text is a html content * - * @param msg Content to check - * @param option 0=Full detection, 1=Fast check - * @return boolean true/false + * @param string $msg Content to check + * @param int $option 0=Full detection, 1=Fast check + * @return boolean true/false */ function dol_textishtml($msg,$option=0) { @@ -3721,9 +3727,10 @@ function dol_textishtml($msg,$option=0) * There is two type of substitions: * - From $substitutionarray (oldval=>newval) * - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules - * @param chaine Source string in which we must do substitution - * @param substitutionarray Array with key->val to substitute - * @return string Output string after subsitutions + * + * @param string $chaine Source string in which we must do substitution + * @param array $substitutionarray Array with key->val to substitute + * @return string Output string after subsitutions */ function make_substitutions($chaine,$substitutionarray) { @@ -3740,9 +3747,10 @@ function make_substitutions($chaine,$substitutionarray) /** * Complete the $substitutionarray with more entries * - * @param substitutionarray Array substitution old value => new value value - * @param outputlangs If we want substitution from special constants, we provide a language - * @param object If we want substitution from special constants, we provide data in a source object + * @param array $substitutionarray Array substitution old value => new value value + * @param Translate $outputlangs If we want substitution from special constants, we provide a language + * @param Object $object If we want substitution from special constants, we provide data in a source object + * @return void */ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='') { @@ -3780,10 +3788,11 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object=' * @param date_end End date * @param format Output format * @param outputlangs Output language + * @return void */ function print_date_range($date_start,$date_end,$format = '',$outputlangs='') { - print get_date_range($date_start,$date_end,$format,$outputlangs); + print get_date_range($date_start,$date_end,$format,$outputlangs); } /** @@ -3793,6 +3802,7 @@ function print_date_range($date_start,$date_end,$format = '',$outputlangs='') * @param date_end End date * @param format Output format * @param outputlangs Output language + * @return string String */ function get_date_range($date_start,$date_end,$format = '',$outputlangs='') { @@ -3822,11 +3832,12 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='') /** * Get formated messages to output (Used to show messages on html output). * - * @param mesgstring Message string - * @param mesgarray Messages array - * @param style Style of message output ('ok' or 'error') - * @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) - * @return string Return html output + * @param string $mesgstring Message string + * @param array $mesgarray Messages array + * @param string $style Style of message output ('ok' or 'error') + * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @return string Return html output + * * @see dol_print_error * @see dol_htmloutput_errors */ @@ -3919,10 +3930,11 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb /** * Get formated error messages to output (Used to show messages on html output). * - * @param mesgstring Error message - * @param mesgarray Error messages array - * @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) - * @return html Return html output + * @param string $mesgstring Error message + * @param array $mesgarray Error messages array + * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @return string Return html output + * * @see dol_print_error * @see dol_htmloutput_mesg */ @@ -3934,10 +3946,12 @@ function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) /** * Print formated messages to output (Used to show messages on html output). * - * @param mesgstring Message - * @param mesgarray Messages array - * @param style Which style to use ('ok', 'error') - * @param keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify) + * @param string $mesgstring Message + * @param array $mesgarray Messages array + * @param string $style Which style to use ('ok', 'error') + * @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify) + * @return void + * * @see dol_print_error * @see dol_htmloutput_errors */ @@ -3983,9 +3997,11 @@ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb /** * Print formated error messages to output (Used to show messages on html output). * - * @param mesgstring Error message - * @param mesgarray Error messages array - * @param keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @param string $mesgstring Error message + * @param array $mesgarray Error messages array + * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @return void + * * @see dol_print_error * @see dol_htmloutput_mesg */ @@ -4031,8 +4047,8 @@ function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensiti /** * Check if a string is in UTF8 * - * @param $str String to check - * @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary) + * @param string $str String to check + * @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary) */ function utf8_check($str) { @@ -4059,8 +4075,8 @@ function utf8_check($str) * Return an UTF-8 string encoded into OS filesystem encoding. This function is used to define * value to pass to filesystem PHP functions. * - * @param string $str String to encode (UTF-8) - * @return string Encoded string (UTF-8, ISO-8859-1) + * @param string $str String to encode (UTF-8) + * @return string Encoded string (UTF-8, ISO-8859-1) */ function dol_osencode($str) { @@ -4079,12 +4095,12 @@ function dol_osencode($str) /** * Return an id or code from a code or id. Store Code-Id in a cache. * - * @param db Database handler - * @param key Code to get Id - * @param tablename Table name without prefix - * @param fieldkey Field for code - * @param fieldid Field for id - * @return int Id of code + * @param DoliDB $db Database handler + * @param string $key Code to get Id + * @param string $tablename Table name without prefix + * @param string $fieldkey Field for code + * @param string $fieldid Field for id + * @return int Id of code */ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') { @@ -4122,8 +4138,8 @@ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') /** * Verify if condition in string is ok or not * - * @param string $strRights - * @return boolean true or false + * @param string $strRights String with condition to check + * @return boolean true or false */ function verifCond($strRights) { @@ -4151,6 +4167,7 @@ function verifCond($strRights) * This function is called by verifCond() * * @param string $s + * @return void */ function dol_eval($s) { @@ -4167,8 +4184,8 @@ function dol_eval($s) /** * Return img flag of country for a language code or country code * - * @param codelang Language code (en_IN, fr_CA...) or Country code (IN, FR) - * @return string HTML img string with flag. + * @param string $codelang Language code (en_IN, fr_CA...) or Country code (IN, FR) + * @return string HTML img string with flag. */ function picto_from_langcode($codelang) { diff --git a/htdocs/paybox/lib/paybox.lib.php b/htdocs/paybox/lib/paybox.lib.php index 5efad6cfce9..b00e62e0db6 100755 --- a/htdocs/paybox/lib/paybox.lib.php +++ b/htdocs/paybox/lib/paybox.lib.php @@ -21,6 +21,16 @@ * \ingroup paybox * \brief Library for common paybox functions */ + + + +/** + * Show header + * + * @param string $title Title of page + * @param string $head Head string to add int head section + * @return void + */ function llxHeaderPaybox($title, $head = "") { global $user, $conf, $langs; @@ -50,6 +60,11 @@ function llxHeaderPaybox($title, $head = "") print ''."\n"; } +/** + * Show footer + * + * @return void + */ function llxFooterPayBox() { print "\n"; @@ -60,13 +75,13 @@ function llxFooterPayBox() /** * Create a redirect form to paybox form * - * @param $PRICE - * @param $CURRENCY - * @param $EMAIL - * @param $urlok - * @param $urlko - * @param $TAG - * @return int 1 if OK, -1 if ERROR + * @param int $PRICE Price + * @param string $CURRENCY Currency + * @param string $EMAIL EMail + * @param string $urlok Url to go back if payment is OK + * @param string $urlko Url to go back if payment is KO + * @param string $TAG Tag + * @return int 1 if OK, -1 if ERROR */ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG) { @@ -231,8 +246,9 @@ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG) /** * Show footer of company in HTML pages * - * @param $fromcompany - * @param $langs + * @param Societe $fromcompany Third party + * @param Translate $langs Output language + * @return void */ function html_print_paybox_footer($fromcompany,$langs) { diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 95439c7f9e6..6c7c086f897 100755 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -23,7 +23,13 @@ */ - +/** + * Show header + * + * @param string $title + * @param string $head + * @return void + */ function llxHeaderPaypal($title, $head = "") { global $user, $conf, $langs; @@ -53,6 +59,11 @@ function llxHeaderPaypal($title, $head = "") print ''."\n"; } +/** + * Show footer + * + * @return void + */ function llxFooterPaypal() { print "\n"; @@ -63,8 +74,9 @@ function llxFooterPaypal() /** * Show footer of company in HTML pages * - * @param $fromcompany - * @param $langs + * @param Societe $fromcompany Third party + * @param Translate $langs Output language + * @return void */ function html_print_paypal_footer($fromcompany,$langs) { @@ -128,6 +140,7 @@ function html_print_paypal_footer($fromcompany,$langs) /** * Define head array for tabs of paypal tools setup pages + * * @return Array of head */ function paypaladmin_prepare_head() @@ -250,12 +263,13 @@ function getPaypalPaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f /** * Send redirect to paypal to browser * - * @param $paymentAmount - * @param $currencyCodeType - * @param $paymentType - * @param $returnURL - * @param $cancelURL - * @param $tag + * @param float $paymentAmount Amount + * @param string $currencyCodeType Currency code + * @param string $paymentType Payment type + * @param string $returnURL Url to use if payment is OK + * @param string $cancelURL Url to use if payment is KO + * @param string $tag Tag + * @return void */ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$returnURL,$cancelURL,$tag) { @@ -295,8 +309,24 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re } dol_syslog("expresscheckout redirect with CallSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $landingPage, $solutionType, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum"); - $resArray = CallSetExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, - $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum); + $resArray = CallSetExpressCheckout( + $paymentAmount, + $currencyCodeType, + $paymentType, + $returnURL, + $cancelURL, + $tag, + $solutionType, + $landingPage, + $shipToName, + $shipToStreet, + $shipToCity, + $shipToState, + $shipToCountryCode, + $shipToZip, + $shipToStreet2, + $phoneNum + ); /* For direct payment with credit card { //$resArray = DirectPayment (...); @@ -349,8 +379,7 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re ' phoneNum: the phoneNum entered on the merchant's site '-------------------------------------------------------------------------------------------------------------------------------------------- */ -function CallSetExpressCheckout( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, -$shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum) +function CallSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum) { //------------------------------------------------------------------------------------------------------------------------------------ // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation @@ -402,17 +431,12 @@ $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $ship return $resArray; } -/* - '------------------------------------------------------------------------------------------- - ' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. - ' - ' Inputs: - ' None - ' Returns: - ' The NVP Collection object of the GetExpressCheckoutDetails Call Response. - '------------------------------------------------------------------------------------------- +/** + * Prepares the parameters for the GetExpressCheckoutDetails API Call. + * + * @return array The NVP Collection object of the GetExpressCheckoutDetails Call Response. */ -function GetDetails( $token ) +function GetDetails($token) { //'-------------------------------------------------------------- //' At this point, the buyer has completed authorizing the payment @@ -450,12 +474,12 @@ function GetDetails( $token ) } -/* - '------------------------------------------------------------------------------------------------------------------------------------------- - ' Purpose: Validate payment - '-------------------------------------------------------------------------------------------------------------------------------------------- +/** + * Validate payment + * + * @return void */ -function ConfirmPayment( $token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag ) +function ConfirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag) { /* Gather the information to make the final call to finalize the PayPal payment. The variable nvpstr @@ -486,36 +510,26 @@ function ConfirmPayment( $token, $paymentType, $currencyCodeType, $payerID, $ipa return $resArray; } -/* - '------------------------------------------------------------------------------------------------------------------------------------------- - ' Purpose: This function makes a DoDirectPayment API call - ' - ' Inputs: - ' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization - ' paymentAmount: total value of the shopping cart - ' currencyCode: currency code value the PayPal API - ' firstName: first name as it appears on credit card - ' lastName: last name as it appears on credit card - ' street: buyer's street address line as it appears on credit card - ' city: buyer's city - ' state: buyer's state - ' countryCode: buyer's country code - ' zip: buyer's zip - ' creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... ) - ' creditCardNumber: buyers credit card number without any spaces, dashes or any other characters - ' expDate: credit card expiration date - ' cvv2: Card Verification Value - ' - '------------------------------------------------------------------------------------------- - ' - ' Returns: - ' The NVP Collection object of the DoDirectPayment Call Response. - '-------------------------------------------------------------------------------------------------------------------------------------------- +/** + * This function makes a DoDirectPayment API call + * + * paymentType: paymentType has to be one of the following values: Sale or Order or Authorization + * paymentAmount: total value of the shopping cart + * currencyCode: currency code value the PayPal API + * firstName: first name as it appears on credit card + * lastName: last name as it appears on credit card + * street: buyer's street address line as it appears on credit card + * city: buyer's city + * state: buyer's state + * countryCode: buyer's country code + * zip: buyer's zip + * creditCardType: buyer's credit card type (i.e. Visa, MasterCard ... ) + * creditCardNumber: buyers credit card number without any spaces, dashes or any other characters + * expDate: credit card expiration date + * cvv2: Card Verification Value + * @return array The NVP Collection object of the DoDirectPayment Call Response. */ - -function DirectPayment( $paymentType, $paymentAmount, $creditCardType, $creditCardNumber, -$expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, -$countryCode, $currencyCode, $tag ) +function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode, $tag) { //declaring of global variables global $conf, $langs; @@ -547,9 +561,10 @@ $countryCode, $currencyCode, $tag ) /** * hash_call: Function to perform the API call to PayPal using API signature - * @param methodName is name of API method. - * @param nvpStr is nvp string. - * @return array returns an associtive array containing the response from the server. + * + * @param string $methodName is name of API method. + * @param string $nvpStr is nvp string. + * @return array returns an associtive array containing the response from the server. */ function hash_call($methodName,$nvpStr) { @@ -606,8 +621,8 @@ function hash_call($methodName,$nvpStr) { dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS); //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10 - curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); - if ($PROXY_USER) curl_setopt ($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS); + curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); + if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS); } //NVPRequest for submitting to server @@ -650,7 +665,9 @@ function hash_call($methodName,$nvpStr) } /** - * Get API errors + * Get API errors + * + * @return array Array of errors */ function GetApiError() { @@ -672,12 +689,13 @@ function GetApiError() } -/*'---------------------------------------------------------------------------------- +/** * This function will take NVPString and convert it to an Associative Array and it will decode the response. * It is usefull to search for a particular key and displaying arrays. - * @nvpstr is NVPString. - * @nvpArray is Associative Array. - ---------------------------------------------------------------------------------- + * + * @param string $nvpstr NVPString + * @return array nvpArray = Associative Array + * ---------------------------------------------------------------------------------- */ function deformatNVP($nvpstr) { From 38c828ceb45b69c5f7d094ead38e9da1fb10105a Mon Sep 17 00:00:00 2001 From: eldy Date: Mon, 3 Oct 2011 18:58:18 +0200 Subject: [PATCH 22/41] Fix: Line of invoices are correctly encoded --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php index 26c189a2456..088247a7af0 100644 --- a/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/includes/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -451,14 +451,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures try { $listlines = $odfHandler->setSegment('lines'); - //var_dump($object->lines);exit; foreach ($object->lines as $line) { $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); foreach($tmparray as $key => $val) { - try { - $listlines->setVars($key, $val); + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); } catch(OdfException $e) { From 98ab39683744a188eaa2c6f61a402676cf67c336 Mon Sep 17 00:00:00 2001 From: eldy Date: Mon, 3 Oct 2011 22:48:10 +0200 Subject: [PATCH 23/41] New: Can choose number of character before triggering Ajax autocomplete of product search. --- htdocs/core/class/html.form.class.php | 43 ++++++++++++++------------- htdocs/langs/fr_FR/admin.lang | 2 +- htdocs/product/admin/produit.php | 20 +++++++++---- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4a861d0eb3a..bda5bddf78c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -907,14 +907,15 @@ class Form /** * Return list of products for customer in Ajax if Ajax activated or go to select_produits_do * - * @param selected Preselected products - * @param htmlname Name of HTML seletc field (must be unique in page) - * @param filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param limit Limit on number of returned lines - * @param price_level Level of price to show - * @param status -1=Return all products, 0=Products not on sell, 1=Products on sell - * @param finished 2=all, 1=finished, 0=raw material - * @param $selected_input_value Value of preselected input text (with ajax) + * @param int $selected Preselected products + * @param string $htmlname Name of HTML seletc field (must be unique in page) + * @param int $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param int $limit Limit on number of returned lines + * @param int $price_level Level of price to show + * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $finished 2=all, 1=finished, 0=raw material + * @param string $selected_input_value Value of preselected input text (with ajax) + * @return void */ function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1,$finished=2,$selected_input_value='',$hidelabel=0) { @@ -947,16 +948,16 @@ class Form /** * Return list of products for a customer * - * @param selected Preselected product - * @param htmlname Name of select html - * @param filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param limit Limite sur le nombre de lignes retournees - * @param price_level Level of price to show - * @param filterkey Filter on product - * @param status -1=Return all products, 0=Products not on sell, 1=Products on sell - * @param finished Filter on finished field: 2=No filter - * @param disableout Disable print output - * @return array Array of keys for json + * @param int $selected Preselected product + * @param string $htmlname Name of select html + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param int $limit Limite sur le nombre de lignes retournees + * @param int $price_level Level of price to show + * @param string $filterkey Filter on product + * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $finished Filter on finished field: 2=No filter + * @param int $disableout Disable print output + * @return array Array of keys for json */ function select_produits_do($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$disableout=0) { @@ -976,16 +977,16 @@ class Form $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='". $langs->getDefaultLang() ."'"; } $sql.= ' WHERE p.entity IN (0,'.(! empty($conf->entities['product']) ? $conf->entities['product'] : $conf->entity).')'; - if($finished == 0) + if ($finished == 0) { $sql.= " AND p.finished = ".$finished; } - elseif($finished == 1) + elseif ($finished == 1) { $sql.= " AND p.finished = ".$finished; if ($status >= 0) $sql.= " AND p.tosell = ".$status; } - elseif($status >= 0) + elseif ($status >= 0) { $sql.= " AND p.tosell = ".$status; } diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 7e9589e035d..b0957345e4b 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -49,7 +49,7 @@ ConfirmAjax= Utiliser les popups de confirmation Ajax UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. ActivityStateToSelectCompany= Ajouter une option de filtrage lors des recherches pour afficher/masquer les tiers en exercice ou ayant cessés d'exercer SearchFilter=Options des filtres de recherche -NumberOfKeyToSearch=Nb caractères déclenchant la recherche: %s +NumberOfKeyToSearch=Nb carac. déclenchant recherche: %s ViewFullDateActions= Visualiser les dates des actions en entier dans la fiche tiers NotAvailableWhenAjaxDisabled= Non disponible quand Ajax désactivé JavascriptDisabled= Javascript désactivé diff --git a/htdocs/product/admin/produit.php b/htdocs/product/admin/produit.php index 85f44e0e627..1f39bc3981f 100644 --- a/htdocs/product/admin/produit.php +++ b/htdocs/product/admin/produit.php @@ -5,7 +5,7 @@ * Copyright (C) 2007 Auguria SARL * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2011 Juanjo Menent - * + * * 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 2 of the License, or @@ -33,12 +33,16 @@ require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php"); $langs->load("admin"); // Security check -if (!$user->admin) -accessforbidden(); +if (! $user->admin) accessforbidden(); $action = GETPOST("action"); $value = GETPOST("value"); + +/* + * Actions + */ + if ($action == 'nbprod') { $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", $value,'chaine',0,'',$conf->entity); @@ -50,7 +54,7 @@ else if ($action == 'multiprix_num') if ($action == 'multiprix') { $multiprix = GETPOST("activate_multiprix"); - + $res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $multiprix,'chaine',0,'',$conf->entity); $res =dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "5",'chaine',0,'',$conf->entity); } @@ -81,7 +85,6 @@ else if ($action == 'set') $res = dolibarr_set_const($db, "PRODUIT_USE_ECOTAXE", $ecotaxe,'chaine',0,'',$conf->entity); }*/ - if($action) { if (! $res > 0) $error++; @@ -190,7 +193,12 @@ if (! $conf->use_javascript_ajax) else { print '
'; - print $html->selectyesno("activate_usesearchtoselectproduct",$conf->global->PRODUIT_USE_SEARCH_TO_SELECT,1); + $arrval=array('0'=>$langs->trans("No"), + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', + '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', + '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', + ); + print $html->selectarray("activate_usesearchtoselectproduct",$arrval,$conf->global->PRODUIT_USE_SEARCH_TO_SELECT); print ''; print ''; print "
'; + print ''; print ''; print ''; + print '
'; + print ''; print ''; - print '
'.$langs->trans("Supplier").''; if ($_GET["rowid"]) { @@ -330,12 +322,13 @@ if ($_GET["id"] || $_GET["ref"]) print '
'; + print '
'; + + print '
'; print '   '; - print ''; + print '
'; print ''; - print ''; } /* ************************************************************************** */ @@ -346,14 +339,13 @@ if ($_GET["id"] || $_GET["ref"]) print "\n
\n"; - if ($_GET["action"] != 'add_price') { - + if ($_GET["action"] != 'add_price' && $action != 'updateprice') + { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; print $langs->trans("AddSupplierPrice").''; } - } print "\n
\n"; @@ -371,16 +363,15 @@ if ($_GET["id"] || $_GET["ref"]) print ''; print_liste_field_titre($langs->trans("Suppliers"),$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); print ''.$langs->trans("SupplierRef").''; - if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) - print_liste_field_titre($langs->trans("Availability"),$_SERVER["PHP_SELF"],"pfp.fk_availability","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,"",$sortfield,$sortorder); + if (!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) print_liste_field_titre($langs->trans("Availability"),$_SERVER["PHP_SELF"],"pfp.fk_availability","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"],"pfp.quantity","",$param,'align="right"',$sortfield,$sortorder); print ''.$langs->trans("PriceQtyMinHT").''; print_liste_field_titre($langs->trans("UnitPriceHT"),$_SERVER["PHP_SELF"],"pfp.unitprice","",$param,'align="right"',$sortfield,$sortorder); print ''; print "\n"; $product_fourn = new ProductFournisseur($db); - $product_fourn_list = $product_fourn->fetch_product_fournisseur($product->id); + $product_fourn_list = $product_fourn->list_product_fournisseur_price($product->id); if (count($product_fourn_list)>0) { @@ -406,7 +397,7 @@ if ($_GET["id"] || $_GET["ref"]) } // Quantity - print ''; + print ''; print $productfourn->fourn_qty; print ''; diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 5be0bee72fc..7853db14257 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -133,8 +133,8 @@ else $sql.= ') '; //if ($fourn_id > 0) // The DISTINCT is used to avoid duplicate from this link //{ - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pf.rowid = pfp.fk_product_fournisseur"; + //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur as pf ON p.rowid = pf.fk_product"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; //} $sql.= ' WHERE p.entity IN (0,'.(! empty($conf->entities['product']) ? $conf->entities['product'] : $conf->entity).')'; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ @@ -156,7 +156,7 @@ else if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; if ($catid) $sql.= " AND cp.fk_categorie = ".$catid; if ($search_categ) $sql.= " AND cp.fk_categorie = ".$search_categ; - if ($fourn_id > 0) $sql.= " AND pf.fk_soc = ".$fourn_id; + if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; $sql.= " p.fk_product_type, p.tms,"; $sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte"; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 93b96132635..e964f9bca59 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -96,12 +96,6 @@ $sql.= ' SUM(s.reel) as stock_physique'; $sql.= ' FROM ('.MAIN_DB_PREFIX.'product as p'; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -// We disable this because this create duplicate lines -/*if ($_GET["fourn_id"] > 0) -{ - $fourn_id = $_GET["fourn_id"]; - $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf"; -}*/ $sql.= ') LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; $sql.= " WHERE p.entity = ".$conf->entity; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ @@ -112,9 +106,12 @@ if ($sall) // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) { - if ($type==1) { + if ($type==1) + { $sql.= " AND p.fk_product_type = '1'"; - } else { + } + else + { $sql.= " AND p.fk_product_type <> '1'"; } } From 0b3cbf9b84b87ebd6c548ffe810282066f320bae Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 4 Oct 2011 18:25:09 +0800 Subject: [PATCH 25/41] Fix: do not use dol_hash function here --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 75ac238aa12..1ca8345cb23 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -215,7 +215,7 @@ class Translate { // Using a memcached server if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER)) { - $usecachekey=$newdomain.'_'.$langofdir.'_'.dol_hash($file_lang); // Should not contains special chars + $usecachekey=$newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars } // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) From 2099cfebf342898bb72f1206bc5185d59bfefaad Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 4 Oct 2011 20:47:50 +0800 Subject: [PATCH 26/41] Fix: uniformize code --- htdocs/categories/categorie.php | 109 +++++++++++++++----------------- 1 file changed, 50 insertions(+), 59 deletions(-) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index ee0bf083dc1..c5ead2e504d 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Brice Davoleau - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent @@ -32,50 +32,47 @@ require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); $langs->load("categories"); $langs->load("products"); -$socid=GETPOST('socid'); -$id=GETPOST('id'); -$ref=GETPOST('ref'); -$mesg=GETPOST('mesg'); +$socid = GETPOST('socid'); +$id = GETPOST('id'); +$ref = GETPOST('ref'); +$type = GETPOST('type'); +$mesg = GETPOST('mesg'); $dbtablename = ''; // For categories on third parties -if (! empty($_REQUEST["socid"])) { - $_REQUEST["id"]=$_REQUEST["socid"]; - $id=$socid; -} -if (! isset($_REQUEST["type"])) $_REQUEST["type"]=0; -if ($_REQUEST["type"] == 1) $socid=$id; -if ($_REQUEST["type"] == 2) $socid=$id; +if (! empty($socid)) $id = $socid; +if (! isset($type)) $type = 0; +if ($type == 1 || $type == 2) $socid = $id; -if ($_REQUEST["id"] || $_REQUEST["ref"]) +if ($id || $ref) { - if ($_REQUEST["type"] == 0) { - $type = 'product'; + if ($type == 0) { + $elementtype = 'product'; $objecttype = 'produit|service&categorie'; - $objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["ref"])?$_REQUEST["ref"]:''); + $objectid = isset($id)?$id:(isset($ref)?$ref:''); $dbtablename = 'product'; - $fieldid = isset($_REQUEST["ref"])?'ref':'rowid'; + $fieldid = isset($ref)?'ref':'rowid'; } - if ($_REQUEST["type"] == 1) { - $type = 'fournisseur'; + if ($type == 1) { + $elementtype = 'fournisseur'; $objecttype = 'societe&categorie'; - $objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["socid"])?$_REQUEST["socid"]:''); + $objectid = isset($id)?$id:(isset($socid)?$socid:''); $fieldid = 'rowid'; } - if ($_REQUEST["type"] == 2) { - $type = 'societe'; + if ($type == 2) { + $elementtype = 'societe'; $objecttype = 'societe&categorie'; - $objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["socid"])?$_REQUEST["socid"]:''); + $objectid = isset($id)?$id:(isset($socid)?$socid:''); $fieldid = 'rowid'; } - if ($_REQUEST["type"] == 3) { - $type = 'member'; + if ($type == 3) { + $elementtype = 'member'; $objecttype = 'adherent&categorie'; - $objectid = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["ref"])?$_REQUEST["ref"]:''); + $objectid = isset($id)?$id:(isset($ref)?$ref:''); $dbtablename = 'adherent'; - $fieldid = isset($_REQUEST["ref"])?'ref':'rowid'; + $fieldid = isset($ref)?'ref':'rowid'; } } @@ -91,25 +88,24 @@ $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid //Suppression d'un objet d'une categorie if ($_REQUEST["removecat"]) { - if ($_REQUEST["type"]==0 && ($user->rights->produit->creer || $user->rights->service->creer)) + if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); $object = new Product($db); - if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]); - if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]); - $type = 'product'; + $result = $object->fetch($id, $ref); + $elementtype = 'product'; } - if ($_REQUEST["type"]==1 && $user->rights->societe->creer) + if ($type==1 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); } - if ($_REQUEST["type"]==2 && $user->rights->societe->creer) + if ($type==2 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); } - if ($_REQUEST["type"] == 3 && $user->rights->adherent->creer) + if ($type == 3 && $user->rights->adherent->creer) { require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); $object = new Adherent($db); @@ -118,46 +114,42 @@ if ($_REQUEST["removecat"]) $cat = new Categorie($db); $result=$cat->fetch($_REQUEST["removecat"]); - $result=$cat->del_type($object,$type); + $result=$cat->del_type($object,$elementtype); } // Add object into a category if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) { - $_GET["id"]=$_REQUEST["id"]; - $_GET["type"]=$_REQUEST["type"]; - - if ($_REQUEST["type"]==0 && ($user->rights->produit->creer || $user->rights->service->creer)) + if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); $object = new Product($db); - if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]); - if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]); - $type = 'product'; + $result = $object->fetch($id, $ref); + $elementtype = 'product'; } - if ($_REQUEST["type"]==1 && $user->rights->societe->creer) + if ($type==1 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); - $type = 'fournisseur'; + $elementtype = 'fournisseur'; } - if ($_REQUEST["type"]==2 && $user->rights->societe->creer) + if ($type==2 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); - $type = 'societe'; + $elementtype = 'societe'; } - if ($_REQUEST["type"]==3 && $user->rights->adherent->creer) + if ($type==3 && $user->rights->adherent->creer) { require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); $object = new Adherent($db); $result = $object->fetch($objectid); - $type = 'member'; + $elementtype = 'member'; } $cat = new Categorie($db); $result=$cat->fetch($_REQUEST["catMere"]); - $result=$cat->add_type($object,$type); + $result=$cat->add_type($object,$elementtype); if ($result >= 0) { $mesg='
'.$langs->trans("WasAddedSuccessfully",$cat->label).'
'; @@ -202,7 +194,7 @@ if ($socid) print ''; print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field @@ -234,14 +226,15 @@ if ($socid) } // Address - print ""; + print ''; // Zip / Town print '"; print '"; // Country - if ($soc->pays) { + if ($soc->pays) + { print '\n"; $var=true; $var=!$var; -print ''; +print ''; print ''; print "'; $var=!$var; -print ''; +print ''; print ''; print "'; +try +{ + set_include_path('/usr/share/php/'); + @require_once('FirePHPCore/FirePHP.class.php'); + restore_include_path(); + $var=!$var; + print ''; + print ''; + print "'; +} +catch(Exception $e) +{ + // Do nothing + print ''."\n"; +} + print "
'.$langs->trans("ThirdPartyName").''; - print $html->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); + print $html->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom','','&type='.$type); print '
".$langs->trans('Address')."".nl2br($soc->address)."
'.$langs->trans('Address').''.nl2br($soc->address).'
'.$langs->trans('Zip').''.$soc->cp."'.$langs->trans('Town').''.$soc->ville."
'.$langs->trans('Country').''; $img=picto_from_langcode($soc->pays_code); print ($img?$img.' ':''); @@ -282,9 +275,9 @@ if ($socid) if ($soc->fournisseur) formCategory($db,$soc,1); } -else if ($_GET["id"] || $_GET["ref"]) +else if ($id || $ref) { - if ($_GET["type"] == 0) + if ($type == 0) { $langs->load("products"); @@ -296,8 +289,7 @@ else if ($_GET["id"] || $_GET["ref"]) // Produit $product = new Product($db); - if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); - if ($_GET["id"]) $result = $product->fetch($_GET["id"]); + $result = $product->fetch($id, $ref); llxHeader("","",$langs->trans("CardProduct".$product->type)); @@ -340,7 +332,7 @@ else if ($_GET["id"] || $_GET["ref"]) formCategory($db,$product,0); } - if ($_GET["type"] == 3) + if ($type == 3) { $langs->load("members"); @@ -353,8 +345,7 @@ else if ($_GET["id"] || $_GET["ref"]) // Produit $member = new Adherent($db); - if ($_GET["ref"]) $result = $member->fetch('',$_GET["ref"]); - if ($_GET["id"]) $result = $member->fetch($_GET["id"]); + $result = $member->fetch($id, $ref); $membert = new AdherentType($db); $membert->fetch($member->typeid); From b295a866a5821c5b1fc191fbaf6756117d16828a Mon Sep 17 00:00:00 2001 From: eldy Date: Wed, 5 Oct 2011 12:51:55 +0200 Subject: [PATCH 27/41] Fix: Fix a serious database default. Table llx_product_fournisseur was linked with llx_product_fournisseur_price with a link 1-1 so was useless. I removed it. This reduce a lot of sophisticated code and will make import of prices easier. This also increase speed. --- htdocs/fourn/class/fournisseur.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 10 +- .../install/mysql/migration/3.1.0-3.2.0.sql | 3 +- .../llx_product_fournisseur_price.key.sql | 2 +- htdocs/product/class/product.class.php | 69 +++++++--- htdocs/product/fournisseurs.php | 129 +++++++++--------- 6 files changed, 119 insertions(+), 96 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 8d94a59f270..22b6af10af0 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -165,7 +165,7 @@ class Fournisseur extends Societe { $prod = new ProductFournisseur($this->db); $prod->fetch($fk_product); - $prod->fetch_fourn_data($this->id); + //$prod->fetch_fourn_data($this->id); $commf->fetch($idc); $commf->addline("Toto",120,1,$prod->tva, $prod->id, 0, $prod->ref_fourn); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 7582969cd99..61b7b48ccd7 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -240,7 +240,7 @@ class ProductFournisseur extends Product * @param fournid Supplier ID * @return int < 0 if error, > 0 if ok */ - function fetch_fourn_data($fournid) + /*function fetch_fourn_data($fournid) { global $conf; @@ -268,7 +268,7 @@ class ProductFournisseur extends Product dol_syslog(get_class($this)."::fetch_fourn_data error=".$this->error, LOG_ERR); return -1; } - } + }*/ /** * Loads the price information of a provider @@ -325,17 +325,17 @@ class ProductFournisseur extends Product global $conf; // Suppliers list - $sql = "SELECT s.nom as supplier_name, "; + $sql = "SELECT s.nom as supplier_name,"; $sql.= " s.rowid as fourn_id,"; $sql.= " pfp.ref_fourn,"; - $sql.= " pfp.rowid as product_fourn_pri_id, "; + $sql.= " pfp.rowid as product_fourn_pri_id,"; $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " ON pfp.fk_soc = s.rowid"; $sql.= " WHERE s.entity = ".$conf->entity; $sql.= " AND pfp.fk_product = ".$prodid; - $sql.= " ORDER BY s.nom, pfp.quantity"; + $sql.= " ORDER BY s.nom, pfp.quantity, pfp.price"; dol_syslog(get_class($this)."::list_product_fournisseur_price sql=".$sql, LOG_DEBUG); diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index a60961dee63..653a2203341 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -57,7 +57,8 @@ ALTER TABLE llx_product_fournisseur_price ADD COLUMN entity integer DEFAULT 1 NO UPDATE llx_product_fournisseur_price as a, llx_product_fournisseur as b SET a.fk_product = b.fk_product, a.fk_soc = b.fk_soc, a.ref_fourn = b.ref_fourn, a.entity = b.entity WHERE a.fk_product_fournisseur = b.rowid AND (a.fk_product IS NULL OR a.fk_soc IS NULL OR a.fk_product = 0 OR a.fk_soc = 0); -ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, entity); +ALTER TABLE llx_product_fournisseur_price DROP INDEX uk_product_fournisseur_price_ref; +ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, quantity, entity); ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_product (fk_product, entity); ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity); ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_price_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql index 7d3dc962152..a625efcfbbc 100644 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.key.sql @@ -26,7 +26,7 @@ ALTER TABLE llx_product_fournisseur_price ADD CONSTRAINT fk_product_fournisseur_ -- Added to remove table llx_product_fournisseur -ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, entity); +ALTER TABLE llx_product_fournisseur_price ADD UNIQUE INDEX uk_product_fournisseur_price_ref (ref_fourn, fk_soc, quantity, entity); ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_product (fk_product, entity); ALTER TABLE llx_product_fournisseur_price ADD INDEX idx_product_fourn_price_fk_soc (fk_soc, entity); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e5d0e712536..e6bb32deb36 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1760,47 +1760,78 @@ class Product extends CommonObject /** - * Add a supplier reference for the product + * Add a supplier price for the product. + * Note: Duplicate ref is accepted for different quantity only or for different companies. * - * @param user User that make link - * @param id_fourn Supplier id - * @param ref_fourn Supplier ref - * @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK + * @param User $user User that make link + * @param int $id_fourn Supplier id + * @param string $ref_fourn Supplier ref + * @param float $quantity Quantity minimum for price + * @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK */ - function add_fournisseur($user, $id_fourn, $ref_fourn) + function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity) { global $conf; $now=dol_now(); - $sql = "SELECT rowid, fk_product"; + if ($ref_fourn) + { + $sql = "SELECT rowid, fk_product"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql.= " WHERE fk_soc = ".$id_fourn; + $sql.= " AND ref_fourn = '".$ref_fourn."'"; + $sql.= " AND fk_product != ".$this->id; + $sql.= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::add_fournisseur sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj) + { + // If the supplier ref already exists but for another product (duplicate ref is accepted for different quantity only or different companies) + $this->product_id_already_linked = $obj->fk_product; + return -3; + } + $this->db->free($resql); + } + } + + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE fk_soc = ".$id_fourn; - $sql.= " AND ref_fourn = '".$ref_fourn."'"; + if ($ref_fourn) $sql.= " AND ref_fourn = '".$ref_fourn."'"; + else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; + $sql.= " AND quantity = '".$quantity."'"; + $sql.= " AND fk_product = ".$this->id; $sql.= " AND entity = ".$conf->entity; - dol_syslog("Product::add_fournisseur sql=".$sql); + dol_syslog(get_class($this)."::add_fournisseur sql=".$sql); $resql=$this->db->query($sql); if ($resql) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); - // The reference supplier does not exist, we create it for this product. + // The reference supplier does not exist, we create it for this product. if (! $obj) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; $sql.= "datec"; $sql.= ", entity"; $sql.= ", fk_product"; $sql.= ", fk_soc"; $sql.= ", ref_fourn"; + $sql.= ", quantity"; $sql.= ", fk_user"; $sql.= ") VALUES ("; - $sql.= $this->db->idate($now); + $sql.= "'".$this->db->idate($now)."'"; $sql.= ", ".$conf->entity; $sql.= ", ".$this->id; $sql.= ", ".$id_fourn; $sql.= ", '".$ref_fourn."'"; + $sql.= ", ".$quantity; $sql.= ", ".$user->id; $sql.= ")"; @@ -1813,22 +1844,16 @@ class Product extends CommonObject else { $this->error=$this->db->lasterror(); - dol_syslog("Product::add_fournisseur ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::add_fournisseur ".$this->error, LOG_ERR); return -1; } } - // If the supplier ref already exists for this product - else if ($obj->fk_product == $this->id) + // If the supplier price already exists for this product and quantity + else { $this->product_fourn_price_id = $obj->rowid; return 0; } - // If the supplier ref already exists but for another product - else - { - $this->product_id_already_linked = $obj->fk_product; - return -3; - } } else { diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 95647c1ca4f..a3b9ccfc9d8 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -35,6 +35,10 @@ $langs->load("suppliers"); $langs->load("bills"); $action=GETPOST('action'); +$id=GETPOST('id','int'); +$ref=GETPOST('ref'); +$socid=GETPOST('socid'); +$error=0; $mesg = ''; // If socid provided by ajax company selector if (! empty($_REQUEST['search_fourn_id'])) @@ -45,10 +49,8 @@ if (! empty($_REQUEST['search_fourn_id'])) } // Security check -$id = GETPOST('id')?GETPOST('id'):GETPOST('ref'); -$fieldid = isset($_GET["ref"])?'ref':'rowid'; if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'produit|service&fournisseur',$id,'product','','',$fieldid); +$result=restrictedArea($user, 'produit|service&fournisseur', ($id>0?$id:$ref), 'product', '', '', ($id>0?'rowid':'ref')); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -56,56 +58,70 @@ $sortorder = GETPOST("sortorder",'alpha'); if (! $sortfield) $sortfield="s.nom"; if (! $sortorder) $sortorder="ASC"; -$mesg = ''; /* * Actions */ -if ($_GET["action"] == 'remove_pf') +if ($action == 'remove_pf') { $product = new ProductFournisseur($db); - if ($product->fetch($_GET["id"]) > 0) + if ($product->fetch($id) > 0) { if ($_GET["rowid"]) { $result=$product->remove_product_fournisseur_price($_GET["rowid"]); - $_GET["action"] = ''; + $action = ''; $mesg = '
'.$langs->trans("PriceRemoved").'.
'; } } } -if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel")) +if ($action == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel")) { $id_fourn=GETPOST("id_fourn"); if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn"); $ref_fourn=GETPOST("ref_fourn"); if (empty($ref_fourn)) $ref_fourn=GETPOST("search_ref_fourn"); + $quantity=GETPOST("qty"); + + if (empty($quantity)) + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'
'; + } + if (empty($ref_fourn)) // TODO Why not making this optionnal ? + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")).'
'; + } + if ($id_fourn <= 0) + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")).'
'; + } + if ($_POST["price"] < 0 || $_POST["price"] == '') + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'
'; + } $product = new ProductFournisseur($db); - $result=$product->fetch(GETPOST("id")); - if ($result > 0) + $result=$product->fetch($id); + if ($result <= 0) { - $db->begin(); + $error++; + $mesg=$product->error; + } - $error=0; - if (! $ref_fourn) - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")).'
'; - } - if ($id_fourn <= 0) - { - //print "eee".$_POST["id_fourn"]; - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")).'
'; - } + if (! $error) + { + $db->begin(); if (! $error) { - $ret=$product->add_fournisseur($user, $id_fourn, $ref_fourn); + $ret=$product->add_fournisseur($user, $id_fourn, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice if ($ret == -3) { $error++; @@ -124,44 +140,27 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc if (! $error) { - if ($_POST["qty"]) - { - if ($_POST["price"] >= 0) - { - $supplier=new Fournisseur($db); - $result=$supplier->fetch($id_fourn); + $supplier=new Fournisseur($db); + $result=$supplier->fetch($id_fourn); - $ret=$product->update_buyprice($_POST["qty"], $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn); - if ($ret < 0) - { - $error++; - $mesg='
'.$product->error.'
'; - } - } - else - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'
'; - } - } - else + $ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn); + if ($ret < 0) { $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'
'; + $mesg='
'.$product->error.'
'; } } if (! $error) { $db->commit(); - $_POST['action']=''; $action=''; } else { $db->rollback(); } - } + } } if ($_POST["cancel"] == $langs->trans("Cancel")) @@ -179,21 +178,19 @@ if ($_POST["cancel"] == $langs->trans("Cancel")) $html = new Form($db); -if ($_GET["id"] || $_GET["ref"]) +if ($id || $ref) { - if ($_GET["action"] <> 're-edit') + if ($action <> 're-edit') { $product = new ProductFournisseur($db); - $result = $product->fetch($_GET["id"],$_GET["ref"]); - $result = $product->fetch_fourn_data($_REQUEST["id_fourn"]); - //print 'eeeee'.$_GET["socid"];exit; + $result = $product->fetch($id,$ref); + //$result = $product->fetch_fourn_data($_REQUEST["id_fourn"]); llxHeader("","",$langs->trans("CardProduct".$product->type)); } - if ( $result ) + if ($result) { - - if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') + if ($action <> 'edit' && $action <> 're-edit') { /* * En mode visu @@ -242,7 +239,7 @@ if ($_GET["id"] || $_GET["ref"]) // Form to add or update a price - if (($_GET["action"] == 'add_price' || $_POST["action"] == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer)) + if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer)) { $langs->load("suppliers"); @@ -262,13 +259,13 @@ if ($_GET["id"] || $_GET["ref"]) print ''; - print ''; // Ref supplier - print ''; print ''; @@ -302,8 +299,8 @@ if ($_GET["id"] || $_GET["ref"]) // Qty min print ''; - print ''; - print ''; + print ''; - print ''; - print ''; + print ''; @@ -339,7 +336,7 @@ if ($_GET["id"] || $_GET["ref"]) print "\n
\n"; - if ($_GET["action"] != 'add_price' && $action != 'updateprice') + if ($action != 'add_price' && $action != 'updateprice') { if ($user->rights->produit->creer || $user->rights->service->creer) { From 822d4508eb5e2b67a5877bf0eb8979c54fbeda8b Mon Sep 17 00:00:00 2001 From: eldy Date: Wed, 5 Oct 2011 13:13:36 +0200 Subject: [PATCH 28/41] Qual: Removed PHPCodesniffer warnings --- htdocs/fourn/class/fournisseur.class.php | 11 ++-- .../fourn/class/fournisseur.product.class.php | 50 +++++++++---------- htdocs/societe/class/societe.class.php | 7 +-- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 22b6af10af0..153d37e3581 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -277,11 +277,12 @@ class Fournisseur extends Societe } /** - * \brief Renvoie nom clicable (avec eventuellement le picto) - * \param withpicto Inclut le picto dans le lien - * \param option Sur quoi pointe le lien - * \param maxlen Longueur max libelle - * \return string Chaine avec URL + * Return a link on thirdparty (with picto) + * + * @param withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only) + * @param option Target of link ('', 'customer', 'prospect', 'supplier') + * @param maxlen Max length of text + * @return string String with URL */ function getNomUrl($withpicto=0,$option='supplier',$maxlen=0) { diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 61b7b48ccd7..9427bb327a1 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -53,9 +53,9 @@ class ProductFournisseur extends Product * * @param DoliDB $DB Database handler */ - function ProductFournisseur($db) + function ProductFournisseur($DB) { - $this->db = $db; + $this->db = $DB; } @@ -63,8 +63,8 @@ class ProductFournisseur extends Product /** * Remove all prices for this couple supplier-product * - * @param id_fourn Supplier Id - * @return int < 0 if error, > 0 if ok + * @param int $id_fourn Supplier Id + * @return int < 0 if error, > 0 if ok */ function remove_fournisseur($id_fourn) { @@ -100,8 +100,8 @@ class ProductFournisseur extends Product /** * Remove a price for a couple supplier-product * - * @param rowid Line id of price - * @return int <0 if KO, >0 if OK + * @param int $rowid Line id of price + * @return int <0 if KO, >0 if OK */ function remove_product_fournisseur_price($rowid) { @@ -273,8 +273,8 @@ class ProductFournisseur extends Product /** * Loads the price information of a provider * - * @param rowid line id - * @return int < 0 if KO, 0 if OK but not found, > 0 if OK + * @param int $rowid Line id + * @return int < 0 if KO, 0 if OK but not found, > 0 if OK */ function fetch_product_fournisseur_price($rowid) { @@ -317,18 +317,16 @@ class ProductFournisseur extends Product /** * List all supplier prices of a product * - * @param int $rowid id du produit - * @return array Array of ProductFournisseur + * @param int $prodid Id of product + * @return array Array of Products with new properties to define supplier price */ function list_product_fournisseur_price($prodid) { global $conf; // Suppliers list - $sql = "SELECT s.nom as supplier_name,"; - $sql.= " s.rowid as fourn_id,"; - $sql.= " pfp.ref_fourn,"; - $sql.= " pfp.rowid as product_fourn_pri_id,"; + $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; + $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn,"; $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.fk_availability"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; @@ -340,10 +338,9 @@ class ProductFournisseur extends Product dol_syslog(get_class($this)."::list_product_fournisseur_price sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { - $prod_fourn = array(); + $retarray = array(); while ($record = $this->db->fetch_array($resql)) { @@ -365,7 +362,7 @@ class ProductFournisseur extends Product { if ($prodfourn->fourn_qty!=0) { - $prodfourn->fourn_unitprice = $prodfourn->fourn_price/$prodfourn->fourn_qty; + $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price/$prodfourn->fourn_qty,'MU'); } else { @@ -373,11 +370,11 @@ class ProductFournisseur extends Product } } - $prod_fourn[]=$prodfourn; + $retarray[]=$prodfourn; } $this->db->free($resql); - return $prod_fourn; + return $retarray; } else { @@ -390,8 +387,8 @@ class ProductFournisseur extends Product /** * Load properties for minimum price * - * @param rowid Product id - * @return int <0 if KO, >0 if OK + * @param int $prodid Product id + * @return int <0 if KO, >0 if OK */ function find_min_price_product_fournisseur($prodid) { @@ -407,10 +404,8 @@ class ProductFournisseur extends Product $this->fourn_name = ''; $this->id = ''; - $sql = "SELECT s.nom as supplier_name,"; - $sql.= " s.rowid as fourn_id,"; - $sql.= " pfp.ref_fourn,"; - $sql.= " pfp.rowid as product_fourn_price_id,"; + $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; + $sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; $sql.= " pfp.price, pfp.quantity, pfp.unitprice"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE s.entity = ".$conf->entity; @@ -445,7 +440,10 @@ class ProductFournisseur extends Product } /** + * Display supplier of product * + * @param int $withpicto Add picto + * @return string String with supplier price */ function getSocNomUrl($withpicto=0) { @@ -456,7 +454,9 @@ class ProductFournisseur extends Product } /** + * Display price of product * + * @return string String with supplier price */ function display_price_product_fournisseur() { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 36b8bf3a7d0..246444086bc 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -299,7 +299,7 @@ class Societe extends CommonObject $result = 0; $this->name = trim($this->name); $this->nom=$this->name; // For backward compatibility - + if (! $this->name) { $this->errors[] = 'ErrorBadThirdPartyName'; @@ -1413,8 +1413,9 @@ class Societe extends CommonObject /** * Return a link on thirdparty (with picto) - * @param withpicto Inclut le picto dans le lien (0=No picto, 1=Inclut le picto dans le lien, 2=Picto seul) - * @param option Sur quoi pointe le lien ('', 'customer', 'prospect', 'supplier') + * + * @param withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only) + * @param option Target of link ('', 'customer', 'prospect', 'supplier') * @param maxlen Max length of text * @return string String with URL */ From f4a3e6a1a7b01595556d866a1dd0908703da622d Mon Sep 17 00:00:00 2001 From: eldy Date: Wed, 5 Oct 2011 13:56:32 +0200 Subject: [PATCH 29/41] Enhance PHPUnit tests --- htdocs/core/class/commonobject.class.php | 13 +++++---- test/phpunit/SocieteTest.php | 37 ++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fad26472892..d7399da1a40 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1075,8 +1075,9 @@ abstract class CommonObject /** * Update public note of element - * @param note_public New value for note - * @return int <0 if KO, >0 if OK + * + * @param string $note_public New value for note + * @return int <0 if KO, >0 if OK */ function update_note_public($note_public) { @@ -1562,8 +1563,8 @@ abstract class CommonObject } else return 0; } - - + + /** * Function to check if an object is used by others * @@ -1609,7 +1610,7 @@ abstract class CommonObject } else return 0; } - + // -------------------- // TODO: All functions here must be redesigned and moved as they are not business functions but output functions @@ -1619,7 +1620,7 @@ abstract class CommonObject /** * * Enter description here ... - * + * * @param unknown_type $objectid * @param unknown_type $objecttype * @param unknown_type $withpicto diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index 393b50d9363..738bb8d35c6 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -167,9 +167,42 @@ class SocieteTest extends PHPUnit_Framework_TestCase $db=$this->savdb; $localobject->note='New note after update'; - $result=$localobject->update($localobject->id,$user); + //$localobject->note_public='New note public after update'; + $localobject->name='New name'; + $localobject->address='New address'; + $localobject->zip='New zip'; + $localobject->town='New town'; + $localobject->status=0; + $localobject->tel='New tel'; + $localobject->fax='New fax'; + $localobject->email='New email'; + $localobject->url='New url'; + $result=$localobject->update($localobject->id,$user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); + $result=$localobject->update_note($localobject->note); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + //$result=$localobject->update_note_public($localobject->note_public); + //print __METHOD__." id=".$localobject->id." result=".$result."\n"; + //$this->assertLessThan($result, 0); + + $newobject=new Societe($this->savdb); + $result=$newobject->fetch($localobject->id); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + $this->assertEquals($localobject->note, $newobject->note); + //$this->assertEquals($localobject->note_public, $newobject->note_public); + $this->assertEquals($localobject->name, $newobject->name); + $this->assertEquals($localobject->address, $newobject->address); + $this->assertEquals($localobject->zip, $newobject->zip); + $this->assertEquals($localobject->town, $newobject->town); + $this->assertEquals($localobject->status, $newobject->status); + $this->assertEquals($localobject->tel, $newobject->tel); + $this->assertEquals($localobject->fax, $newobject->fax); + $this->assertEquals($localobject->email, $newobject->email); + $this->assertEquals($localobject->url, $newobject->url); return $localobject; } @@ -208,7 +241,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase $result=$localobject->getFullAddress(); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertContains('MyTown', $result); + $this->assertContains("New address\nNew zip New town", $result); $result=$localobject->isInEEC(); print __METHOD__." id=".$localobject->id." pays_code=".$this->pays_code." result=".$result."\n"; From 6eea1f56c977f79e660acd01668b70cea3c8e6b0 Mon Sep 17 00:00:00 2001 From: eldy Date: Wed, 5 Oct 2011 14:29:16 +0200 Subject: [PATCH 30/41] More comments. --- htdocs/core/class/hookmanager.class.php | 11 +++++++---- htdocs/product/class/product.class.php | 14 ++++++-------- htdocs/societe/class/societe.class.php | 16 +++++++--------- test/phpunit/AllTests.php | 5 +++++ 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index b59cddc5764..950a060428e 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -51,11 +51,14 @@ class HookManager /** * Init array this->hooks with instantiated controler - * A hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS + * + * First, a hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS * with value nameofhookkey1:nameofhookkey2:...:nameofhookkeyn. - * This add into conf->hooks_module an entries ('modulename'=>nameofhookkey) - * After this, this->hooks is defined - * @param arraytype Array list of hooked tab/features. For example: thirdpartytab, ... + * This add into conf->hooks_modules an entrie ('modulename'=>nameofhookkey) + * Then, when this function is called, an array this->hooks is defined with instance of controler + * classes that support the hook called + * + * @param arraytype Array list of searched hooks tab/features. For example: 'thirdpartytab', 'thirdparty',... * @return int Always 1 */ function callHooks($arraytype) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e6bb32deb36..277fd8a85ab 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -570,25 +570,23 @@ class Product extends CommonObject } } + // Removed extrafields + //$result=$this->deleteExtraFields($this); + //if ($result < 0) $error++; + if (! $error) { // Actions on extra fields (by external module or standard code) include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); $hookmanager=new HookManager($this->db); - $hookmanager->callHooks(array('product_extrafields')); + $hookmanager->callHooks(array('product')); $parameters=array(); $action='delete'; - $reshook=$hookmanager->executeHooks('deleteExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('deleteProduct',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if (! empty($hookmanager->error)) { $error++; $this->error=$hookmanager->error; } - else if (empty($reshook)) - { - // TODO - //$result=$this->deleteExtraFields($this); - //if ($result < 0) $error++; - } } // Delete product diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 246444086bc..5e3ccc52321 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -942,25 +942,23 @@ class Societe extends CommonObject } } + // Removed extrafields + //$result=$this->deleteExtraFields($this); + //if ($result < 0) $error++; + if (! $error) { - // Actions on extra fields (by external module or standard code) + // Additionnal action by hooks include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); $hookmanager=new HookManager($this->db); - $hookmanager->callHooks(array('thirdparty_extrafields')); + $hookmanager->callHooks(array('thirdparty')); $parameters=array(); $action='delete'; - $reshook=$hookmanager->executeHooks('deleteExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('deleteThirdparty',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if (! empty($hookmanager->error)) { $error++; $this->error=$hookmanager->error; } - else if (empty($reshook)) - { - // TODO - //$result=$this->deleteExtraFields($this); - //if ($result < 0) $error++; - } } // Remove third party diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 864315d3c86..f697b33ad6c 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -45,6 +45,11 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class AllTests { + /** + * Function suite to make all PHPUnit tests + * + * @return void + */ public static function suite() { $suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework'); From 927200f8f5086dde31f2e01e14793e6f66305784 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 5 Oct 2011 18:11:09 +0200 Subject: [PATCH 31/41] Trad: Log module outputs can be setup with "or" rule (not only "xor") --- htdocs/langs/ca_ES/admin.lang | 2 +- htdocs/langs/es_ES/admin.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang index b870106be2e..ac81dba9a25 100644 --- a/htdocs/langs/ca_ES/admin.lang +++ b/htdocs/langs/ca_ES/admin.lang @@ -339,7 +339,7 @@ Module30Desc=Gestió de factures i abonaments de clients. Gestió factures de pr Module40Name=Proveïdors Module40Desc=Gestió de proveïdors Module42Name=Syslog -Module42Desc=Utilització de logs (syslog) +Module42Desc=Generació de logs (arxius, syslog,...) Module49Name=Editors Module49Desc=Gestió d'editors Module50Name=Productes diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index 6402e08c8d6..3d1abf13eed 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -339,7 +339,7 @@ Module30Desc=Gestión de facturas y abonos a clientes. Gestión facturas de prov Module40Name=Proveedores Module40Desc=Gestión de proveedores Module42Name=Syslog -Module42Desc=Utilización de logs (syslog) +Module42Desc=Generación de logs (archivos, syslog,...) Module49Name=Editores Module49Desc=Gestión de editores Module50Name=Productos From 24c9a7d26d6193bf64abec4091c2ee328cc8bc36 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 6 Oct 2011 00:10:06 +0800 Subject: [PATCH 32/41] Fix: reorder line after update line with fk_parent_line --- htdocs/comm/propal/class/propal.class.php | 56 +++++++++++-------- htdocs/commande/class/commande.class.php | 17 ++++-- htdocs/compta/facture/class/facture.class.php | 21 +++++-- htdocs/core/class/commonobject.class.php | 13 ++++- 4 files changed, 74 insertions(+), 33 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6adbc8f94d1..4731f0343da 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -495,24 +495,31 @@ class Propal extends CommonObject $staticline=new PropaleLigne($this->db); $staticline->fetch($rowid); $this->line->oldline = $staticline; - - $this->line->rowid=$rowid; - $this->line->desc=$desc; - $this->line->qty=$qty; - $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=$txlocaltax1; - $this->line->localtax2_tx=$txlocaltax2; - $this->line->remise_percent=$remise_percent; - $this->line->subprice=$pu; - $this->line->info_bits=$info_bits; - $this->line->total_ht=$total_ht; - $this->line->total_tva=$total_tva; - $this->line->total_localtax1=$total_localtax1; - $this->line->total_localtax2=$total_localtax2; - $this->line->total_ttc=$total_ttc; - $this->line->special_code=$special_code; - $this->line->fk_parent_line=$fk_parent_line; - $this->line->skip_update_total=$skip_update_total; + + // Reorder if fk_parent_line change + if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + { + $rangmax = $this->line_max($fk_parent_line); + $this->line->rang = $rangmax + 1; + } + + $this->line->rowid = $rowid; + $this->line->desc = $desc; + $this->line->qty = $qty; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = $txlocaltax1; + $this->line->localtax2_tx = $txlocaltax2; + $this->line->remise_percent = $remise_percent; + $this->line->subprice = $pu; + $this->line->info_bits = $info_bits; + $this->line->total_ht = $total_ht; + $this->line->total_tva = $total_tva; + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; + $this->line->total_ttc = $total_ttc; + $this->line->special_code = $special_code; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->skip_update_total = $skip_update_total; // TODO deprecated $this->line->price=$price; @@ -521,6 +528,9 @@ class Propal extends CommonObject $result=$this->line->update(); if ($result > 0) { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); + $this->update_price(1); $this->fk_propal = $this->id; @@ -2646,8 +2656,9 @@ class PropaleLigne } /** - * \brief Mise a jour de l'objet ligne de propale en base - * \return int <0 si ko, >0 si ok + * Mise a jour de l'objet ligne de propale en base + * + * @return int <0 si ko, >0 si ok */ function update($notrigger=0) { @@ -2692,9 +2703,10 @@ class PropaleLigne $sql.= " , info_bits=".$this->info_bits; if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); + if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog("PropaleLigne::update sql=$sql"); + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -2714,7 +2726,7 @@ class PropaleLigne else { $this->error=$this->db->error(); - dol_syslog("PropaleLigne::update Error ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 409df18639f..6f33f315b6d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2222,6 +2222,13 @@ class Commande extends CommonObject $staticline=new OrderLine($this->db); $staticline->fetch($rowid); $this->line->oldline = $staticline; + + // Reorder if fk_parent_line change + if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + { + $rangmax = $this->line_max($fk_parent_line); + $this->line->rang = $rangmax + 1; + } $this->line->rowid=$rowid; $this->line->desc=$desc; @@ -2250,6 +2257,9 @@ class Commande extends CommonObject $result=$this->line->update(); if ($result > 0) { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); + // Mise a jour info denormalisees $this->update_price(1); @@ -3095,11 +3105,10 @@ class OrderLine if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; } $sql.= " , product_type=".$this->product_type; $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); - + if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog("OrderLine::update sql=$sql"); - + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -3119,7 +3128,7 @@ class OrderLine else { $this->error=$this->db->error(); - dol_syslog("OrderLine::update Error ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c65623d2cfe..9bcd64fd4e3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2016,6 +2016,13 @@ class Facture extends CommonObject $staticline=new FactureLigne($this->db); $staticline->fetch($rowid); $this->line->oldline = $staticline; + + // Reorder if fk_parent_line change + if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + { + $rangmax = $this->line_max($fk_parent_line); + $this->line->rang = $rangmax + 1; + } $this->line->rowid = $rowid; $this->line->desc = $desc; @@ -2044,6 +2051,9 @@ class Facture extends CommonObject $result=$this->line->update(); if ($result > 0) { + // Reorder if child line + if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); + // Mise a jour info denormalisees au niveau facture $this->update_price(1); $this->db->commit(); @@ -3567,8 +3577,9 @@ class FactureLigne } /** - * Update line into database - * @return int <0 if KO, >0 if OK + * Update line into database + * + * @return int <0 if KO, >0 if OK */ function update() { @@ -3621,10 +3632,10 @@ class FactureLigne $sql.= ",total_localtax1=".price2num($this->total_localtax1).""; $sql.= ",total_localtax2=".price2num($this->total_localtax2).""; $sql.= ",fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); + if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog("FactureLigne::update sql=".$sql); - + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -3643,7 +3654,7 @@ class FactureLigne else { $this->error=$this->db->error(); - dol_syslog("FactureLigne::update Error ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::update Error ".$this->error, LOG_ERR); $this->db->rollback(); return -2; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d7399da1a40..62051b58c37 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -967,6 +967,8 @@ abstract class CommonObject { $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE rowid ='.$rowid; + + dol_syslog(get_class($this)."::getRangOfLine sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1008,13 +1010,18 @@ abstract class CommonObject $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; $sql.= ' AND fk_parent_line = '.$fk_parent_line; + + dol_syslog(get_class($this)."::line_max sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); - if (! empty($row[0])) { + if (! empty($row[0])) + { return $row[0]; - } else { + } + else + { return $this->getRangOfLine($fk_parent_line); } } @@ -1024,6 +1031,8 @@ abstract class CommonObject { $sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; + + dol_syslog(get_class($this)."::line_max sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { From b6f27d9ec6579bba7998fa53aebe88fb0e79b54f Mon Sep 17 00:00:00 2001 From: eldy Date: Wed, 5 Oct 2011 22:41:08 +0200 Subject: [PATCH 33/41] New: Try a hidden feature to have log using firephp. --- htdocs/lib/functions.lib.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index e05aea66fe4..9438d318c57 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -483,6 +483,15 @@ function dol_syslog($message, $level=LOG_INFO) closelog(); } } + + // Check if log is to syslog (SYSLOG_FIREPHP_ON defined) + if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON")) + { + require_once(SYSLOG_FIREPHP_PATH.'FirePHPCore/FirePHP.class.php'); + ob_start(); + $firephp = FirePHP::getInstance(true); + $firephp->log($message); + } } } From bddf4c6626a071a1299d08ad1b116b5fd9655d54 Mon Sep 17 00:00:00 2001 From: eldy Date: Wed, 5 Oct 2011 22:54:39 +0200 Subject: [PATCH 34/41] Qual: Removed ob* functions --- htdocs/adherents/class/adherent.class.php | 4 ---- htdocs/lib/functions2.lib.php | 12 ++++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 8fe32acc931..f332c0c5500 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1560,11 +1560,9 @@ class Adherent extends CommonObject //curl_setopt($ch, CURLOPT_POST, 0); //curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5"); //--- Start buffering - //ob_start(); $result=curl_exec($ch); dol_syslog($result); //--- End buffering and clean output - //ob_end_clean(); if (curl_error($ch) > 0) { // error @@ -1632,11 +1630,9 @@ class Adherent extends CommonObject //curl_setopt($ch, CURLOPT_POST, 0); //curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5"); //--- Start buffering - //ob_start(); $result=curl_exec($ch); dol_syslog($result); //--- End buffering and clean output - //ob_end_clean(); $rescode=curl_error($ch); if ($rescode > 0) { diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php index 971438d3beb..7dd7ed08c28 100644 --- a/htdocs/lib/functions2.lib.php +++ b/htdocs/lib/functions2.lib.php @@ -981,19 +981,15 @@ function dol_print_reduction($reduction=0,$langs) /** - * Return OS version + * Return OS version. + * Note that PHP_OS returns only OS (not version) and OS PHP was built on, not + * necessarly OS PHP runs on. * * @return string OS version */ function version_os() { - // Get version of OS - ob_start(); - phpinfo(); - $chaine = ob_get_contents(); - ob_end_clean(); - preg_match('/System <\/td>
'; - if(count($prodsfather) > 0) + if (count($prodsfather) > 0) { print ''; - if(count($prodsfather) > 0) + if (count($prodsfather) > 0) { print '
'.$langs->trans("Supplier").''; + print '
'.$langs->trans("Supplier").''; if ($_GET["rowid"]) { $supplier=new Fournisseur($db); - $supplier->fetch($_GET["socid"]); + $supplier->fetch($socid); print $supplier->getNomUrl(1); - print ''; + print ''; print ''; print ''; } @@ -280,14 +277,14 @@ if ($_GET["id"] || $_GET["ref"]) print '
'.$langs->trans("SupplierRef").''; + print '
'.$langs->trans("SupplierRef").''; if ($_GET["rowid"]) { print $product->fourn_ref; } else { - print 'ref_fourn).'">'; + print ''; } print '
'.$langs->trans("QtyMin").''; + print ''.$langs->trans("QtyMin").''; $quantity = $_REQUEST["qty"] ? $_REQUEST["qty"] : "1"; if ($_GET["rowid"]) { @@ -315,8 +312,8 @@ if ($_GET["id"] || $_GET["ref"]) print ''; } print ''.$langs->trans("PriceQtyMin").'fourn_price)).'">'; + print ''.$langs->trans("PriceQtyMin").'fourn_price)?price($product->fourn_price):'')).'">'; print ' '; print $html->select_PriceBaseType(($_POST["price_base_type"]?$_POST["price_base_type"]:$product->price_base_type), "price_base_type"); print '([^<]*)<\/td>/i',$chaine,$reg); - $osversion=$reg[1]; + $osversion=php_uname(); return $osversion; } From c16c6d379874e4774b59c22f5be5dd5b5eb180e0 Mon Sep 17 00:00:00 2001 From: eldy Date: Wed, 5 Oct 2011 23:03:05 +0200 Subject: [PATCH 35/41] Fix: Close database handler --- htdocs/admin/system/index.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 4af1b6b3342..f918caeab1f 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -29,8 +29,7 @@ $langs->load("admin"); $langs->load("user"); $langs->load("install"); -if (!$user->admin) - accessforbidden(); +if (! $user->admin) accessforbidden(); /* @@ -123,6 +122,8 @@ print '
'; //print "
\n"; print info_admin($langs->trans("SystemInfoDesc")).'
'; - llxFooter(); + +$db->close(); + ?> From 72e6e954f6936050b31a39b80ca91e584a98dce4 Mon Sep 17 00:00:00 2001 From: eldy Date: Wed, 5 Oct 2011 23:49:05 +0200 Subject: [PATCH 36/41] Qual: Removed warnings --- htdocs/product/composition/fiche.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/product/composition/fiche.php b/htdocs/product/composition/fiche.php index d3707e569bd..f5a254e650f 100644 --- a/htdocs/product/composition/fiche.php +++ b/htdocs/product/composition/fiche.php @@ -123,7 +123,7 @@ if ($cancel == $langs->trans("Cancel")) */ // action recherche des produits par mot-cle et/ou par categorie -if($action == 'search' ) +if ($action == 'search') { $current_lang = $langs->getDefaultLang(); @@ -174,9 +174,9 @@ dol_fiche_head($head, 'subproduct', $titre, 0, $picto); if ($id || $ref) { - if ( $result ) + if ($result) { - if ($action <> 'edit' &&$action <> 'search' && $action <> 're-edit') + if ($action <> 'edit' && $action <> 'search' && $action <> 're-edit') { /* * En mode visu @@ -209,7 +209,7 @@ if ($id || $ref) // List of subproducts $prods_arbo = $product->get_arbo_each_prod(); - if(count($prods_arbo) > 0) + if (count($prods_arbo) > 0) { print '
'; print ''.$langs->trans("ProductAssociationList").'
'; @@ -236,7 +236,7 @@ if ($id || $ref) // Number of parent products print '
'.$langs->trans("ParentProductsNumber").''.count($prodsfather).'
'; print ''.$langs->trans("ProductParentList").'
'; @@ -321,7 +321,7 @@ if ($id || $ref) // Number of parent products print '
'.$langs->trans("ParentProductsNumber").''.count($prodsfather).'
'; print ''.$langs->trans("ProductParentList").'
'; @@ -375,7 +375,7 @@ if ($id || $ref) print '
'; print ''; - if($action == 'search') + if ($action == 'search') { print '
'; print '
'; @@ -408,7 +408,7 @@ if ($id || $ref) if ($prod_arbo->type==2 || $prod_arbo->type==3) { $is_pere=0; - $prod_arbo->get_sousproduits_arbo (); + $prod_arbo->get_sousproduits_arbo(); // associations sousproduits $prods_arbo = $prod_arbo->get_arbo_each_prod(); if (count($prods_arbo) > 0) @@ -421,7 +421,8 @@ if ($id || $ref) } } } - if ($is_pere==1) { + if ($is_pere==1) + { $i++; continue; } @@ -498,8 +499,8 @@ if ($action == '') print "\n\n"; +llxFooter(); $db->close(); -llxFooter(); ?> From cd04d51ea7b0f86dfd35495c3da21f422c781f27 Mon Sep 17 00:00:00 2001 From: eldy Date: Thu, 6 Oct 2011 00:49:58 +0200 Subject: [PATCH 37/41] Fix: Removed warning when FirePHP is on --- htdocs/admin/syslog.php | 33 +++++++++++++++++++++++++++++++-- htdocs/lib/functions.lib.php | 18 ++++++++++++++---- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 149f537dabb..92559b28a0a 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -35,6 +35,7 @@ $error=0; $mesg=''; $action = GETPOST("action"); $syslog_file_on=(defined('SYSLOG_FILE_ON') && constant('SYSLOG_FILE_ON'))?1:0; $syslog_syslog_on=(defined('SYSLOG_SYSLOG_ON') && constant('SYSLOG_SYSLOG_ON'))?1:0; +$syslog_firephp_on=(defined('SYSLOG_FIREPHP_ON') && constant('SYSLOG_FIREPHP_ON'))?1:0; /* @@ -48,6 +49,7 @@ if ($action == 'set') $res = dolibarr_del_const($db,"SYSLOG_FILE_ON",0); $res = dolibarr_del_const($db,"SYSLOG_SYSLOG_ON",0); + $res = dolibarr_del_const($db,"SYSLOG_FIREPHP_ON",0); if (! $error && GETPOST("filename")) { @@ -93,6 +95,12 @@ if ($action == 'set') } } + if (! $error && isset($_POST['SYSLOG_FIREPHP_ON'])) // If firephp no available, post is not present + { + $syslog_firephp_on=GETPOST('SYSLOG_FIREPHP_ON'); + if (! $error) $res = dolibarr_set_const($db,"SYSLOG_FIREPHP_ON",$syslog_firephp_on,'chaine',0,'',0); + } + if (! $error) { $db->commit(); @@ -165,19 +173,40 @@ print "
'.$langs->trans("SyslogSimpleFile").'
'.$langs->trans("SyslogSimpleFile").''.$langs->trans("SyslogFilename").': '; print '".$html->textwithpicto('',$langs->trans("YouCanUseDOL_DATA_ROOT")); print '
'.$langs->trans("SyslogSyslog").'
'.$langs->trans("SyslogSyslog").''.$langs->trans("SyslogFacility").': '; print '".$html->textwithpicto('','Only LOG_USER supported on Windows'); print '
'.$langs->trans("FirePHP").''; + print '".$html->textwithpicto('','FirePHP must be installed onto PHP and FirePHP plugin for Firefox must also be installed'); + print '
\n"; print "\n"; diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 9438d318c57..3553d36b442 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -487,10 +487,20 @@ function dol_syslog($message, $level=LOG_INFO) // Check if log is to syslog (SYSLOG_FIREPHP_ON defined) if (defined("SYSLOG_FIREPHP_ON") && constant("SYSLOG_FIREPHP_ON")) { - require_once(SYSLOG_FIREPHP_PATH.'FirePHPCore/FirePHP.class.php'); - ob_start(); - $firephp = FirePHP::getInstance(true); - $firephp->log($message); + try + { + // Warning FirePHPCore must be into PHP include path. It is not possible to use into require_once() a constant from + // database or config file because we must be able to log data before database or config file read. + set_include_path('/usr/share/php/'); + require_once('FirePHPCore/FirePHP.class.php'); + restore_include_path(); + ob_start(); + $firephp = FirePHP::getInstance(true); + $firephp->log($message); + } + catch(Exception $e) + { + } } } } From cfcccbdfa096c2b6d8914deef98b77a962c8f84f Mon Sep 17 00:00:00 2001 From: eldy Date: Thu, 6 Oct 2011 00:55:55 +0200 Subject: [PATCH 38/41] Documentation --- ChangeLog | 5 +++-- htdocs/admin/syslog.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a41c49c6a43..916aa541bf9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,12 +24,13 @@ For users: For developers: - New: Add webservice to get or create a prodcut or service. - New: Log module outputs can be setup with "or" rule (not only "xor"). +- New: Add FirePHP output for logging module. +- Qual: Data structure for supplier prices is simpler. - Qual: Removed no more used external libraries. - Qual: Cleaned a lot of dead code. -- Qual: Parent templates classes were moved as abstract classes. - Qual: Add more "hooks". - Qual: Add "canvas" feature to overwrite page of thirdparty, contact, product with yours. -- More OOP (usage of "abstract", "static", ...), uniformize constructors. +- Qual: More OOP (usage of "abstract", "static", ...), uniformize constructors. ***** ChangeLog for 3.1 compared to 3.0 ***** diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 92559b28a0a..04950a51eb0 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -193,7 +193,7 @@ try restore_include_path(); $var=!$var; print ' '.$langs->trans("FirePHP").''; print ''; From 4feed15c57cd62b60f6eea4915d6751d2a0c7751 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 6 Oct 2011 11:04:56 +0200 Subject: [PATCH 39/41] Trad: Add translation for dictionaries admin page --- htdocs/admin/dict.php | 66 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 14926154b28..88cce17f223 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2011 Philippe Grand * * This program is free software; you can redistribute it and/or modify @@ -41,8 +41,8 @@ $acts[0] = "activate"; $acts[1] = "disable"; //$actl[0] = $langs->trans("Activate"); //$actl[1] = $langs->trans("Disable"); -$actl[0] = img_picto($langs->trans("Disabled"),'off'); -$actl[1] = img_picto($langs->trans("Activated"),'on'); +$actl[0] = img_picto($langs->trans("Disabled"),'switch_off'); +$actl[1] = img_picto($langs->trans("Activated"),'switch_on'); $listoffset=GETPOST('listoffset'); $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; @@ -122,7 +122,7 @@ $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.d $tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent"; //$tabsql[9] = "SELECT code, code_iso, label as libelle, symbole, active FROM ".MAIN_DB_PREFIX."c_currencies"; $tabsql[9] = "SELECT code, code_iso, label as libelle, active FROM ".MAIN_DB_PREFIX."c_currencies"; -$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid"; +$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid"; $tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; $tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c'; $tabsql[13]= "SELECT id as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c"; @@ -780,12 +780,68 @@ if ($_GET["id"]) $valuetoshow=price($valuetoshow); } else if ($fieldlist[$field]=='libelle_facture') { + $langs->load("bills"); + $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; $valuetoshow=nl2br($valuetoshow); } - else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]=='llx_c_pays') { + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_pays') { $key=$langs->trans("Country".strtoupper($obj->code)); $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; } + else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_availability') { + $langs->load("propal"); + $key=$langs->trans("AvailabilityType".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_actioncomm') { + $key=$langs->trans("Action".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_currencies') { + $key=$langs->trans("Currency".strtoupper($obj->code_iso)); + $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_typent') { + $key=$langs->trans(strtoupper($obj->code)); + $valuetoshow=($key != strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_prospectlevel') { + $key=$langs->trans(strtoupper($obj->code)); + $valuetoshow=($key != strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_civilite') { + $key=$langs->trans("Civility".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_type_contact') { + $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_payment_term') { + $langs->load("bills"); + $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_paiement') { + $langs->load("bills"); + $key=$langs->trans("PaymentType".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_reason') { + $key=$langs->trans("DemandReasonType".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_method') { + $langs->load("orders"); + $key=$langs->trans($obj->code); + $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field]; + } + else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_shipment_mode') { + $langs->load("sendings"); + $key=$langs->trans("SendingMethod".strtoupper($obj->code)); + $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code))?$key:$obj->$fieldlist[$field]; + } else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $showfield=0; } From af09be16741a1b0a510ad2bc696dcf9e2168de3d Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 6 Oct 2011 11:54:36 +0200 Subject: [PATCH 40/41] Fix: Missing translation --- htdocs/product/fournisseurs.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index a3b9ccfc9d8..2f7c4749d57 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -292,6 +292,7 @@ if ($id || $ref) // Availability if(!empty($conf->global->FOURN_PRODUCT_AVAILABILITY)) { + $langs->load("propal"); print ''.$langs->trans("Availability").''; $html->select_availability($product->fk_availability,"oselDispo",1); print ''."\n"; From a74bdae666b88e872f350ec527383d06e8c14976 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 7 Oct 2011 00:53:27 +0800 Subject: [PATCH 41/41] Fix: add parameters for external modules --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 4d842d78c6d..ed47ad963f6 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -439,7 +439,7 @@ class FormFile $out.= ''; // Execute hooks - $parameters=array('socid'=>$GLOBALS['socid'],'id'=>$GLOBALS['id']); + $parameters=array('socid'=>$GLOBALS['socid'],'id'=>$GLOBALS['id'],'modulepart'=>$modulepart); if (is_object($hookmanager)) $out.= $hookmanager->executeHooks('formBuilddocOptions',$parameters); }