From 9c7647a7aeb8778faa5361dbd97cc765476b03c8 Mon Sep 17 00:00:00 2001 From: astebert Date: Tue, 12 Aug 2014 11:45:11 +0200 Subject: [PATCH 001/145] Update bills.lang Ligne 252 : Changement grammatical - de "Paiements issue de l'acompte" - en "Paiement issu de l'acompte" --- htdocs/langs/fr_FR/bills.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index debbe4f4d33..9e9980f9091 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -249,7 +249,7 @@ AddCreditNote=Créer facture avoir Deposit=Acompte Deposits=Acomptes DiscountFromCreditNote=Remise issue de l'avoir %s -DiscountFromDeposit=Paiements issue de l'acompte %s +DiscountFromDeposit=Paiement issu de l'acompte %s AbsoluteDiscountUse=Ce type de crédit ne peut s'utiliser que sur une facture non validée CreditNoteDepositUse=La facture doit être validée pour pouvoir utiliser ce type de crédit NewGlobalDiscount=Nouvelle ligne de déduction From 287e2ca032034586a97257a4c6b192c11bfd7a95 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 15 Sep 2014 09:58:44 +0200 Subject: [PATCH 002/145] Add ref_ext into fetch product (else fetch and update set this column to null) --- htdocs/product/class/product.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c3b337c4a16..fa241367462 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1351,6 +1351,7 @@ class Product extends CommonObject $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.= " datec, tms, import_key, entity, desiredstock, tobatch"; + $sql.= " ,ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; if ($id) $sql.= " WHERE rowid = ".$this->db->escape($id); else @@ -1424,6 +1425,8 @@ class Product extends CommonObject $this->date_modification = $obj->tms; $this->import_key = $obj->import_key; $this->entity = $obj->entity; + + $this->ref_ext = $obj->ref_ext; $this->db->free($resql); From 248ef4fd46f0ae2250230329272581177d96190e Mon Sep 17 00:00:00 2001 From: Eden Date: Fri, 19 Sep 2014 20:36:02 +0200 Subject: [PATCH 003/145] Fix: gidNumber ldap attribute was not defined i using posixGroup objectClass --- htdocs/admin/ldap_groups.php | 4 ++++ htdocs/user/group/ldap.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index e043bff88aa..a0bb5c4b605 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -219,6 +219,10 @@ if (function_exists("ldap_connect")) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info); + // Get a gid number for objectclass PosixGroup + if(in_array('posixGroup',$info['objectclass'])) + $info['gidNumber'] = $ldap->getNextGroupGid(); + $result1=$ldap->delete($dn); // To be sure to delete existing records $result2=$ldap->add($dn,$info,$user); // Now the test $result3=$ldap->delete($dn); // Clean what we did diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index cde5e764af5..978b1929b98 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -64,6 +64,10 @@ if ($action == 'dolibarr2ldap') $result=$ldap->connect_bind(); $info=$fgroup->_load_ldap_info(); + // Get a gid number for objectclass PosixGroup + if(in_array('posixGroup',$info['objectclass'])) + $info['gidNumber'] = $ldap->getNextGroupGid(); + $dn=$fgroup->_load_ldap_dn($info); $olddn=$dn; // We can say that old dn = dn as we force synchro From 860253759b50bf864d253bb767003c5c17f5fd97 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 23 Sep 2014 11:59:57 +0200 Subject: [PATCH 004/145] Add hook for addMorButton into supplier card --- htdocs/fourn/fiche.php | 65 +++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index 127dcfdcc8c..2719f9e0a9b 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -48,6 +48,12 @@ $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe'); $object = new Fournisseur($db); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('suppliercard')); + +$parameters = array('id' => $id); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + /* * Action */ @@ -435,34 +441,41 @@ if ($object->fetch($id)) * Barre d'actions */ + print '
'; - - if ($user->rights->fournisseur->commande->creer) - { - $langs->load("orders"); - print ''.$langs->trans("AddOrder").''; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { + + if ($user->rights->fournisseur->commande->creer) + { + $langs->load("orders"); + print ''.$langs->trans("AddOrder").''; + } + + if ($user->rights->fournisseur->facture->creer) + { + $langs->load("bills"); + print ''.$langs->trans("AddBill").''; + } + + // Add action + if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + { + if ($user->rights->agenda->myactions->create) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } + } + + print '
'; } - - if ($user->rights->fournisseur->facture->creer) - { - $langs->load("bills"); - print ''.$langs->trans("AddBill").''; - } - - // Add action - if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - if ($user->rights->agenda->myactions->create) - { - print ''.$langs->trans("AddAction").''; - } - else - { - print ''.$langs->trans("AddAction").''; - } - } - - print ''; print '
'; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) From d1868b643ea842200237bb7f9a84e200fe4344ed Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 24 Sep 2014 11:47:34 +0200 Subject: [PATCH 005/145] FIX: clone line extrafields value on quote, order and invoice --- htdocs/comm/propal/class/propal.class.php | 11 +++++++++-- htdocs/commande/class/commande.class.php | 9 +++++++-- htdocs/compta/facture/class/facture.class.php | 9 +++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 1c2fe54cc71..2c507e3e59d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2010-2011 Philippe Grand - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -788,6 +788,9 @@ class Propal extends CommonObject $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, $this->lines[$i]->label + $this->lines[$i]->date_start, + $this->lines[$i]->date_end, + $this->lines[$i]->array_options ); if ($result < 0) @@ -922,6 +925,10 @@ class Propal extends CommonObject $this->db->begin(); + // get extrafields so they will be clone + foreach($this->lines as $line) + $line->fetch_optionals($line->rowid); + // Load source object $objFrom = dol_clone($this); @@ -1046,7 +1053,7 @@ class Propal extends CommonObject $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql.= " WHERE p.fk_statut = c.id"; $sql.= " AND p.entity = ".$conf->entity; - if ($ref) $sql.= " AND p.ref='".$this->db->escape($ref)."'"; + if ($ref) $sql.= " AND p.ref='".$ref."'"; else $sql.= " AND p.rowid=".$rowid; dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 795c2e26526..7a8fd63c8f1 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2011 Jean Heimburger - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -712,7 +712,8 @@ class Commande extends CommonOrder $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, - $this->lines[$i]->label + $this->lines[$i]->label, + $this->lines[$i]->array_options ); if ($result < 0) { @@ -850,6 +851,10 @@ class Commande extends CommonOrder $this->db->begin(); + // get extrafields so they will be clone + foreach($this->lines as $line) + $line->fetch_optionals($line->rowid); + // Load source object $objFrom = dol_clone($this); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e9bf109b9e7..93e245746a0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012 Marcos García * Copyright (C) 2013 Cedric Gross * Copyright (C) 2013 Florian Henry @@ -367,7 +367,8 @@ class Facture extends CommonInvoice $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, - $this->lines[$i]->label + $this->lines[$i]->label, + $this->lines[$i]->array_options ); if ($result < 0) { @@ -569,6 +570,10 @@ class Facture extends CommonInvoice $this->db->begin(); + // get extrafields so they will be clone + foreach($this->lines as $line) + $line->fetch_optionals($line->rowid); + // Load source object $objFrom = dol_clone($this); From 2c52de3840c520965839d43a8307074255b23304 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 24 Sep 2014 12:12:10 +0200 Subject: [PATCH 006/145] fix missing "," --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2c507e3e59d..507a9dce633 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -787,7 +787,7 @@ class Propal extends CommonObject $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, - $this->lines[$i]->label + $this->lines[$i]->label, $this->lines[$i]->date_start, $this->lines[$i]->date_end, $this->lines[$i]->array_options From 7b9f154c295eb10c02e9d79bd526ff99ef6f04fc Mon Sep 17 00:00:00 2001 From: fmarcet Date: Thu, 25 Sep 2014 12:45:08 +0200 Subject: [PATCH 007/145] Fix: Withdrawal total amount is double --- ChangeLog | 1 + htdocs/compta/prelevement/class/bonprelevement.class.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 079219e6c7f..57e1876b760 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ For users: - Fix: Extrafield feature select from table should try to translate multiple column when not needed - Fix: cents for indian ruppes are calle paisa and paise. - Fix: Invoices payments may be older than invoices. +- Fix: Withdrawal total amount is double - Fix: [ bug #1593 ] Spanish Localtax IRPF not being calculated since 3.6.0 in supplier invoices when adding a line ***** ChangeLog for 3.6 compared to 3.5.* ***** diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 104277f4ed5..4bc91e4a5bc 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur + * Copyright (C) 2014 Ferran Marcet * * 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 @@ -1411,7 +1412,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$CrLf); fputs($this->file, ''.$CrLf); - $sql = "SELECT pl.amount"; + /*$sql = "SELECT pl.amount"; $sql.= " FROM"; $sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,"; $sql.= " ".MAIN_DB_PREFIX."facture as f,"; @@ -1437,7 +1438,7 @@ class BonPrelevement extends CommonObject else { $result = -2; - } + }*/ } From 96c5771718ec4ca070d948c5b4161eb361dd1484 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Sep 2014 16:18:32 +0200 Subject: [PATCH 008/145] Fix web service category --- ChangeLog | 1 + htdocs/webservices/server_category.php | 81 +++++++++++--------------- 2 files changed, 34 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 079219e6c7f..d422594ef83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,7 @@ For users: - Fix: cents for indian ruppes are calle paisa and paise. - Fix: Invoices payments may be older than invoices. - Fix: [ bug #1593 ] Spanish Localtax IRPF not being calculated since 3.6.0 in supplier invoices when adding a line +- Fix: Web service categorie WDSL declaration is correct ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/webservices/server_category.php b/htdocs/webservices/server_category.php index 1b85c677175..45a8fb76a78 100644 --- a/htdocs/webservices/server_category.php +++ b/htdocs/webservices/server_category.php @@ -106,56 +106,41 @@ $server->wsdl->addComplexType( 'tns:categorie' ); -/* - * Tableau des catégories - -$server->wsdl->addComplexType( - 'categories', - 'complexType', - 'array', - '', - 'SOAP-ENC:Array', - array(), - array( - array('id'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:categorie[]') - ), - 'tns:categories' -); + /* + * Image of product */ - -/* - * Les photos de la catégorie (un tableau indéxé qui contient les images avec leur vignette) + $server->wsdl->addComplexType( + 'PhotosArray', + 'complexType', + 'array', + 'sequence', + '', + array( + 'image' => array( + 'name' => 'image', + 'type' => 'tns:image', + 'minOccurs' => '0', + 'maxOccurs' => 'unbounded' + ) + ) + ); + + /* + * An image */ -$server->wsdl->addComplexType( - 'PhotosArray', - 'complexType', - 'array', - '', - 'SOAP-ENC:Array', - array(), - array( - array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:image[]') - ), - '' -); - -/* - * Une photo ( nom image / nom_vignette ) - */ -$server->wsdl->addComplexType( - 'image', - 'complexType', - 'array', - '', - 'SOAP-ENC:Array', - array(), - array( - 'photo' => array('name'=>'photo','type'=>'xsd:string'), - 'photo_vignette' => array('name'=>'photo_vignette','type'=>'xsd:string'), - 'imgWidth' => array('name'=>'imgWidth','type'=>'xsd:string'), - 'imgHeight' => array('name'=>'imgHeight','type'=>'xsd:string') - ) -); + $server->wsdl->addComplexType( + 'image', + 'complexType', + 'struct', + 'all', + '', + array( + 'photo' => array('name'=>'photo','type'=>'xsd:string'), + 'photo_vignette' => array('name'=>'photo_vignette','type'=>'xsd:string'), + 'imgWidth' => array('name'=>'imgWidth','type'=>'xsd:string'), + 'imgHeight' => array('name'=>'imgHeight','type'=>'xsd:string') + ) + ); /* * Retour From b8969edcc5e367f840523d9960eb416facbaaf61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Sep 2014 12:34:45 +0200 Subject: [PATCH 009/145] Prepare 3.6.1 --- build/debian/changelog | 7 +++++++ build/exe/doliwamp/doliwamp.iss | 4 ++-- build/rpm/dolibarr_fedora.spec | 3 +++ build/rpm/dolibarr_generic.spec | 3 +++ build/rpm/dolibarr_mandriva.spec | 3 +++ build/rpm/dolibarr_opensuse.spec | 3 +++ htdocs/filefunc.inc.php | 2 +- 7 files changed, 22 insertions(+), 3 deletions(-) diff --git a/build/debian/changelog b/build/debian/changelog index 06d0d2212d5..76e8ae3a2fc 100644 --- a/build/debian/changelog +++ b/build/debian/changelog @@ -1,3 +1,10 @@ +dolibarr (3.6.1-3) unstable; urgency=low + + [ Laurent Destailleur (eldy) ] + * New upstream release. + + -- Laurent Destailleur (eldy) Tue, 23 Sep 2014 12:00:00 +0100 + dolibarr (3.6.0-3) unstable; urgency=low [ Laurent Destailleur (eldy) ] diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index da727786896..1657ff1c7e7 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -17,9 +17,9 @@ ; ----- Change this ----- AppName=DoliWamp ; DoliWamp-x.x.x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x -AppVerName=DoliWamp-3.6.0 +AppVerName=DoliWamp-3.6.1 ; DoliWamp-x.x x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x -OutputBaseFilename=DoliWamp-3.6.0 +OutputBaseFilename=DoliWamp-3.6.1 ; ----- End of change ;OutputManifestFile=build\doliwampbuild.log ; Define full path from which all relative path are defined diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index d676e59255e..439a09b8266 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -333,6 +333,9 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog +* Wed Sep 24 2014 Laurent Destailleur 3.6.1-0.3 +- Upstream release + * Wed Jul 15 2014 Laurent Destailleur 3.6.0-0.3 - Upstream release diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index ef94435a62a..945e8f4812c 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -569,6 +569,9 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog +* Wed Sep 24 2014 Laurent Destailleur 3.6.1-0.3 +- Upstream release + * Wed Jul 15 2014 Laurent Destailleur 3.6.0-0.3 - Upstream release diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index dfa148570f0..17b46c3c143 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -338,6 +338,9 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog +* Wed Sep 24 2014 Laurent Destailleur 3.6.1-0.3 +- Upstream release + * Wed Jul 15 2014 Laurent Destailleur 3.6.0-0.3 - Upstream release diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index b3b304312f5..f6192c87c9b 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -349,6 +349,9 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog +* Wed Sep 24 2014 Laurent Destailleur 3.6.1-0.3 +- Upstream release + * Wed Jul 15 2014 Laurent Destailleur 3.6.0-0.3 - Upstream release diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index b927b0016e8..8066c2a1a22 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -29,7 +29,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.6.0'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.6.1'); if (! defined('EURO')) define('EURO',chr(128)); // Define syslog constants From 7dcaa6121863d5115adb03666c4653df91894d6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Sep 2014 13:23:38 +0200 Subject: [PATCH 010/145] Prepare 3.6.1 --- build/makepack-howto.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index 24e5f809185..40b0e5180bc 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -36,14 +36,13 @@ complete release of Dolibarr, step by step. - Update version number with x.y.z in build/exe/doliwamp/doliwamp.iss - Update version number with x.y.z in build/rpm/*.spec - Commit all changes. -- Add a Tag (x.y.z) - Build Dolibarr and DoliWamp packages with makepack-dolibarr.pl - Check content of built packages. - Move build files into www.dolibarr.org web site (/home/dolibarr/wwwroot/files/stable). - Run makepack-dolibarr.pl again with option to publish files on - sourceforge. + sourceforge. This will also add official tag. - Edit symbolic links in directory "/home/dolibarr/wwwroot/files/stable/xxx" on server to point to new files (used by some web sites). From 05f83dddf09464053e17a5072f5febc8345eb2dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Sep 2014 15:23:40 +0200 Subject: [PATCH 011/145] Fix: packager --- build/makepack-dolibarr.pl | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 77f19c1500a..b6fa0dd7122 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -460,8 +460,8 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/license.txt`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PDF`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PCLZip`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.33`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-20100919`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-*`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/LICENSE.TXT`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/savant`; @@ -610,9 +610,6 @@ if ($nboftargetok) { print "Version is $MAJOR.$MINOR.$REL1-$RPMSUBVERSION\n"; - #print "Create directory $RPMDIR\n"; - #$ret=`mkdir -p "$RPMDIR"`; - print "Remove target ".$FILENAMERPM."...\n"; unlink("$NEWDESTI/".$FILENAMERPM); print "Remove target ".$FILENAMETGZ2."-".$RPMSUBVERSION.".src.rpm...\n"; @@ -620,13 +617,13 @@ if ($nboftargetok) { print "Create directory $BUILDROOT/$FILENAMETGZ2\n"; $ret=`rm -fr $BUILDROOT/$FILENAMETGZ2`; + print "Copy $BUILDROOT/$PROJECT to $BUILDROOT/$FILENAMETGZ2\n"; $cmd="cp -pr '$BUILDROOT/$PROJECT' '$BUILDROOT/$FILENAMETGZ2'"; $ret=`$cmd`; - # Set owners - #print "Set owners on files/dir\n"; - #$ret=`chown -R root.root $BUILDROOT/$FILENAMETGZ2`; + # Removed files we don't need + $ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/htdocs/includes/ckeditor/_source`; print "Set permissions on files/dir\n"; $ret=`chmod -R 755 $BUILDROOT/$FILENAMETGZ2`; @@ -747,10 +744,18 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/rpm`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/zip`; # Removed duplicate license files + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/plugins/scayt/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/plugins/wsc/LICENSE.md`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/LICENSE.md`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/plugins/scayt/LICENSE.md`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/plugins/wsc/LICENSE.md`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/flot/LICENSE.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.34/LICENSE`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tcpdf/fonts/freefont-20120503/COPYING`; + # Removed files we don't need + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source`; + # Rename upstream changelog to match debian rules $ret=`mv $BUILDROOT/$PROJECT.tmp/ChangeLog $BUILDROOT/$PROJECT.tmp/changelog`; From e8b7c9c6bdad044e675e05484d29d1f24277f348 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Sep 2014 16:00:11 +0200 Subject: [PATCH 012/145] Fix: doxygen --- .../actions_adherentcard_common.class.php | 4 ++-- .../actions_adherentcard_default.class.php | 2 +- htdocs/comm/action/index.php | 2 +- .../class/bonprelevement.class.php | 2 +- .../actions_contactcard_common.class.php | 4 ++-- .../actions_contactcard_default.class.php | 2 +- htdocs/core/class/canvas.class.php | 4 ++-- htdocs/core/class/extrafields.class.php | 2 +- htdocs/core/class/hookmanager.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 8 +++---- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/ldap.class.php | 16 +++++++------- htdocs/core/class/link.class.php | 2 +- htdocs/core/class/menubase.class.php | 6 ++--- htdocs/core/class/rssparser.class.php | 8 +++---- htdocs/core/db/DoliDB.class.php | 4 ++-- htdocs/core/lib/admin.lib.php | 22 +++++++++---------- htdocs/core/lib/files.lib.php | 4 ++-- htdocs/core/lib/functions.lib.php | 8 +++---- htdocs/core/lib/functions2.lib.php | 4 ++-- htdocs/core/lib/pdf.lib.php | 16 +++++++------- htdocs/core/lib/project.lib.php | 22 +++++++++---------- htdocs/core/lib/treeview.lib.php | 2 +- htdocs/core/lib/ws.lib.php | 6 ++--- htdocs/core/menus/standard/auguria.lib.php | 12 +++++----- htdocs/core/menus/standard/eldy.lib.php | 12 +++++----- htdocs/core/modules/action/rapport.pdf.php | 4 ++-- .../barcode/mod_barcode_product_standard.php | 8 +++---- .../modules/cheque/pdf/pdf_blochet.class.php | 6 ++--- .../commande/doc/pdf_einstein.modules.php | 12 +++++----- .../commande/doc/pdf_proforma.modules.php | 12 +++++----- .../contract/doc/pdf_strato.modules.php | 6 ++--- .../expedition/doc/pdf_merou.modules.php | 8 +++---- .../expedition/doc/pdf_rouget.modules.php | 8 +++---- .../modules/facture/doc/pdf_crabe.modules.php | 12 +++++----- .../fichinter/doc/pdf_soleil.modules.php | 6 ++--- .../livraison/pdf/pdf_typhon.modules.php | 8 +++---- .../modules/member/doc/pdf_standard.class.php | 10 ++++----- htdocs/core/modules/modSalaries.class.php | 2 +- .../doc/pdf_standardlabel.class.php | 10 ++++----- .../product/mod_codeproduct_elephant.php | 2 +- .../product/mod_codeproduct_leopard.php | 2 +- .../project/pdf/pdf_baleine.modules.php | 6 ++--- .../modules/propale/doc/pdf_azur.modules.php | 12 +++++----- .../modules/rapport/pdf_paiement.class.php | 10 ++++----- .../societe/mod_codeclient_elephant.php | 2 +- .../societe/mod_codeclient_leopard.php | 2 +- .../modules/societe/mod_codeclient_monkey.php | 4 ++-- .../pdf/pdf_canelle.modules.php | 10 ++++----- .../pdf/pdf_muscadet.modules.php | 12 +++++----- htdocs/imports/import.php | 4 ++-- htdocs/main.inc.php | 2 +- .../product/actions_card_product.class.php | 2 +- .../service/actions_card_service.class.php | 2 +- .../resource/class/actions_resource.class.php | 4 ++-- .../canvas/actions_card_common.class.php | 4 ++-- .../company/actions_card_company.class.php | 4 ++-- .../actions_card_individual.class.php | 4 ++-- htdocs/societe/class/societe.class.php | 6 ++--- htdocs/user/class/user.class.php | 4 ++-- test/phpunit/FactureRecTest.php | 14 ++++++------ test/phpunit/FactureTest.php | 2 +- test/phpunit/UserTest.php | 2 +- 63 files changed, 204 insertions(+), 204 deletions(-) diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index fc593e826f2..4a8b8d584ab 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -94,7 +94,7 @@ abstract class ActionsAdherentCardCommon /** * Load data control * - * @param string &$action Type of action + * @param string $action Type of action * @param int $id Id of object * @return void */ @@ -228,7 +228,7 @@ abstract class ActionsAdherentCardCommon /** * Set content of ->tpl array, to use into template * - * @param string &$action Type of action + * @param string $action Type of action * @param int $id Id * @return string HTML output */ diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index b88e4b2134f..5c40cb22954 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -76,7 +76,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon /** * Assign custom values for canvas * - * @param string &$action Type of action + * @param string $action Type of action * @param int $id Id * @return void */ diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 92b87d94ad1..41435afc84d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -966,7 +966,7 @@ llxFooter(); * @param int $year Year * @param int $monthshown Current month shown in calendar view * @param string $style Style to use for this day - * @param array &$eventarray Array of events + * @param array $eventarray Array of events * @param int $maxprint Nb of actions to show each day on month view (0 means no limit) * @param int $maxnbofchar Nb of characters to show for event line * @param string $newparam Parameters on current URL diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 104277f4ed5..70431e0d39b 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -164,7 +164,7 @@ class BonPrelevement extends CommonObject /** * Add line to withdrawal * - * @param int &$line_id id line to add + * @param int $line_id id line to add * @param int $client_id id invoice customer * @param string $client_nom name of cliente * @param int $amount amount of invoice diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index a2612e51e47..50b45918f9c 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -94,7 +94,7 @@ abstract class ActionsContactCardCommon /** * Load data control * - * @param string &$action Type of action + * @param string $action Type of action * @param int $id Id of object * @return void */ @@ -228,7 +228,7 @@ abstract class ActionsContactCardCommon /** * Set content of ->tpl array, to use into template * - * @param string &$action Type of action + * @param string $action Type of action * @param int $id Id * @return string HTML output */ diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index b39114cb3f5..3bfcf347c3f 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -75,7 +75,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon /** * Assign custom values for canvas * - * @param string &$action Type of action + * @param string $action Type of action * @param int $id Id * @return void */ diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index f51056b2551..959decc581c 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -125,7 +125,7 @@ class Canvas /** * Shared method for canvas to assign values for templates * - * @param string &$action Action string + * @param string $action Action string * @param int $id Object id (if ref not provided) * @param string $ref Object ref (if id not provided) * @return void @@ -181,7 +181,7 @@ class Canvas /** * Shared method for canvas to execute actions * - * @param string &$action Action string + * @param string $action Action string * @param int $id Object id * @return mixed Return return code of doActions of canvas * @deprecated This function is called if you add a doActions class inside your canvas. Try to not diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 13757ef947a..7b1f9d59889 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1041,7 +1041,7 @@ class ExtraFields * Fill array_options property of object by extrafields value (using for data sent by forms) * * @param array $extralabels $array of extrafields - * @param object &$object Object + * @param object $object Object * @param string $onlykey Only following key is filled * @return int 1 if array_options set / 0 if no value */ diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 3afcd941ee9..9d8ce90e812 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -114,8 +114,8 @@ class HookManager * * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) * @param array $parameters Array of parameters - * @param Object &$object Object to use hooks on - * @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) + * @param Object $object Object to use hooks on + * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) * @return mixed For doActions,formObjectOptions,pdf_xxx: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO. * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Deprecated. Must always return an int and things to print into ->resprints. * Can also return some values into an array ->results. diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fdd951293a6..ee28ec6a495 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1492,9 +1492,9 @@ class Form /** * constructProductListOption * - * @param resultset &$objp Resultset of fetch - * @param string &$opt Option - * @param string &$optJson Option + * @param resultset $objp Resultset of fetch + * @param string $opt Option + * @param string $optJson Option * @param int $price_level Price level * @param string $selected Preselected value * @return void @@ -4080,7 +4080,7 @@ class Form /** * Return HTML code to output a barcode * - * @param Object &$object Object containing data to retrieve file name + * @param Object $object Object containing data to retrieve file name * @param int $width Width of photo * @return string HTML code to output barcode */ diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index fe1cd8ddb6b..b5bd99495c9 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -462,7 +462,7 @@ class FormOther /** * Write lines of a project (all lines of a project if parent = 0) * - * @param int &$inc Cursor counter + * @param int $inc Cursor counter * @param int $parent Id of parent task we want to see * @param array $lines Array of task lines * @param int $level Level diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 30eeca5a486..88abc140104 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -370,7 +370,7 @@ class Ldap * Ldap object connect and bind must have been done * * @param string $dn DN entry key - * @param string[] $info Attributes array + * @param array $info Attributes array * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ @@ -423,7 +423,7 @@ class Ldap * Ldap object connect and bind must have been done * * @param string $dn DN entry key - * @param string[] $info Attributes array + * @param array $info Attributes array * @param string $user Objet user that modify * @return int <0 if KO, >0 if OK */ @@ -475,7 +475,7 @@ class Ldap * Ldap object connect and bind must have been done * * @param string $dn DN entry key - * @param string[] $info Attributes array + * @param array $info Attributes array * @param User $user Objet user that update * @param string $olddn Old DN entry key (before update) * @return int <0 if KO, >0 if OK @@ -563,7 +563,7 @@ class Ldap * Build a LDAP message * * @param string $dn DN entry key - * @param string[] $info Attributes array + * @param array $info Attributes array * @return string Content of file */ function dump_content($dn, $info) @@ -605,7 +605,7 @@ class Ldap * Dump a LDAP message to ldapinput.in file * * @param string $dn DN entry key - * @param string[] $info Attributes array + * @param array $info Attributes array * @return int <0 if KO, >0 if OK */ function dump($dn, $info) @@ -642,7 +642,7 @@ class Ldap * Ldap object connect and bind must have been done * * @param string $dn DN entry key - * @param string[] $info Attributes array + * @param array $info Attributes array * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ @@ -694,7 +694,7 @@ class Ldap * Ldap object connect and bind must have been done * * @param string $dn DN entry key - * @param string[] $info Attributes array + * @param array $info Attributes array * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ @@ -746,7 +746,7 @@ class Ldap * Ldap object connect and bind must have been done * * @param string $dn DN entry key - * @param string[] $info Attributes array + * @param array $info Attributes array * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 08d520d519e..02924d86668 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -234,7 +234,7 @@ class Link extends CommonObject /** * Loads all links from database * - * @param array &$links array of Link objects to fill + * @param array $links array of Link objects to fill * @param string $objecttype type of the associated object in dolibarr * @param int $objectid id of the associated object in dolibarr * @param string $sortfield field used to sort diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 966b9ac7f77..c04697acd39 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -380,7 +380,7 @@ class Menubase * @param string $myleftmenu Value for leftmenu to filter menu to load (always '') * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @param string $menu_handler Filter on name of menu_handler used (auguria, eldy...) - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @return array Return array with menu entries for top menu */ function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) @@ -408,7 +408,7 @@ class Menubase * @param string $myleftmenu Value for leftmenu to filter menu to load (always '') * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @param string $menu_handler Filter on name of menu_handler used (auguria, eldy...) - * @param array &$tabMenu Array with menu entries already loaded + * @param array $tabMenu Array with menu entries already loaded * @return Menu Menu array for particular mainmenu value or full tabArray */ function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) @@ -493,7 +493,7 @@ class Menubase * @param string $myleftmenu Value for left that defined leftmenu * @param int $type_user Looks for menu entry for 0=Internal users, 1=External users * @param string $menu_handler Name of menu_handler used ('auguria', 'eldy'...) - * @param array &$tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled) + * @param array $tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled) * @return int >0 if OK, <0 if KO */ function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 80ca1b155b7..d9a7d8348d6 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -258,7 +258,7 @@ class RssParser if (!is_resource($xmlparser)) { $this->error="ErrorFailedToCreateParser"; return -1; } - + xml_set_object($xmlparser, $this); xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element'); xml_set_character_data_handler($xmlparser, 'feed_cdata'); @@ -268,7 +268,7 @@ class RssParser //var_dump($rss->_format);exit; } } - + // If $rss loaded if ($rss) { @@ -452,7 +452,7 @@ class RssParser * * @param string $p Start * @param string $element Tag - * @param array &$attrs Attributes of tags + * @param array $attrs Attributes of tags * @return void */ function feed_start_element($p, $element, &$attrs) @@ -644,7 +644,7 @@ class RssParser /** * To concat 2 string with no warning if an operand is not defined * - * @param string &$str1 Str1 + * @param string $str1 Str1 * @param string $str2 Str2 * @return string String cancatenated */ diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index aa0792c5970..65b136a7a9c 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -17,8 +17,8 @@ */ /** - * \file htdocs/core/db/dolidb.class.php - * \brief Class file to manage Dolibarr database access + * \file htdocs/core/db/DoliDB.class.php + * \brief Class file to manage Dolibarr database access */ require_once DOL_DOCUMENT_ROOT .'/core/db/Database.interface.php'; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index c389f442830..155415f59c3 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -853,17 +853,17 @@ function unActivateModule($value, $requiredby=1) /** * Add external modules to list of dictionaries * - * @param array &$taborder Taborder - * @param array &$tabname Tabname - * @param array &$tablib Tablib - * @param array &$tabsql Tabsql - * @param array &$tabsqlsort Tabsqlsort - * @param array &$tabfield Tabfield - * @param array &$tabfieldvalue Tabfieldvalue - * @param array &$tabfieldinsert Tabfieldinsert - * @param array &$tabrowid Tabrowid - * @param array &$tabcond Tabcond - * @param array &$tabhelp Tabhelp + * @param array $taborder Taborder + * @param array $tabname Tabname + * @param array $tablib Tablib + * @param array $tabsql Tabsql + * @param array $tabsqlsort Tabsqlsort + * @param array $tabfield Tabfield + * @param array $tabfieldvalue Tabfieldvalue + * @param array $tabfieldinsert Tabfieldinsert + * @param array $tabrowid Tabrowid + * @param array $tabcond Tabcond + * @param array $tabhelp Tabhelp * @return int 1 */ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond,&$tabhelp) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index c90e58f556c..bcc6c165472 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -43,7 +43,7 @@ function dol_basename($pathfile) * @param string $types Can be "directories", "files", or "all" * @param int $recursive Determines whether subdirectories are searched * @param string $filter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function - * @param string[] $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview\.png)$','^\.')) + * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview\.png)$','^\.')) * @param string $sortcriteria Sort criteria ("","fullname","name","date","size") * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only @@ -1289,7 +1289,7 @@ function dol_uncompress($inputfile,$outputdir) * * @param string $dir Directory to scan * @param string $regexfilter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function - * @param string[] $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview\.png)$','^\.')). This regex value must be escaped for '/', since this char is used for preg_match function + * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview\.png)$','^\.')). This regex value must be escaped for '/', since this char is used for preg_match function * @param int $nohook Disable all hooks * @return string Full path to most recent file */ diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1450e2f100f..e238b1e5834 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3770,7 +3770,7 @@ function make_substitutions($chaine,$substitutionarray) /** * Complete the $substitutionarray with more entries * - * @param array &$substitutionarray Array substitution old value => new value value + * @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 * @param Mixed $parameters Add more parameters (useful to pass product lines) @@ -4109,7 +4109,7 @@ function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0) * or descending output and uses optionally natural case insensitive sorting (which * can be optionally case sensitive as well). * - * @param array &$array Array to sort (array of array('key','otherkey1','otherkey2'...)) + * @param array $array Array to sort (array of array('key','otherkey1','otherkey2'...)) * @param string $index Key in array to use for sorting criteria * @param int $order Sort order * @param int $natsort 1=use "natural" sort (natsort), 0=use "standard" sort (asort) @@ -4330,8 +4330,8 @@ function picto_from_langcode($codelang) * @param Conf $conf Object conf * @param Translate $langs Object langs * @param Object $object Object object - * @param array &$head Object head - * @param int &$h New position to fill + * @param array $head Object head + * @param int $h New position to fill * @param string $type Value for object where objectvalue can be * 'thirdparty' to add a tab in third party view * 'intervention' to add a tab in intervention view diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 1c3953906a2..4127686b459 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1107,7 +1107,7 @@ function numero_semaine($time) * Convertit une masse d'une unite vers une autre unite * * @param float $weight Masse a convertir - * @param int &$from_unit Unite originale en puissance de 10 + * @param int $from_unit Unite originale en puissance de 10 * @param int $to_unit Nouvelle unite en puissance de 10 * @return float Masse convertie */ @@ -1142,7 +1142,7 @@ function weight_convert($weight,&$from_unit,$to_unit) * * @param DoliDB $db Handler database * @param Conf $conf Object conf - * @param User &$user Object user + * @param User $user Object user * @param array $tab Tableau (cle=>valeur) des parametres a sauvegarder * @return int <0 if KO, >0 if OK * diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index bcb1008b622..17c1185e2e0 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -420,7 +420,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target /** * Show header of page for PDF generation * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Translate $outputlangs Object lang for output * @param int $page_height Height of page * @return void @@ -441,7 +441,7 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height) /** * Add a draft watermark on PDF files * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Translate $outputlangs Object lang * @param int $h Height of PDF * @param int $w Width of PDF @@ -481,7 +481,7 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) /** * Show bank informations for PDF generation * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Translate $outputlangs Object lang * @param int $curx X * @param int $cury Y @@ -643,7 +643,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default /** * Show footer of page for PDF generation * - * @param PDF &$pdf The PDF factory + * @param PDF $pdf The PDF factory * @param Translate $outputlangs Object lang for output * @param string $paramfreetext Constant name of free text * @param Societe $fromcompany Object company @@ -852,7 +852,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass /** * Show linked objects for PDF generation * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param object $object Object * @param Translate $outputlangs Object lang * @param int $posx X @@ -890,7 +890,7 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al /** * Output line description into PDF * - * @param PDF &$pdf PDF object + * @param PDF $pdf PDF object * @param Object $object Object * @param int $i Current line number * @param Translate $outputlangs Object lang for output @@ -1587,13 +1587,13 @@ function pdf_getLinkedObjects($object,$outputlangs) { $outputlangs->load('orders'); $outputlangs->load('sendings'); - + $num=count($objects); for ($i=0;$i<$num;$i++) { $objects[$i]->fetchObjectLinked(); $order = $objects[$i]->linkedObjects['commande'][0]; - + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($objects[$i]->ref); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index bfe782c40f9..a564a312ac2 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -206,13 +206,13 @@ function project_admin_prepare_head() /** * Show task lines with a particular parent * - * @param string &$inc Counter that count number of lines legitimate to show (for return) + * @param string $inc Counter that count number of lines legitimate to show (for return) * @param int $parent Id of parent task to start - * @param array &$lines Array of all tasks - * @param int &$level Level of task + * @param array $lines Array of all tasks + * @param int $level Level of task * @param string $var Color * @param int $showproject Show project columns - * @param int &$taskrole Array of roles of user for each tasks + * @param int $taskrole Array of roles of user for each tasks * @param int $projectsListId List of id of project allowed to user (string separated with comma) * @param int $addordertick Add a tick to move task * @return void @@ -443,12 +443,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t /** * Output a task line * - * @param string &$inc ? + * @param string $inc ? * @param string $parent ? * @param Object $lines ? - * @param int &$level ? - * @param string &$projectsrole ? - * @param string &$tasksrole ? + * @param int $level ? + * @param string $projectsrole ? + * @param string $tasksrole ? * @param string $mine Show only task lines I am assigned to * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @return $inc @@ -589,10 +589,10 @@ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksr /** * Search in task lines with a particular parent if there is a task for a particular user (in taskrole) * - * @param string &$inc Counter that count number of lines legitimate to show (for return) + * @param string $inc Counter that count number of lines legitimate to show (for return) * @param int $parent Id of parent task to start - * @param array &$lines Array of all tasks - * @param string &$taskrole Array of task filtered on a particular user + * @param array $lines Array of all tasks + * @param string $taskrole Array of task filtered on a particular user * @return int 1 if there is */ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 1bbf2e55e27..470da211f2e 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -28,7 +28,7 @@ /** * Show indent and picto of a tree line. Return array with information of line. * - * @param array &$fulltree Array of entries in correct order + * @param array $fulltree Array of entries in correct order * @param string $key Key of entry into fulltree to show picto * @param int $silent Do not output indent and picto, returns only value * @return array array(0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after, nbofdirinsub, nbofdocinsub) diff --git a/htdocs/core/lib/ws.lib.php b/htdocs/core/lib/ws.lib.php index 1e7f4b4e522..533a13e1fb6 100644 --- a/htdocs/core/lib/ws.lib.php +++ b/htdocs/core/lib/ws.lib.php @@ -27,9 +27,9 @@ * Check authentication array and set error, errorcode, errorlabel * * @param array $authentication Array with authentication informations ('login'=>,'password'=>,'entity'=>,'dolibarrkey'=>) - * @param int &$error Number of errors - * @param string &$errorcode Error string code - * @param string &$errorlabel Error string label + * @param int $error Number of errors + * @param string $errorcode Error string code + * @param string $errorlabel Error string label * @return User Return user object identified by login/pass/entity into authentication array */ function check_authentication($authentication,&$error,&$errorcode,&$errorlabel) diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 837403828ee..427a03d9929 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; * @param DoliDB $db Database handler * @param string $atarget Target * @param int $type_user 0=Menu for backoffice, 1=Menu for front office - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @param array &$menu Object Menu to return back list of menu entries + * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @param array $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @return int 0 */ @@ -203,8 +203,8 @@ function print_end_menu_array_auguria() * @param DoliDB $db Database handler * @param array $menu_array_before Table of menu entries to show before entries of menu handler * @param array $menu_array_after Table of menu entries to show after entries of menu handler - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @param Menu &$menu Object Menu to return back list of menu entries + * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @param Menu $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all) @@ -402,8 +402,8 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM * Function to test if an entry is enabled or not * * @param string $type_user 0=We need backoffice menu, 1=We need frontoffice menu - * @param array &$menuentry Array for menu entry - * @param array &$listofmodulesforexternal Array with list of modules allowed to external users + * @param array $menuentry Array for menu entry + * @param array $listofmodulesforexternal Array with list of modules allowed to external users * @return int 0=Hide, 1=Show, 2=Show gray */ function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index ed255b5785f..b42fc258c6d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; * @param DoliDB $db Database handler * @param string $atarget Target (Example: '' or '_top') * @param int $type_user 0=Menu for backoffice, 1=Menu for front office - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @param array &$menu Object Menu to return back list of menu entries + * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @param array $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @return int 0 */ @@ -428,8 +428,8 @@ function print_end_menu_array() * @param DoliDB $db Database handler * @param array $menu_array_before Table of menu entries to show before entries of menu handler (menu->liste filled with menu->add) * @param array $menu_array_after Table of menu entries to show after entries of menu handler (menu->liste filled with menu->add) - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @param Menu &$menu Object Menu to return back list of menu entries + * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @param Menu $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all) @@ -1364,8 +1364,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu * Function to test if an entry is enabled or not * * @param string $type_user 0=We need backoffice menu, 1=We need frontoffice menu - * @param array &$menuentry Array for menu entry - * @param array &$listofmodulesforexternal Array with list of modules allowed to external users + * @param array $menuentry Array for menu entry + * @param array $listofmodulesforexternal Array with list of modules allowed to external users * @return int 0=Hide, 1=Show, 2=Show gray */ function dol_eldy_showmenu($type_user, &$menuentry, &$listofmodulesforexternal) diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index b864205f2c9..cc3f2557db9 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -159,7 +159,7 @@ class CommActionRapport /** * Write content of pages * - * @param PDF &$pdf Object pdf + * @param PDF $pdf Object pdf * @param Translate $outputlangs Object langs * @return int 1 */ @@ -255,7 +255,7 @@ class CommActionRapport /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Translate $outputlangs Object lang for output * @param int $pagenb Page nb * @return void diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index e03bdc6d2e9..28fa03ee4f3 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/core/modules/product/mod_barcode_product_standard.php + * \file htdocs/core/modules/barcode/mod_barcode_product_standard.php * \ingroup barcode * \brief File of class to manage barcode numbering with standard rule */ @@ -162,7 +162,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * Check validity of code according to its rules * * @param DoliDB $db Database handler - * @param string &$code Code to check/correct + * @param string $code Code to check/correct * @param Product $product Object product * @param int $thirdparty_type 0 = customer/prospect , 1 = supplier * @param string $type type of barcode (EAN, ISBN, ...) @@ -177,7 +177,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode global $conf; //var_dump($code.' '.$product->ref.' '.$thirdparty_type);exit; - + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; $result=0; @@ -282,7 +282,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode { $newcodefortest=substr($newcodefortest,0,12); } - + $result=check_value($mask,$newcodefortest); return $result; diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php index 96214f08d66..04ba6a57174 100644 --- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php @@ -177,7 +177,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts /** * Generate Header * - * @param PDF &$pdf Pdf object + * @param PDF $pdf Pdf object * @param int $page Current page number * @param int $pages Total number of pages * @param Translate $outputlangs Object language for output @@ -283,7 +283,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts /** * Output array * - * @param PDF &$pdf PDF object + * @param PDF $pdf PDF object * @param int $pagenb Page nb * @param int $pages Pages * @param Translate $outputlangs Object lang @@ -341,7 +341,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 68266f2cef9..b3dd27a8a7a 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -533,7 +533,7 @@ class pdf_einstein extends ModelePDFCommandes /** * Show payments table * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object order * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output @@ -548,7 +548,7 @@ class pdf_einstein extends ModelePDFCommandes /** * Show miscellaneous information (payment mode, payment term, ...) * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object @@ -732,7 +732,7 @@ class pdf_einstein extends ModelePDFCommandes /** * Show total to pay * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart @@ -989,7 +989,7 @@ class pdf_einstein extends ModelePDFCommandes /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y (not used) @@ -1084,7 +1084,7 @@ class pdf_einstein extends ModelePDFCommandes /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -1263,7 +1263,7 @@ class pdf_einstein extends ModelePDFCommandes /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index eb599c2a214..49e3c374752 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -532,7 +532,7 @@ class pdf_proforma extends ModelePDFCommandes /** * Show payments table * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object order * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output @@ -547,7 +547,7 @@ class pdf_proforma extends ModelePDFCommandes /** * Show miscellaneous information (payment mode, payment term, ...) * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object @@ -689,7 +689,7 @@ class pdf_proforma extends ModelePDFCommandes /** * Show total to pay * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart @@ -946,7 +946,7 @@ class pdf_proforma extends ModelePDFCommandes /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y (not used) @@ -1041,7 +1041,7 @@ class pdf_proforma extends ModelePDFCommandes /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -1220,7 +1220,7 @@ class pdf_proforma extends ModelePDFCommandes /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 5fc0eb6dd2a..238f51e78cd 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -357,7 +357,7 @@ class pdf_strato extends ModelePDFContract /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y @@ -423,7 +423,7 @@ class pdf_strato extends ModelePDFContract /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -602,7 +602,7 @@ class pdf_strato extends ModelePDFContract /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 5385d7ad0e6..14bc79bf935 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -73,7 +73,7 @@ class pdf_merou extends ModelePdfExpedition /** * Function to build pdf onto disk * - * @param Object &$object Object expedition to generate (or id if old method) + * @param Object $object Object expedition to generate (or id if old method) * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -353,7 +353,7 @@ class pdf_merou extends ModelePdfExpedition /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y @@ -394,7 +394,7 @@ class pdf_merou extends ModelePdfExpedition /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text @@ -423,7 +423,7 @@ class pdf_merou extends ModelePdfExpedition /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 6d0e44817a7..37e3f8b911f 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -76,7 +76,7 @@ class pdf_rouget extends ModelePdfExpedition /** * Function to build pdf onto disk * - * @param Object &$object Object expedition to generate (or id if old method) + * @param Object $object Object expedition to generate (or id if old method) * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -354,7 +354,7 @@ class pdf_rouget extends ModelePdfExpedition /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y @@ -409,7 +409,7 @@ class pdf_rouget extends ModelePdfExpedition /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -649,7 +649,7 @@ class pdf_rouget extends ModelePdfExpedition /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 9186e51b954..6b66d9d2df3 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -535,7 +535,7 @@ class pdf_crabe extends ModelePDFFactures /** * Show payments table * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object invoice * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output @@ -673,7 +673,7 @@ class pdf_crabe extends ModelePDFFactures /** * Show miscellaneous information (payment mode, payment term, ...) * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object @@ -829,7 +829,7 @@ class pdf_crabe extends ModelePDFFactures /** * Show total to pay * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart @@ -1124,7 +1124,7 @@ class pdf_crabe extends ModelePDFFactures /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y (not used) @@ -1218,7 +1218,7 @@ class pdf_crabe extends ModelePDFFactures /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -1449,7 +1449,7 @@ class pdf_crabe extends ModelePDFFactures /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index f2055e8d643..c94cd154251 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -345,7 +345,7 @@ class pdf_soleil extends ModelePDFFicheinter /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y @@ -408,7 +408,7 @@ class pdf_soleil extends ModelePDFFicheinter /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -587,7 +587,7 @@ class pdf_soleil extends ModelePDFFicheinter /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index b13177f9127..3aae0e5a18e 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -540,7 +540,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder /** * Show miscellaneous information (payment mode, payment term, ...) * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object @@ -567,7 +567,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y (not used) @@ -626,7 +626,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -842,7 +842,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 043a2e89f5c..cef4155c607 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -99,7 +99,7 @@ class pdf_standard * Methode qui permet de modifier la taille des caracteres * Cela modiera aussi l'espace entre chaque ligne * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param int $pt point * @return void */ @@ -118,7 +118,7 @@ class pdf_standard * - %LOGO% is replace with company logo * - %PHOTO% is replace with photo provided as parameter * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param string $textleft Text left * @param string $header Header * @param string $footer Footer @@ -300,7 +300,7 @@ class pdf_standard /** * Print dot line * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param int $x1 X1 * @param int $y1 Y1 * @param int $x2 X2 @@ -341,7 +341,7 @@ class pdf_standard /** * Fonction realisant une croix aux 4 coins des cartes * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param int $x1 X1 * @param int $y1 Y1 * @param int $x2 X2 @@ -412,7 +412,7 @@ class pdf_standard /** * Set format * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param string $format Format * @return void */ diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index f8a99b99aab..5ecadcc9792 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -22,7 +22,7 @@ */ /** - * \defgroup tax Module salaries + * \defgroup salaries Module salaries * \brief Module to include salaries management * \file htdocs/core/modules/modSalaries.class.php * \ingroup salaries diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index b6e35f95f8e..8ae45bdc681 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -99,7 +99,7 @@ class pdf_standardlabel * Methode qui permet de modifier la taille des caracteres * Cela modiera aussi l'espace entre chaque ligne * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param int $pt point * @return void */ @@ -117,7 +117,7 @@ class pdf_standardlabel * - %LOGO% is replace with company logo * - %PHOTO% is replace with photo provided as parameter * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param string $textleft Text left * @param string $header Header * @param string $footer Footer @@ -292,7 +292,7 @@ class pdf_standardlabel /** * Print dot line * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param int $x1 X1 * @param int $y1 Y1 * @param int $x2 X2 @@ -333,7 +333,7 @@ class pdf_standardlabel /** * Fonction realisant une croix aux 4 coins des cartes * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param int $x1 X1 * @param int $y1 Y1 * @param int $x2 X2 @@ -404,7 +404,7 @@ class pdf_standardlabel /** * Set format * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param string $format Format * @return void */ diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 3ab5fdb9e09..37383474c2d 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -220,7 +220,7 @@ class mod_codeproduct_elephant extends ModeleProductCode * Check validity of code according to its rules * * @param DoliDB $db Database handler - * @param string &$code Code to check/correct + * @param string $code Code to check/correct * @param Product $product Object product * @param int $type 0 = customer/prospect , 1 = supplier * @return int 0 if OK diff --git a/htdocs/core/modules/product/mod_codeproduct_leopard.php b/htdocs/core/modules/product/mod_codeproduct_leopard.php index df71792ee86..a3df52f682f 100644 --- a/htdocs/core/modules/product/mod_codeproduct_leopard.php +++ b/htdocs/core/modules/product/mod_codeproduct_leopard.php @@ -91,7 +91,7 @@ class mod_codeproduct_leopard extends ModeleProductCode * Check validity of code according to its rules * * @param DoliDB $db Database handler - * @param string &$code Code to check/correct + * @param string $code Code to check/correct * @param Product $product Object product * @param int $type 0 = product , 1 = service * @return int 0 if OK diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php index c8cc0b65fbc..d8f2d744e78 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php @@ -315,7 +315,7 @@ class pdf_baleine extends ModelePDFProjects /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y @@ -348,7 +348,7 @@ class pdf_baleine extends ModelePDFProjects /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -434,7 +434,7 @@ class pdf_baleine extends ModelePDFProjects /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index fe952fb9903..29fea0d9c1a 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -589,7 +589,7 @@ class pdf_azur extends ModelePDFPropales /** * Show payments table * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object proposal * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output @@ -604,7 +604,7 @@ class pdf_azur extends ModelePDFPropales /** * Show miscellaneous information (payment mode, payment term, ...) * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object @@ -779,7 +779,7 @@ class pdf_azur extends ModelePDFPropales /** * Show total to pay * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart @@ -1050,7 +1050,7 @@ class pdf_azur extends ModelePDFPropales /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y (not used) @@ -1154,7 +1154,7 @@ class pdf_azur extends ModelePDFPropales /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -1354,7 +1354,7 @@ class pdf_azur extends ModelePDFPropales /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index d0defd260dd..3bfb6f6b60c 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -95,7 +95,7 @@ class pdf_paiement $socid=0; if ($user->societe_id) $socid=$user->societe_id; - + if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; @@ -141,7 +141,7 @@ class pdf_paiement $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."facture as f,"; $sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf,"; $sql.= " ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) + if (! $user->rights->societe->client->voir && ! $socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } @@ -149,7 +149,7 @@ class pdf_paiement $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND p.fk_paiement = c.id "; $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; - if (! $user->rights->societe->client->voir && ! $socid) + if (! $user->rights->societe->client->voir && ! $socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } @@ -237,7 +237,7 @@ class pdf_paiement /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param int $page Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -296,7 +296,7 @@ class pdf_paiement /** * Output body * - * @param PDF &$pdf PDF object + * @param PDF $pdf PDF object * @param string $page Page * @param array $lines Array of lines * @param Translate $outputlangs Object langs diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 94dd1b814e7..88b6e65bf01 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -239,7 +239,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * Check validity of code according to its rules * * @param DoliDB $db Database handler - * @param string &$code Code to check/correct + * @param string $code Code to check/correct * @param Societe $soc Object third party * @param int $type 0 = customer/prospect , 1 = supplier * @return int 0 if OK diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 313a14ad246..27155847bf0 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -90,7 +90,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * Check validity of code according to its rules * * @param DoliDB $db Database handler - * @param string &$code Code to check/correct + * @param string $code Code to check/correct * @param Societe $soc Object third party * @param int $type 0 = customer/prospect , 1 = supplier * @return int 0 if OK diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 8b31e581e26..2933a09de8e 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -139,7 +139,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode $date = dol_now(); $yymm = strftime("%y%m",$date); - + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is else $num = sprintf("%04s",$max+1); @@ -152,7 +152,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * Check validity of code according to its rules * * @param DoliDB $db Database handler - * @param string &$code Code to check/correct + * @param string $code Code to check/correct * @param Societe $soc Object third party * @param int $type 0 = customer/prospect , 1 = supplier * @return int 0 if OK diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index ead49d7de98..d3cf60295f6 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -494,7 +494,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show total to pay * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart @@ -689,7 +689,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y (not used) @@ -785,7 +785,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show payments table * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object invoice * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output @@ -870,7 +870,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -1045,7 +1045,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index f15cab9cb6b..78a33f76a29 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -521,7 +521,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders /** * Show payments table * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object order * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output @@ -536,7 +536,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders /** * Show miscellaneous information (payment mode, payment term, ...) * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object @@ -599,7 +599,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders /** * Show total to pay * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart @@ -802,7 +802,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders /** * Show table for lines * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y (not used) @@ -897,7 +897,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders /** * Show top header of page. * - * @param PDF &$pdf Object PDF + * @param PDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -1089,7 +1089,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders /** * Show footer of page. Need this->emetteur object * - * @param PDF &$pdf PDF + * @param PDF $pdf PDF * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 41a82de36b1..f40bcd3e061 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1762,8 +1762,8 @@ function show_elem($fieldssource,$pos,$key,$var,$nostyle='') /** * Return not used field number * - * @param array &$fieldssource Array of field source - * @param array &$listofkey Array of keys + * @param array $fieldssource Array of field source + * @param array $listofkey Array of keys * @return void */ function getnewkey(&$fieldssource,&$listofkey) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 30837b590f8..419c737b270 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -110,7 +110,7 @@ function test_sql_and_script_inject($val, $type) /** * Security: Return true if OK, false otherwise. * - * @param string &$var Variable name + * @param string $var Variable name * @param string $type 1=GET, 0=POST, 2=PHP_SELF * @return boolean true if there is an injection */ diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index ddbd3c015ff..44c28f383b5 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -67,7 +67,7 @@ class ActionsCardProduct /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * - * @param string &$action Type of action + * @param string $action Type of action * @param string $id Id of object * @param string $ref Ref of object * @return void diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index cee958be50f..cbb9e10750c 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -66,7 +66,7 @@ class ActionsCardService /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * - * @param string &$action Type of action + * @param string $action Type of action * @param string $id Id of object * @param string $ref Ref of object * @return void diff --git a/htdocs/resource/class/actions_resource.class.php b/htdocs/resource/class/actions_resource.class.php index afcf9eb19b8..f8f0b5412f9 100644 --- a/htdocs/resource/class/actions_resource.class.php +++ b/htdocs/resource/class/actions_resource.class.php @@ -46,8 +46,8 @@ class ActionsResource * doActions for resource module * * @param array $parameters parameters - * @param Object &$object object - * @param string &$action action + * @param Object $object object + * @param string $action action * @return void */ /* Why a hook action ? TODO Remove this class and replace a method into commonobject diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 1ee163038bb..6f6cb067333 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -89,7 +89,7 @@ abstract class ActionsCardCommon /** * Load data control * - * @param int &$action Action code + * @param int $action Action code * @return void */ function doActions(&$action) @@ -354,7 +354,7 @@ abstract class ActionsCardCommon /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * - * @param string &$action Type of action + * @param string $action Type of action * @param string $id Id of object * @param string $ref Ref of object * @return void diff --git a/htdocs/societe/canvas/company/actions_card_company.class.php b/htdocs/societe/canvas/company/actions_card_company.class.php index a47b6321792..d54af2b8bba 100644 --- a/htdocs/societe/canvas/company/actions_card_company.class.php +++ b/htdocs/societe/canvas/company/actions_card_company.class.php @@ -75,7 +75,7 @@ class ActionsCardCompany extends ActionsCardCommon /** * Execute actions * - * @param string &$action Type of action + * @param string $action Type of action * @param int $id Id of object * @return int <0 if KO, >0 if OK */ @@ -91,7 +91,7 @@ class ActionsCardCompany extends ActionsCardCommon /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * - * @param string &$action Type of action + * @param string $action Type of action * @param string $id Id of object * @param string $ref Ref of object * @return void diff --git a/htdocs/societe/canvas/individual/actions_card_individual.class.php b/htdocs/societe/canvas/individual/actions_card_individual.class.php index b8cb94a820b..2f00cd4bc27 100644 --- a/htdocs/societe/canvas/individual/actions_card_individual.class.php +++ b/htdocs/societe/canvas/individual/actions_card_individual.class.php @@ -75,7 +75,7 @@ class ActionsCardIndividual extends ActionsCardCommon /** * Execute actions * - * @param string &$action Action + * @param string $action Action * @param int $id Id of object (may be empty for creation) * @return int <0 if KO, >0 if OK */ @@ -91,7 +91,7 @@ class ActionsCardIndividual extends ActionsCardCommon /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * - * @param string &$action Type of action + * @param string $action Type of action * @param string $id Id of object * @param string $ref Ref of object * @return void diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5893fbab021..b97103458c3 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -133,17 +133,17 @@ class Societe extends CommonObject var $barcode_type; /** * code (loaded by fetch_barcode) - * @var + * @var string */ var $barcode_type_code; /** * label (loaded by fetch_barcode) - * @var + * @var string */ var $barcode_type_label; /** * coder (loaded by fetch_barcode) - * @var + * @var string */ var $barcode_type_coder; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index df36812cce8..6f59ac5eadf 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2118,7 +2118,7 @@ class User extends CommonObject /** * Update user using data from the LDAP * - * @param ldapuser &$ldapuser Ladp User + * @param ldapuser $ldapuser Ladp User * * @return int <0 if KO, >0 if OK */ @@ -2237,7 +2237,7 @@ class User extends CommonObject // Init this->parentof that is array(id_son=>id_parent, ...) $this->load_parentof(); - + // Init $this->users array $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.login, u.statut, u.entity"; // Distinct reduce pb with old tables with duplicates $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index 4adace8ef9a..7b5caffc2df 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -131,7 +131,7 @@ class FactureRecTest extends PHPUnit_Framework_TestCase $localobjectinv=new Facture($this->savdb); $localobjectinv->initAsSpecimen(); $localobjectinv->create($user); - + $localobject=new FactureRec($this->savdb); $localobject->initAsSpecimen(); $result=$localobject->create($user, $localobjectinv->id); @@ -141,15 +141,15 @@ class FactureRecTest extends PHPUnit_Framework_TestCase return $result; } - - - - - + + + + + /** * Edit an object to test updates * - * @param mixed &$localobject Object Facture + * @param mixed $localobject Object Facture * @return void */ public function changeProperties(&$localobject) diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 9551c6ce02e..cc54953875c 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -282,7 +282,7 @@ class FactureTest extends PHPUnit_Framework_TestCase /** * Edit an object to test updates * - * @param mixed &$localobject Object Facture + * @param mixed $localobject Object Facture * @return void */ public function changeProperties(&$localobject) diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index d161b3ce395..ef103eb1a46 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -272,7 +272,7 @@ class UserTest extends PHPUnit_Framework_TestCase /** * Edit an object to test updates * - * @param mixed &$localobject Object Facture + * @param mixed $localobject Object Facture * @return void */ public function changeProperties(&$localobject) From 5fdd798e9128e0b0ffdf165b6acf059a71164b7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Sep 2014 17:13:15 +0200 Subject: [PATCH 013/145] Fix: phpcheckstyle from phpcs 1.5.5 (closing tags and & char on parameter). --- htdocs/admin/commande.php | 1 - htdocs/admin/menus/other.php | 1 - htdocs/admin/stock.php | 6 ++--- htdocs/admin/system/database.php | 7 +++--- htdocs/admin/system/dbtable.php | 1 - htdocs/admin/system/dolibarr.php | 1 - htdocs/admin/system/index.php | 2 -- htdocs/admin/tools/eaccelerator.php | 1 - htdocs/admin/tools/purge.php | 1 - htdocs/admin/tools/update.php | 1 - htdocs/admin/translation.php | 1 - htdocs/admin/workflow.php | 1 - htdocs/cashdesk/affIndex.php | 1 - htdocs/cashdesk/facturation.php | 2 -- htdocs/cashdesk/tpl/menu.tpl.php | 1 - htdocs/categories/viewcat.php | 1 - htdocs/comm/action/class/actioncomm.class.php | 1 - htdocs/comm/fiche.php | 7 +++--- htdocs/commande/customer.php | 8 +++---- htdocs/compta/facture/apercu.php | 1 - htdocs/core/actions_sendmails.inc.php | 2 -- htdocs/core/actions_setnotes.inc.php | 2 -- htdocs/core/class/dolprintipp.class.php | 1 - htdocs/core/lib/holiday.lib.php | 1 - htdocs/core/lib/product.lib.php | 2 -- htdocs/core/lib/trip.lib.php | 4 +--- htdocs/core/lib/usergroups.lib.php | 1 - htdocs/core/login/functions_empty.php | 2 -- htdocs/core/login/functions_forceuser.php | 3 --- htdocs/core/login/functions_http.php | 3 --- htdocs/core/login/functions_ldap.php | 2 -- htdocs/core/login/functions_openid.php | 2 -- htdocs/core/menus/standard/auguria.lib.php | 2 -- .../core/modules/propale/modules_propale.php | 1 - htdocs/fichinter/document.php | 2 +- htdocs/holiday/define_holiday.php | 3 ++- htdocs/langs/en_US/compta.lang | 2 +- htdocs/livraison/class/livraison.class.php | 2 -- htdocs/opensurvey/fonctions.php | 23 +++++++++---------- htdocs/opensurvey/results.php | 1 - htdocs/printipp/admin/printipp.php | 8 +++---- htdocs/societe/ajaxcompanies.php | 2 -- .../canvas/actions_card_common.class.php | 1 - test/phpunit/CommandeFournisseurTest.php | 1 - test/phpunit/CommandeTest.php | 1 - test/phpunit/CommonObjectTest.php | 1 - test/phpunit/CompanyBankAccountTest.php | 2 +- test/phpunit/EntrepotTest.php | 1 - test/phpunit/ExportTest.php | 2 +- test/phpunit/FactureRecTest.php | 1 - test/phpunit/FactureTest.php | 2 +- test/phpunit/FunctionsLibTest.php | 2 +- test/phpunit/PropalTest.php | 2 +- test/phpunit/SocieteTest.php | 2 +- test/phpunit/UserTest.php | 1 - test/phpunit/WebservicesInvoicesTest.php | 2 +- test/phpunit/WebservicesThirdpartyTest.php | 2 +- 57 files changed, 42 insertions(+), 98 deletions(-) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 6736f9d2279..1d05efa8e99 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -534,4 +534,3 @@ print '
'; llxFooter(); $db->close(); -?> diff --git a/htdocs/admin/menus/other.php b/htdocs/admin/menus/other.php index 0ec3119c097..36733add335 100644 --- a/htdocs/admin/menus/other.php +++ b/htdocs/admin/menus/other.php @@ -143,4 +143,3 @@ print ''; llxFooter(); $db->close(); -?> \ No newline at end of file diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 9b80662c180..3cc9e70ca31 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -77,7 +77,7 @@ if($action) if($action == 'STOCK_USE_VIRTUAL_STOCK') { $res = dolibarr_set_const($db, "STOCK_USE_VIRTUAL_STOCK", GETPOST('STOCK_USE_VIRTUAL_STOCK','alpha'),'chaine',0,'',$conf->entity); } - + if($action == 'STOCK_MUST_BE_ENOUGH_FOR_INVOICE') { $res = dolibarr_set_const($db, "STOCK_MUST_BE_ENOUGH_FOR_INVOICE", GETPOST('STOCK_MUST_BE_ENOUGH_FOR_INVOICE','alpha'),'chaine',0,'',$conf->entity); } @@ -329,7 +329,7 @@ if ($virtualdiffersfromphysical) print ''; } -$db->close(); llxFooter(); -?> + +$db->close(); diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index f32122df7b9..d9833a13d01 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -81,7 +81,7 @@ else print ''.$langs->trans("Parameters").''; print ''.$langs->trans("Value").''; print ''."\n"; - + // arraytest is an array of test to do $arraytest=array(); if (preg_match('/mysql/i',$db->type)) @@ -91,7 +91,7 @@ else 'collation_database'=>array('var'=>'dolibarr_main_db_collation','valifempty'=>'utf8_general_ci') ); } - + $listtouse=array(); if ($listname == 'listofvars') $listtouse=$listofvars; if ($listname == 'listofstatus') $listtouse=$listofstatus; @@ -124,4 +124,5 @@ else } llxFooter(); -?> \ No newline at end of file + +$db->close(); diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index fe182c2e73e..0990d89acd0 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -130,4 +130,3 @@ else llxFooter(); $db->close(); -?> \ No newline at end of file diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 8be469006ff..fe9bde59cec 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -379,4 +379,3 @@ print ''; llxFooter(); $db->close(); -?> diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 640d5138362..1f95dce57cf 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -118,5 +118,3 @@ print info_admin($langs->trans("SystemInfoDesc")).'
'; llxFooter(); $db->close(); - -?> diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index a3f046f4510..8f82f33d039 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -350,4 +350,3 @@ print "

"; llxFooter(); $db->close(); -?> diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index cac0bce888c..30c7ba4dd43 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -166,4 +166,3 @@ if (preg_match('/^confirm/i',$choice)) llxFooter(); $db->close(); -?> \ No newline at end of file diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index e449d265fa3..8b0b105d0f0 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -174,4 +174,3 @@ if (! empty($result['return'])) llxFooter(); $db->close(); -?> \ No newline at end of file diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 8e5370a957e..66bc4fb22ba 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -69,4 +69,3 @@ print $langs->trans("SeeAlso").': '."\n"; -?> \ No newline at end of file diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index 4d442c0dbd3..32411f627fb 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -191,5 +191,3 @@ $obj_facturation->paiementLe('RESET'); // Affichage des templates require ('tpl/facturation1.tpl.php'); - -?> diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php index 59800fb57c1..4ee52ce0da6 100644 --- a/htdocs/cashdesk/tpl/menu.tpl.php +++ b/htdocs/cashdesk/tpl/menu.tpl.php @@ -78,4 +78,3 @@ if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && ! empty($conf->stock->enabled) } print ''; print ''; -?> \ No newline at end of file diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index bec834e1ff9..010306d1e00 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -520,4 +520,3 @@ if($object->type == 4) llxFooter(); $db->close(); -?> \ No newline at end of file diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index e41e556f3d9..9919dc21e80 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1071,4 +1071,3 @@ class ActionComm extends CommonObject } -?> diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 7a79b658a76..7ba1cc8bc48 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -821,11 +821,11 @@ if ($id > 0) /* * Barre d'actions */ - + $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - - + + print '
'; if (! empty($conf->propal->enabled) && $user->rights->propal->creer) @@ -933,4 +933,3 @@ dol_htmloutput_mesg('',$mesgs); // End of page llxFooter(); $db->close(); -?> diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 373775a0da0..29812903d12 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -156,7 +156,7 @@ if ($resql) print ""; print ''; - + $result=''; $lien=$lienfin=''; $lien = ''; @@ -164,7 +164,7 @@ if ($resql) $name=$obj->nom; $result.=($lien.img_object($langs->trans("ShowCompany").': '.$name,'company').$lienfin); $result.=$lien.(dol_trunc($name,$maxlen)).$lienfin; - + print $result; print ''; print ''.$obj->town.' '; @@ -185,7 +185,7 @@ else dol_print_error($db); } +llxFooter(); + $db->close(); -llxFooter(); -?> diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php index e1662708489..856640e306e 100644 --- a/htdocs/compta/facture/apercu.php +++ b/htdocs/compta/facture/apercu.php @@ -420,4 +420,3 @@ elseif (file_exists($fileimagebis)) $db->close(); llxFooter(); -?> diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index f13113487c1..3af164abfab 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -229,5 +229,3 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } - -?> \ No newline at end of file diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 3b2bbef75bb..74f576cf852 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -43,5 +43,3 @@ else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST(' $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); if ($result < 0) setEventMessage($object->error,'errors'); } - -?> \ No newline at end of file diff --git a/htdocs/core/class/dolprintipp.class.php b/htdocs/core/class/dolprintipp.class.php index 768741d9368..942ee3da3c3 100644 --- a/htdocs/core/class/dolprintipp.class.php +++ b/htdocs/core/class/dolprintipp.class.php @@ -201,4 +201,3 @@ class dolprintIPP return $ipp->printer_attributes; } } -?> diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index dd299ab5c2c..6b4877b14b2 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -50,4 +50,3 @@ function holiday_prepare_head($object) return $head; } -?> diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e8c86b37db9..a252b361dcf 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -357,5 +357,3 @@ function measuring_units_string($unit,$measuring_style='') return $measuring_units[$unit]; } - -?> diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php index 60794497554..7d58e9e01b1 100644 --- a/htdocs/core/lib/trip.lib.php +++ b/htdocs/core/lib/trip.lib.php @@ -54,10 +54,8 @@ function trip_prepare_head($object) $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; - + complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove'); return $head; } - -?> \ No newline at end of file diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index d6097b6f5a1..75a78627f52 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -342,4 +342,3 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print ''; } -?> diff --git a/htdocs/core/login/functions_empty.php b/htdocs/core/login/functions_empty.php index c96a5023d4d..e4379ee2c3a 100644 --- a/htdocs/core/login/functions_empty.php +++ b/htdocs/core/login/functions_empty.php @@ -39,5 +39,3 @@ function check_user_password_empty($usertotest,$passwordtotest,$entitytotest) return $login; } - -?> \ No newline at end of file diff --git a/htdocs/core/login/functions_forceuser.php b/htdocs/core/login/functions_forceuser.php index e74a253550a..94201c74ad0 100644 --- a/htdocs/core/login/functions_forceuser.php +++ b/htdocs/core/login/functions_forceuser.php @@ -46,6 +46,3 @@ function check_user_password_forceuser($usertotest,$passwordtotest,$entitytotest return $login; } - - -?> \ No newline at end of file diff --git a/htdocs/core/login/functions_http.php b/htdocs/core/login/functions_http.php index b224b27f15b..285ebebbabf 100644 --- a/htdocs/core/login/functions_http.php +++ b/htdocs/core/login/functions_http.php @@ -43,6 +43,3 @@ function check_user_password_http($usertotest,$passwordtotest,$entitytotest) return $login; } - - -?> \ No newline at end of file diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 403530ac80b..88a5f55de19 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -227,5 +227,3 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest) return $login; } - -?> diff --git a/htdocs/core/login/functions_openid.php b/htdocs/core/login/functions_openid.php index e183bc40795..2470567d596 100644 --- a/htdocs/core/login/functions_openid.php +++ b/htdocs/core/login/functions_openid.php @@ -112,5 +112,3 @@ function check_user_password_openid($usertotest,$passwordtotest,$entitytotest) return $login; } - -?> \ No newline at end of file diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 427a03d9929..e8d71496820 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -430,5 +430,3 @@ function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexterna if (! $menuentry['perms']) return 2; // No permissions and user is external return 1; } - -?> diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index 289862c8523..8e45f3b86f2 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -253,4 +253,3 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, } } -?> diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 54728df36d9..fd039efff24 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -131,7 +131,7 @@ else print $langs->trans("ErrorUnknown"); } + llxFooter(); $db->close(); -?> diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 4e1540c99e5..c432d37007b 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -190,7 +190,8 @@ print ''; dol_fiche_end(); + llxFooter(); $db->close(); -?> + diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 281ee374343..e0931bf5812 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -167,7 +167,7 @@ AccountancyDashboard=Accountancy summary ByProductsAndServices=By products and services RefExt=External ref ToCreateAPredefinedInvoice=To create a predefined invoice, create a standard invoice then, without validating it, click onto button "Convert to predefined invoice". -LinkedOrder=linked to order +LinkedOrder=Link to order ReCalculate=Recalculate Mode1=Method 1 Mode2=Method 2 diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index dd5ebf38573..65213cea647 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -968,5 +968,3 @@ class LivraisonLigne } } - -?> diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index c3c80a59b86..b2077c05bbf 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -25,14 +25,14 @@ /** * Returns an array with the tabs for the "Opensurvey poll" section * It loads tabs from modules looking for the entity Opensurveyso - * + * * @param Opensurveysondage $object Current viewing poll * @return array Tabs for the opensurvey section */ function opensurvey_prepare_head(Opensurveysondage $object) { - + global $langs, $conf; - + $h = 0; $head = array(); @@ -40,7 +40,7 @@ function opensurvey_prepare_head(Opensurveysondage $object) { $head[0][1] = $langs->trans("Card"); $head[0][2] = 'general'; $h++; - + $head[1][0] = 'results.php?id='.$object->id_sondage; $head[1][1] = $langs->trans("SurveyResults"); $head[1][2] = 'preview'; @@ -111,12 +111,12 @@ function showlogo() $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=companylogo&file=thumbs/'.urlencode($mysoc->logo_small); } } - + if (!$urllogo && (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png'))) { $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; } - + print '
Logo
'; print '
'; } @@ -205,14 +205,14 @@ function dol_survey_random($car) function ajouter_sondage() { global $db, $user; - + require_once DOL_DOCUMENT_ROOT.'/opensurvey/class/opensurveysondage.class.php'; $sondage=dol_survey_random(16); $allow_comments = empty($_SESSION['allow_comments']) ? 0 : 1; $allow_spy = empty($_SESSION['allow_spy']) ? 0 : 1; - + // Insert survey $opensurveysondage = new Opensurveysondage($db); $opensurveysondage->id_sondage = $sondage; @@ -226,9 +226,9 @@ function ajouter_sondage() $opensurveysondage->allow_comments = $allow_comments; $opensurveysondage->allow_spy = $allow_spy; $opensurveysondage->sujet = $_SESSION['toutchoix']; - + $res = $opensurveysondage->create($user); - + if ($res < 0) { dol_print_error($db); } @@ -243,11 +243,10 @@ function ajouter_sondage() unset($_SESSION['toutchoix']); unset($_SESSION['totalchoixjour']); unset($_SESSION['champdatefin']); - + $urlback=dol_buildpath('/opensurvey/card.php',1).'?id='.$sondage; header("Location: ".$urlback); exit(); } -?> diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 00daab24b27..c5baba61242 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -1083,4 +1083,3 @@ print '
'."\n"; llxFooterSurvey(); $db->close(); -?> diff --git a/htdocs/printipp/admin/printipp.php b/htdocs/printipp/admin/printipp.php index 08202b38f8e..6aaf44f8bdd 100644 --- a/htdocs/printipp/admin/printipp.php +++ b/htdocs/printipp/admin/printipp.php @@ -149,7 +149,7 @@ if ($mode == 'config' && $user->admin) print $langs->trans("PRINTIPP_PASSWORD").''; print ''; print ''; - + //$var=true; //print ''; //print ''.$langs->trans("OtherParameter").''; @@ -181,7 +181,7 @@ if ($mode == 'test' && $user->admin) print 'Media'; print 'Supported'; print "\n"; - + $list = $printer->getlist_available_printers(); $var = true; foreach ($list as $value) @@ -203,13 +203,13 @@ if ($mode == 'test' && $user->admin) print "\n"; } print ''; - + if (count($list) == 0) print $langs->trans("NoPrinterFound"); } dol_fiche_end(); + llxFooter(); $db->close(); -?> diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php index 32fbe2e2c00..de116453cf2 100644 --- a/htdocs/societe/ajaxcompanies.php +++ b/htdocs/societe/ajaxcompanies.php @@ -110,5 +110,3 @@ else { echo json_encode(array('nom'=>'ErrorBadParameter','label'=>'ErrorBadParameter','key'=>'ErrorBadParameter','value'=>'ErrorBadParameter')); } - -?> \ No newline at end of file diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 6f6cb067333..39f0dc761f8 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -706,4 +706,3 @@ abstract class ActionsCardCommon } -?> diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 2c83b4fdfc3..90c0d10e3fb 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -338,4 +338,3 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase } } -?> \ No newline at end of file diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index 451e886a761..8a2e3f57120 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -265,4 +265,3 @@ class CommandeTest extends PHPUnit_Framework_TestCase } } -?> \ No newline at end of file diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index cbdde31e14d..a22146dfc2a 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -183,4 +183,3 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase return $result; } } -?> \ No newline at end of file diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index 24d6ad03d80..693282e62c4 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -233,4 +233,4 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase } } -?> + diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index efd5f54008f..53788d71dab 100755 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -257,4 +257,3 @@ class EntrepotTest extends PHPUnit_Framework_TestCase return; } } -?> \ No newline at end of file diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index d5938fc4691..641fe3b7f9e 100755 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -265,4 +265,4 @@ class ExportTest extends PHPUnit_Framework_TestCase return true; } } -?> + diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index 7b5caffc2df..4d4783240fa 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -196,4 +196,3 @@ class FactureRecTest extends PHPUnit_Framework_TestCase return $retAr; } } -?> \ No newline at end of file diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index cc54953875c..2227559ffd3 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -329,4 +329,4 @@ class FactureTest extends PHPUnit_Framework_TestCase return $retAr; } } -?> + diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index dbb3f6d8b8d..78c2278ba69 100755 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -799,4 +799,4 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase } } -?> + diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php index 3cac847a01f..089b279f75c 100644 --- a/test/phpunit/PropalTest.php +++ b/test/phpunit/PropalTest.php @@ -265,4 +265,4 @@ class PropalTest extends PHPUnit_Framework_TestCase } } -?> + diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index 162248f2e98..97aa0f0a954 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -456,4 +456,4 @@ class SocieteTest extends PHPUnit_Framework_TestCase } } -?> + diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index ef103eb1a46..e0eaa03acec 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -318,4 +318,3 @@ class UserTest extends PHPUnit_Framework_TestCase return $retAr; } } -?> \ No newline at end of file diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index 12c01eeba70..85c2398c568 100755 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -181,4 +181,4 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase } } -?> + diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 8ef0c383955..bf7cdc357c0 100755 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -181,4 +181,4 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase } } -?> + From 6a570222cc413ffe305f32b08939e63f5e7c814a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Sep 2014 14:18:04 +0200 Subject: [PATCH 014/145] Fix: Missing fields into select --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9919dc21e80..360f38c3f45 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -284,7 +284,7 @@ class ActionComm extends CommonObject $sql.= " a.fk_user_action, a.fk_user_done,"; $sql.= " a.fk_contact, a.percent as percentage,"; $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.priority, a.fulldayevent, a.location, a.transparency,"; + $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle,"; $sql.= " s.nom as socname,"; $sql.= " u.firstname, u.lastname as lastname"; @@ -878,7 +878,7 @@ class ActionComm extends CommonObject $sql.= " a.fk_user_action, a.fk_user_done,"; $sql.= " a.fk_contact, a.percent as percentage,"; $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.priority, a.fulldayevent, a.location,"; + $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; $sql.= " u.firstname, u.lastname,"; $sql.= " s.nom as socname,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle"; From 8c6ce79d9d0da035f67d0e67a0db34ec7c9cb8a7 Mon Sep 17 00:00:00 2001 From: Drosis Nikos Date: Mon, 29 Sep 2014 18:15:09 +0300 Subject: [PATCH 015/145] Fix Lang for Payment Type --- htdocs/compta/sociales/charges.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index 48a8f656959..4ea2af2c20f 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -300,7 +300,7 @@ if ($id > 0) * Payments */ $sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,"; - $sql.= "c.libelle as paiement_type"; + $sql.= "c.code as type_code,c.libelle as paiement_type"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; @@ -333,8 +333,9 @@ if ($id > 0) print ""; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; - print "".$objp->paiement_type.' '.$objp->num_paiement."\n"; - print ''.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."\n"; + $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type; + print "".$labeltype.' '.$objp->num_paiement."\n"; + print ''.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."\n"; print ""; $totalpaye += $objp->amount; $i++; From 920c9c725104b58ca3375ff7bf436042aa04f976 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 30 Sep 2014 17:36:01 +0200 Subject: [PATCH 016/145] Fix : tva not coming from multiprice --- htdocs/comm/propal.php | 2 -- htdocs/commande/fiche.php | 2 -- htdocs/compta/facture.php | 2 -- 3 files changed, 6 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index cece1b3b29e..beaa24be32e 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -738,8 +738,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; $price_min = $prod->multiprices_min[$object->client->price_level]; $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; } else { diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 99864a59dd2..9af80af21e1 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -686,8 +686,6 @@ else if ($action == 'addline' && $user->rights->commande->creer) $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; $price_min = $prod->multiprices_min[$object->client->price_level]; $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; } else { diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b17b59cf704..11a920877cd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1262,8 +1262,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; $price_min = $prod->multiprices_min[$object->client->price_level]; $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - //$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - //$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; } else { From 78ec4d595b11c22317c54074d0b61a998b3b18cb Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 2 Oct 2014 15:21:49 +0200 Subject: [PATCH 017/145] Fix trad currency --- ChangeLog | 1 + htdocs/product/composition/fiche.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34448e95543..218d6aada55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ For users: - Fix: Withdrawal total amount is double - Fix: [ bug #1593 ] Spanish Localtax IRPF not being calculated since 3.6.0 in supplier invoices when adding a line - Fix: Web service categorie WDSL declaration is correct +- Fix: ErrorBadValueForParamNotAString was displayed in virtual product if no base price defined ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/product/composition/fiche.php b/htdocs/product/composition/fiche.php index 26761a2d56b..bf89798e79f 100644 --- a/htdocs/product/composition/fiche.php +++ b/htdocs/product/composition/fiche.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $langs->load("bills"); $langs->load("products"); +$langs->load("main"); $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -292,13 +293,17 @@ if ($id > 0 || ! empty($ref)) { // Price print ''.$langs->trans("SellingPrice").''; + if ($object->price_base_type == 'TTC') { print price($object->price_ttc).' '.$langs->trans($object->price_base_type); } else { - print price($object->price).' '.$langs->trans($object->price_base_type); + print price($object->price); + if (!empty($object->price_base_type)) { + print ' '.$langs->trans($object->price_base_type); + } } print ''; @@ -310,7 +315,10 @@ if ($id > 0 || ! empty($ref)) } else { - print price($object->price_min).' '.$langs->trans($object->price_base_type); + print price($object->price_min); + if (!empty($object->price_base_type)) { + print ' '.$langs->trans($object->price_base_type); + } } print ''; } From 4b28ff005ef29c8de594eca9b24c2ab8a54356ea Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 2 Oct 2014 15:24:40 +0200 Subject: [PATCH 018/145] Return error message on category creation failure --- ChangeLog | 1 + htdocs/categories/fiche.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 218d6aada55..fc92cfd43a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ For users: - Fix: [ bug #1593 ] Spanish Localtax IRPF not being calculated since 3.6.0 in supplier invoices when adding a line - Fix: Web service categorie WDSL declaration is correct - Fix: ErrorBadValueForParamNotAString was displayed in virtual product if no base price defined +- Fix: Category creation failed and no message output ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index a2f9dc54df2..208cbb38331 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -143,6 +143,8 @@ if ($action == 'add' && $user->rights->categorie->creer) { $action = 'confirmed'; $_POST["addcat"] = ''; + } else { + setEventMessage($object->error,'errors'); } } } From c69565fd69f826f3fc3c846a849f8e088828f4a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Oct 2014 03:12:39 +0200 Subject: [PATCH 019/145] Fix: column name should not be an numeric --- htdocs/core/actions_extrafields.inc.php | 18 +++++++++--------- htdocs/core/class/commonobject.class.php | 8 ++++---- htdocs/core/class/extrafields.class.php | 5 ++--- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 55a538a2195..89edfcbae8e 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -28,7 +28,7 @@ $extrasize=GETPOST('size'); if (GETPOST('type')=='double' && strpos($extrasize,',')===false) $extrasize='24,8'; if (GETPOST('type')=='date') $extrasize=''; if (GETPOST('type')=='datetime') $extrasize=''; -if (GETPOST('type')=='select') $extrasize=''; +if (GETPOST('type')=='select') $extrasize=''; // Add attribute @@ -87,7 +87,7 @@ if ($action == 'add') $mesg[]=$langs->trans("ErrorNoValueForRadioType"); $action = 'create'; } - if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox')) && GETPOST('param')) + if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox')) && GETPOST('param')) { // Construct array for parameter (value of select list) $parameters = GETPOST('param'); @@ -95,7 +95,7 @@ if ($action == 'add') foreach($parameters_array as $param_ligne) { if (!empty($param_ligne)) { - if (preg_match_all('/,/',$param_ligne,$matches)) + if (preg_match_all('/,/',$param_ligne,$matches)) { if (count($matches[0])>1) { $error++; @@ -104,7 +104,7 @@ if ($action == 'add') $action = 'create'; } } - else + else { $error++; $langs->load("errors"); @@ -112,12 +112,12 @@ if ($action == 'add') $action = 'create'; } } - } + } } if (! $error) { - // attrname must be alphabetical and lower case only + // attrname must be alphabetical and lower case only if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname'])) { // Construct array for parameter (value of select list) @@ -139,8 +139,8 @@ if ($action == 'add') list($key,$value) = explode(',',$param_ligne); $params['options'][$key] = $value; } - } - + } + $result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params); if ($result > 0) { @@ -164,7 +164,7 @@ if ($action == 'add') $action = 'create'; } } - else + else { setEventMessage($mesg,'errors'); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 36b4af841a8..0f41eefddf7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2120,11 +2120,11 @@ abstract class CommonObject foreach ($tab as $key => $value) { - // Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine) - if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) + // Test fetch_array ! is_int($key) because fetch_array result is a mix table with some key as alpha and some key as int (depend db engine) + if ($key != 'rowid' && $key != 'tms' && ! is_int($key)) { - // we can add this attribute to adherent object - $this->array_options["options_$key"]=$value; + // we can add this attribute to object properties + $this->array_options["options_".$key]=$value; } } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7b1f9d59889..c9e5d937a18 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -154,7 +154,7 @@ class ExtraFields { $table=$elementtype.'_extrafields'; - if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) + if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname)) { if ($type=='boolean') { $typedb='int'; @@ -226,8 +226,7 @@ class ExtraFields // Clean parameters if (empty($pos)) $pos=0; - - if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) + if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname)) { if(is_array($param) and count($param) > 0) { From a853aed348f2fcc9c8e0258beec591407f1b4634 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Oct 2014 03:42:11 +0200 Subject: [PATCH 020/145] Fix: Some fields not visibles. Wrong value for calculated time. --- htdocs/projet/class/task.class.php | 2 +- htdocs/projet/tasks/task.php | 9 +++++---- htdocs/projet/tasks/time.php | 31 +++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index ea0cce9e121..c97b51e53a4 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -41,7 +41,7 @@ class Task extends CommonObject var $fk_task_parent; var $label; var $description; - var $duration_effective; + var $duration_effective; // total of time spent on this task var $planned_workload; var $date_c; var $date_start; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index dd83cf57d8f..908a9513162 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -348,7 +348,7 @@ if ($id > 0 || ! empty($ref)) print ''; // Progress - print ''.$langs->trans("Progress").''; + print ''.$langs->trans("ProgressDeclared").''; print $formother->select_percent($object->progress,'progress'); print ''; @@ -436,14 +436,15 @@ if ($id > 0 || ! empty($ref)) print convertSecondToTime($object->planned_workload,'allhourmin'); print ''; - // Progress + // Declared progress print ''.$langs->trans("ProgressDeclared").''; print $object->progress.' %'; print ''; - // Progress + // Calculated progress print ''.$langs->trans("ProgressCalculated").''; - print $object->progress.' %'; + if ($object->planned_workload) print round(100 * $object->duration_effective / $object->planned_workload,2).' %'; + else print ''; print ''; // Description diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index cb8a4dd193a..7136ffc43c5 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -50,7 +50,7 @@ $projectstatic = new Project($db); /* * Actions -*/ + */ if ($action == 'addtimespent' && $user->rights->projet->creer) { @@ -171,7 +171,7 @@ if (! empty($project_ref) && ! empty($withproject)) /* * View -*/ + */ llxHeader("",$langs->trans("Task")); @@ -283,9 +283,6 @@ if ($id > 0 || ! empty($ref)) // Label print ''.$langs->trans("Label").''.$object->label.''; - // Planned workload - print ''.$langs->trans("PlannedWorkload").''.convertSecondToTime($object->planned_workload,'allhourmin').''; - // Project if (empty($withproject)) { @@ -300,6 +297,30 @@ if ($id > 0 || ! empty($ref)) print ''; } + // Date start + print ''.$langs->trans("DateStart").''; + print dol_print_date($object->date_start,'dayhour'); + print ''; + + // Date end + print ''.$langs->trans("DateEnd").''; + print dol_print_date($object->date_end,'dayhour'); + print ''; + + // Planned workload + print ''.$langs->trans("PlannedWorkload").''.convertSecondToTime($object->planned_workload,'allhourmin').''; + + // Declared progress + print ''.$langs->trans("ProgressDeclared").''; + print $object->progress.' %'; + print ''; + + // Calculated progress + print ''.$langs->trans("ProgressCalculated").''; + if ($object->planned_workload) print round(100 * $object->duration_effective / $object->planned_workload,2).' %'; + else print ''; + print ''; + print ''; dol_fiche_end(); From b85a8359884e90264b92afc7997e828fcce1ff8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Oct 2014 19:03:58 +0200 Subject: [PATCH 021/145] Prepare 3.6.1 --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index fc92cfd43a9..294fc64ff5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,8 @@ For users: - Fix: Web service categorie WDSL declaration is correct - Fix: ErrorBadValueForParamNotAString was displayed in virtual product if no base price defined - Fix: Category creation failed and no message output +- Fix: Lanf for Payment Type +- Fix: PHPCheckstyle 1.5.5 ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: From 05fe8e45b3ead4dd32b75e2c280b8be4c21356ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Oct 2014 19:07:49 +0200 Subject: [PATCH 022/145] Exclude module dire from package --- build/makepack-dolibarr.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 55de5abffb4..a1e08361d36 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -434,6 +434,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/nltechno*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/pos*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`; $ret=`rm -fr $BUILDROOT/$PROJECT/test`; $ret=`rm -fr $BUILDROOT/$PROJECT/Thumbs.db $BUILDROOT/$PROJECT/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/Thumbs.db $BUILDROOT/$PROJECT/*/*/*/*/Thumbs.db`; $ret=`rm -f $BUILDROOT/$PROJECT/.cvsignore $BUILDROOT/$PROJECT/*/.cvsignore $BUILDROOT/$PROJECT/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.cvsignore`; From 742d0e37eeadf40c7b01475f5a90b2986777b2d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Oct 2014 12:54:51 +0200 Subject: [PATCH 023/145] Fix: Bad month return by function --- htdocs/core/lib/date.lib.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 78551dac105..39d3e6ffa7b 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -518,8 +518,8 @@ function dol_get_last_day($year,$month=12,$gm=false) * @param int $day Day * @param int $month Month * @param int $year Year - * @param int $gm False = Return date to compare with server TZ, True to compare with GM date. - * @return array year,month, week,first_day,prev_year,prev_month,prev_day + * @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date. + * @return array year,month,week,first_day,prev_year,prev_month,prev_day */ function dol_get_first_day_week($day,$month,$year,$gm=false) { @@ -542,7 +542,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false) $tmpday = date($tmparray[0])-$seconds; $tmpday = date("d",$tmpday); - //Check first day of week is form this month or not + //Check first day of week is in same month than current day or not if ($tmpday>$day) { $prev_month = $month-1; @@ -559,15 +559,17 @@ function dol_get_first_day_week($day,$month,$year,$gm=false) $prev_month = $month; $prev_year = $year; } + $tmpmonth = $prev_month; + $tmpyear = $prev_year; - //Get first day of next week + //Get first day of next week $tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0); $tmptime-=24*60*60*7; $tmparray=dol_getdate($tmptime,true); $prev_day = $tmparray['mday']; - //Check first day of week is form this month or not - if ($prev_day>$tmpday) + //Check prev day of week is in same month than first day or not + if ($prev_day > $tmpday) { $prev_month = $month-1; $prev_year = $year; @@ -579,9 +581,9 @@ function dol_get_first_day_week($day,$month,$year,$gm=false) } } - $week = date("W",dol_mktime(0,0,0,$month,$tmpday,$year,$gm)); + $week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm)); - return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day); + return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day); } /** From c73f4a14ee9d62e8f6a9d4ab8ef502932ae4f36d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Oct 2014 16:17:09 +0200 Subject: [PATCH 024/145] Fix: Bad days returned by function --- htdocs/comm/action/index.php | 51 ++++++++++++++---------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index efe47defd92..e518b05ded6 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -184,18 +184,19 @@ if ($action=='show_week') $prev_month = $prev['prev_month']; $prev_day = $prev['prev_day']; $first_day = $prev['first_day']; - + $first_month= $prev['first_month']; + $first_year = $prev['first_year']; $week = $prev['week']; $day = (int) $day; - $next = dol_get_next_week($day, $week, $month, $year); + $next = dol_get_next_week($first_day, $week, $first_month, $first_year); $next_year = $next['year']; $next_month = $next['month']; $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow - $firstdaytoshow=dol_mktime(0,0,0,$prev_month,$first_day,$prev_year); - $lastdaytoshow=dol_mktime(0,0,0,$next_month,$next_day,$next_year); + $firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year); + $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); $max_day_in_month = date("t",dol_mktime(0,0,0,$month,1,$year)); @@ -870,39 +871,27 @@ elseif ($action == 'show_week') // View by week } echo " \n"; - // In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month) - //var_dump($eventarray); - //print $tmpday; - echo " \n"; for($iter_day = 0; $iter_day < 7; $iter_day++) { - if(($tmpday <= $max_day_in_month)) - { - // Show days of the current week - $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); + // Show days of the current week + $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); + $tmparray = dol_getdate($curtime,'fast'); + $tmpday = $tmparray['mday']; + $tmpmonth = $tmparray['mon']; + $tmpyear = $tmparray['year']; - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_other_month_right'; - $today=0; - $todayarray=dol_getdate($now,'fast'); - if ($todayarray['mday']==$tmpday && $todayarray['mon']==$month && $todayarray['year']==$year) $today=1; - if ($today) $style='cal_today'; + $style='cal_current_month'; + if ($iter_day == 6) $style.=' cal_other_month_right'; + $today=0; + $todayarray=dol_getdate($now,'fast'); + if ($todayarray['mday']==$tmpday && $todayarray['mon']==$tmpmonth && $todayarray['year']==$tmpyear) $today=1; + if ($today) $style='cal_today'; - echo ' '; - show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); - echo " \n"; - } - else - { - $style='cal_current_month'; - if ($iter_day == 6) $style.=' cal_other_month_right'; - echo ' '; - show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); - echo "\n"; - } - $tmpday++; + echo ' '; + show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); + echo " \n"; } echo " \n"; From 692881bf5998e06b6fd9adf1ecc830c39b1220c7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 6 Oct 2014 09:06:25 +0200 Subject: [PATCH 025/145] Fix: missing $ismultientitymanaged --- htdocs/contrat/class/contrat.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 073ef7bd0f5..6cf04c10522 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1,12 +1,12 @@ * Copyright (C) 2004-2012 Destailleur Laurent - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013 Florian Henry * * 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 @@ -41,6 +41,7 @@ class Contrat extends CommonObject public $table_element='contrat'; public $table_element_line='contratdet'; public $fk_element='fk_contrat'; + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $id; var $ref; From 48072c58d796789edbdfca6091c00d0eb7e8b913 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 6 Oct 2014 10:05:27 +0200 Subject: [PATCH 026/145] Fix bug 1588 : relative discount not working anymore --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 68613492df8..a51a6505416 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -203,7 +203,7 @@ else { "> - remise_client); ?>" name="remise_percent">% + remise_percent); ?>" name="remise_percent">% Date: Mon, 6 Oct 2014 13:28:07 +0200 Subject: [PATCH 027/145] Missing reprogramming task into GUI for cron module. Without this, a new task is never executed (because without datenextrun defined) --- htdocs/cron/card.php | 15 ++++++++++++--- htdocs/cron/list.php | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 4857523aaf5..dd30e67afab 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -95,9 +95,18 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex } else { - if ($object->lastresult > 0) setEventMessage($langs->trans("JobFinished"),'warnings'); - else setEventMessage($langs->trans("JobFinished"),'mesgs'); - $action=''; + $res = $object->reprogram_jobs($user->login); + if ($res > 0) + { + if ($object->lastresult > 0) setEventMessage($langs->trans("JobFinished"),'warnings'); + else setEventMessage($langs->trans("JobFinished"),'mesgs'); + $action=''; + } + else + { + setEventMessage($object->error,'errors'); + $action=''; + } } } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 19a0d5cc3b1..28f16c1ad55 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -100,6 +100,21 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex if ($result < 0) { setEventMessage($object->error,'errors'); } + else + { + $res = $object->reprogram_jobs($user->login); + if ($res > 0) + { + if ($object->lastresult > 0) setEventMessage($langs->trans("JobFinished"),'warnings'); + else setEventMessage($langs->trans("JobFinished"),'mesgs'); + $action=''; + } + else + { + setEventMessage($object->error,'errors'); + $action=''; + } + } header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-1'); // Make a call to avoid to run twice job when using back exit; From 87fc27c7e649566ebb467dc32af7b65ee623f292 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 6 Oct 2014 13:31:01 +0200 Subject: [PATCH 028/145] Avoid missing class error for fetch_thirdparty method --- htdocs/core/class/commonobject.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6439e3e003e..7c803a0b8a9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -576,6 +576,9 @@ abstract class CommonObject if (empty($this->socid)) return 0; + if (!class_exists('Societe')) + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdparty = new Societe($this->db); $result=$thirdparty->fetch($this->socid); $this->client = $thirdparty; // deprecated From 6a4468d94ea397695033249d40e73095970fd247 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 6 Oct 2014 14:18:28 +0200 Subject: [PATCH 029/145] Not need to test if class exists with require_once --- htdocs/core/class/commonobject.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7c803a0b8a9..3ef8241f83f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -576,8 +576,7 @@ abstract class CommonObject if (empty($this->socid)) return 0; - if (!class_exists('Societe')) - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $thirdparty = new Societe($this->db); $result=$thirdparty->fetch($this->socid); From 0c7cabbf373650f410dfb6203de7284554484f08 Mon Sep 17 00:00:00 2001 From: Drosis Nikos Date: Mon, 6 Oct 2014 16:15:11 +0300 Subject: [PATCH 030/145] Fix Error when trying to clone an Order --- htdocs/commande/class/commande.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a6659ee8bb3..f6d5677af16 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -898,6 +898,13 @@ class Commande extends CommonOrder $this->date_validation = ''; $this->ref_client = ''; + // Set ref + require_once DOL_DOCUMENT_ROOT ."/core/modules/commande/".$conf->global->COMMANDE_ADDON.'.php'; + $obj = $conf->global->COMMANDE_ADDON; + $modCommande = new $obj; + $this->ref = $modCommande->getNextValue($objsoc,$this); + + // Create clone $result=$this->create($user); if ($result < 0) $error++; From 4fd67d725ab2d634dc0a1f66f3a508a158eabbbf Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 6 Oct 2014 10:05:27 +0200 Subject: [PATCH 031/145] Fix bug 1588 : relative discount not working anymore --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 68613492df8..a51a6505416 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -203,7 +203,7 @@ else { "> - remise_client); ?>" name="remise_percent">% + remise_percent); ?>" name="remise_percent">% Date: Sat, 11 Oct 2014 23:55:10 +0200 Subject: [PATCH 032/145] Fix: ErrorBadValueForParamNotAString error message in price customer multiprice --- htdocs/product/price.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index b208cba1c7e..856a68face6 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -365,10 +365,14 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) { // Prix mini print '' . $langs->trans("MinPrice") . ' ' . $i . ''; - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print price($object->multiprices_min_ttc ["$i"]) . ' ' . $langs->trans($object->multiprices_base_type ["$i"]); - } else { - print price($object->multiprices_min ["$i"]) . ' ' . $langs->trans($object->multiprices_base_type ["$i"]); + if (empty($object->multiprices_base_type["$i"])) $object->multiprices_base_type["$i"]="HT"; + if ($object->multiprices_base_type["$i"] == 'TTC') + { + print price($object->multiprices_min_ttc["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]); + } + else + { + print price($object->multiprices_min["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]); } print ''; From c184253951cfa64952d5ee6399472611255ecf22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Oct 2014 23:56:45 +0200 Subject: [PATCH 033/145] Update doc --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 294fc64ff5a..90067f92312 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 3.6.2 compared to 3.6.1 ***** +- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice + + ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: - Fix: Can upload files on services. From ac2ff5c6044ad1524579e986c8129e256f693385 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Oct 2014 01:40:18 +0200 Subject: [PATCH 034/145] Update logs --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 90067f92312..a4e7edc94dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice - +- Fix: bug 1588 : relative discount ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: From c30f13a03d9f9bba6f390b8ab5bf583629379e89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Oct 2014 02:07:50 +0200 Subject: [PATCH 035/145] Fix: label of input method not translated. --- ChangeLog | 1 + htdocs/fourn/class/fournisseur.commande.class.php | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4e7edc94dd..12694302fda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice - Fix: bug 1588 : relative discount +- Fix: label of input method not tranlated. ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 155c8111f81..3aa9d77f5de 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2016,7 +2016,8 @@ class CommandeFournisseur extends CommonOrder } /** - * Returns the translated input method + * Returns the translated input method of object (defined if $this->methode_commande_id > 0). + * This function make a sql request to get translation. No cache yet, try to not use it inside a loop. * * @return string */ @@ -2026,21 +2027,19 @@ class CommandeFournisseur extends CommonOrder if ($this->methode_commande_id > 0) { - $sql = "SELECT rowid, code, libelle"; + $sql = "SELECT rowid, code, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_method'; $sql.= " WHERE active=1 AND rowid = ".$db->escape($this->methode_commande_id); $query = $db->query($sql); - if ($query && $db->num_rows($query)) { - $result = $db->fetch_object($query); + $obj = $db->fetch_object($query); - $string = $langs->trans($result->code); - - if ($string == $result->code) + $string = $langs->trans($obj->code); + if ($string == $obj->code) { - $string = $obj->libelle != '-' ? $obj->libelle : ''; + $string = $obj->label != '-' ? $obj->label : ''; } return $string; From cbbe909bc58f028ab3a76156171d2ff8202ca8a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Oct 2014 15:22:07 +0200 Subject: [PATCH 036/145] Fix: Pb in management of "or" ("|") for permission check. --- htdocs/compta/charges/index.php | 10 +++++----- htdocs/core/lib/security.lib.php | 12 +++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index f38f7e72aa2..a3803e853ba 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -111,7 +111,7 @@ if ($conf->salaries->enabled) $total = 0 ; print ''; print ''; - print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.datev","",$param,'width="120"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"s.datev","",$param,'width="140px"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"s.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"s.rowid","",$param,'',$sortfield,$sortorder); @@ -144,7 +144,7 @@ if ($conf->salaries->enabled) $i++; } - print ''; + print ''; print '"; print ''; print ''; @@ -174,7 +174,7 @@ if ($conf->tax->enabled) print '
'.$langs->trans("Total").'
'.$langs->trans("Total").''.price($total)."  
'; print ''; - print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="120"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"cs.date_ech","",$param,'width="140px"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"c.libelle","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"cs.fk_type","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"cs.amount","",$param,'align="right"',$sortfield,$sortorder); @@ -304,7 +304,7 @@ if ($conf->tax->enabled) $total = 0 ; print '
'; print ''; - print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="120"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PeriodEndDate"),$_SERVER["PHP_SELF"],"pv.datev","",$param,'width="140px"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"pv.label","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("ExpectedToPay"),$_SERVER["PHP_SELF"],"pv.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("RefPayment"),$_SERVER["PHP_SELF"],"pv.rowid","",$param,'',$sortfield,$sortorder); @@ -337,7 +337,7 @@ if ($conf->tax->enabled) $i++; } - print ''; + print ''; print '"; print ''; print ''; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 31e900f8e7e..7416d564a1a 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -174,11 +174,17 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature } else if (! empty($feature2)) // This should be used for future changes { + $tmpreadok=1; foreach($feature2 as $subfeature) { - if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $readok=0; $nbko++; } - else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $readok=0; $nbko++; } - else { $readok=1; break; } // Break is to bypass second test if the first is ok + if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; } + else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; } + else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok + } + if (! $tmpreadok) // We found a test on feature that is ko + { + $readok=0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). + $nbko++; } } else if (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is for old permissions From 30e27014b887b21dfb33458512b8819bdcac3e6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Oct 2014 15:49:14 +0200 Subject: [PATCH 037/145] Fix: box of customer and propsects were not correctly disabled. --- htdocs/core/boxes/box_clients.php | 18 +++++++++++++++++- htdocs/core/boxes/box_prospect.php | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index b2ad0a6b718..b65702b643f 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -37,12 +37,28 @@ class box_clients extends ModeleBoxes var $depends = array("societe"); var $db; - var $param; + var $enabled = 1; var $info_box_head = array(); var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param='') + { + global $conf, $user; + + $this->db = $db; + + // disable box for such cases + if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option + } + /** * Load data for box to show them later * diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 9c7a666bc4a..6d62989727b 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -39,11 +39,28 @@ class box_prospect extends ModeleBoxes var $depends = array("societe"); var $db; + var $enabled = 1; var $info_box_head = array(); var $info_box_contents = array(); + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param='') + { + global $conf, $user; + + $this->db = $db; + + // disable box for such cases + if (! empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled=0; // disabled by this option + } + /** * Load data into info_box_contents array to show array later. * From 455bae98ef41d67d402ad0e8f03183ccba4817c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Oct 2014 15:49:29 +0200 Subject: [PATCH 038/145] Fix: box of customer and propsects were not correctly disabled. --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 12694302fda..42a8d6d6b28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice - Fix: bug 1588 : relative discount - Fix: label of input method not tranlated. +- Fix: box of customer and propsects were not correctly disabled. ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: From 104592b349bfe241907266a51361d48413b62f72 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 12 Oct 2014 19:08:34 +0200 Subject: [PATCH 039/145] Fix: wrong function name --- 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 7a855eb9325..394dd4fad82 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -703,7 +703,7 @@ class Translate */ function getCurrencyAmount($currency_code, $amount) { - $symbol=$this->getCurrencSymbol($currency_code); + $symbol=$this->getCurrencySymbol($currency_code); if (in_array($currency_code, array('USD'))) return $symbol.$amount; else return $amount.$symbol; From 722f6e0db6a64132dc2e68606d288a80a346de03 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 15 Oct 2014 15:24:31 +0200 Subject: [PATCH 040/145] Fix right on product list --- htdocs/product/liste.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 40e99a2d2ee..cab06a7f387 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -467,7 +467,7 @@ else } // Better buy price - if ($user->rights->produit->creer) + if ($user->rights->fournisseur->lire) { print '\n"; // Profil public From badf3794894bc81f3873fd53ec5f42b4e2751b56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 27 Oct 2014 01:56:06 +0100 Subject: [PATCH 048/145] Fix: [ bug #1618 ] PHP Error thrown when saving a barcode --- ChangeLog | 1 + htdocs/product/fiche.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a1ec979f287..c2ad4b7ecf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ English Dolibarr ChangeLog - Fix: box of customer and propsects were not correctly disabled. - Fix: right and error management #1961 - Fix: Fix Error when trying to clone an Order #1943 +- Fix: [ bug #1618 ] PHP Error thrown when saving a barcode ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 7e5b9b76c78..5498233e5b8 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -124,7 +124,7 @@ if (empty($reshook)) // Barcode value if ($action == 'setbarcode' && $createbarcode) { - $result=$object->check_barcode(GETPOST('barcode'),GETPOT('barcode_type_code')); + $result=$object->check_barcode(GETPOST('barcode'),GETPOST('barcode_type_code')); if ($result >= 0) { From d846dd24316acf8f9fc6fce9680b700a013a7de5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 27 Oct 2014 19:38:27 +0100 Subject: [PATCH 049/145] Fix extrafield from list feature where filter is provided --- htdocs/core/class/extrafields.class.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c9e5d937a18..16583c0703c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -743,15 +743,17 @@ class ExtraFields if (strpos($InfoFieldList[4], 'extra')!==false) { $sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra'; - $sqlwhere.= ' AND extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4]; + $sqlwhere.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4]; } else { - $sqlwhere.= ' AND '.$InfoFieldList[4]; + $sqlwhere.= ' WHERE '.$InfoFieldList[4]; } + }else { + $sqlwhere.= ' WHERE 1'; } if (in_array($InfoFieldList[0],array('tablewithentity'))) $sqlwhere.= ' AND entity = '.$conf->entity; // Some tables may have field, some other not. For the moment we disable it. - $sql.=preg_replace('/^ AND /','',$sqlwhere); + //$sql.=preg_replace('/^ AND /','',$sqlwhere); //print $sql; dol_syslog(get_class($this).'::showInputField type=sellist sql='.$sql); @@ -979,7 +981,10 @@ class ExtraFields { foreach ($fields_label as $field_toshow) { - $translabel=$langs->trans($obj->$field_toshow); + $translabel=''; + if (!empty($obj->$field_toshow)) { + $translabel=$langs->trans($obj->$field_toshow); + } if ($translabel!=$field_toshow) { $value.=dol_trunc($translabel,18).' '; }else { @@ -989,7 +994,10 @@ class ExtraFields } else { - $translabel=$langs->trans($obj->$InfoFieldList[1]); + $translabel=''; + if (!empty($obj->$InfoFieldList[1])) { + $translabel=$langs->trans($obj->$InfoFieldList[1]); + } if ($translabel!=$obj->$InfoFieldList[1]) { $value=dol_trunc($translabel,18); }else { From 834a6dc2af74a4fc482171a8e3c352acb7a54e10 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 28 Oct 2014 16:50:44 +0100 Subject: [PATCH 050/145] webservice Thirdparty parameter lastname for invidual creation is now lastname and not ref --- ChangeLog | 1 + htdocs/webservices/server_thirdparty.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c2ad4b7ecf1..b75afb18be0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ English Dolibarr ChangeLog - Fix: right and error management #1961 - Fix: Fix Error when trying to clone an Order #1943 - Fix: [ bug #1618 ] PHP Error thrown when saving a barcode +- Fix: webservice Thirdparty parameter lastname for invidual creation is now lastname and not ref ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index c5ac0c8c686..4a295cd3bfa 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -460,7 +460,7 @@ function createThirdParty($authentication,$thirdparty) $result=$newobject->create($fuser); if ($newobject->particulier && $result > 0) { $newobject->firstname = $thirdparty['firstname']; - $newobject->name_bis = $thirdparty['ref']; + $newobject->name_bis = $thirdparty['lastname']; $result = $newobject->create_individual($fuser); } if ($result <= 0) From c5045a75d8884fe8ce871c3836137b57793be8d5 Mon Sep 17 00:00:00 2001 From: jfefe Date: Thu, 30 Oct 2014 01:16:37 +0100 Subject: [PATCH 051/145] Missing trans key into resource module --- htdocs/langs/en_US/resource.lang | 4 +++- htdocs/langs/fr_FR/resource.lang | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/resource.lang b/htdocs/langs/en_US/resource.lang index 502d328d7c3..b17cae82f29 100755 --- a/htdocs/langs/en_US/resource.lang +++ b/htdocs/langs/en_US/resource.lang @@ -32,4 +32,6 @@ ResourceLinkedWithSuccess=Resource linked with success TitleResourceCard=Resource card ConfirmDeleteResource=Confirm to delete this resource RessourceSuccessfullyDeleted=Resource successfully deleted -DictionaryResourceType=Type of resources \ No newline at end of file +DictionaryResourceType=Type of resources + +SelectResource=Select resource diff --git a/htdocs/langs/fr_FR/resource.lang b/htdocs/langs/fr_FR/resource.lang index e4c8a6ade87..5059d628092 100755 --- a/htdocs/langs/fr_FR/resource.lang +++ b/htdocs/langs/fr_FR/resource.lang @@ -32,4 +32,6 @@ ResourceLinkedWithSuccess=Ressource liée avec succès TitleResourceCard=Fiche ressource ConfirmDeleteResource=Confirmer la suppression de cette ressource? RessourceSuccessfullyDeleted=Ressource effacée avec succès -DictionaryResourceType=Type de ressources \ No newline at end of file +DictionaryResourceType=Type de ressources + +SelectResource=Sélectionner la ressource From e370ffb2d44cdd453fde42e48e9955908f073330 Mon Sep 17 00:00:00 2001 From: jfefe Date: Thu, 30 Oct 2014 01:33:39 +0100 Subject: [PATCH 052/145] Bad function call --- htdocs/resource/class/resource.class.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/resource.class.php index 9cf6a83ef1d..d9ad13f83b1 100644 --- a/htdocs/resource/class/resource.class.php +++ b/htdocs/resource/class/resource.class.php @@ -23,8 +23,8 @@ */ // Put here all includes required by your class file -require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); - +require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"; /** * DAO Resource object @@ -330,12 +330,12 @@ class Resource extends CommonObject function delete($rowid, $notrigger=0) { global $user,$langs,$conf; - + $error=0; - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."resource"; $sql.= " WHERE rowid =".$rowid; - + dol_syslog(get_class($this)."::delete sql=".$sql); if ($this->db->query($sql)) { @@ -355,7 +355,7 @@ class Resource extends CommonObject } // End call triggers } - + return 1; } else { @@ -371,7 +371,7 @@ class Resource extends CommonObject return -1; } } - + /** * Load resource objects into $this->lines * @@ -507,9 +507,9 @@ class Resource extends CommonObject $line->fk_user_create = $obj->fk_user_create; if($obj->resource_id && $obj->resource_type) - $line->objresource = $this->fetchObjectByElement($obj->resource_id,$obj->resource_type); + $line->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type); if($obj->element_id && $obj->element_type) - $line->objelement = $this->fetchObjectByElement($obj->element_id,$obj->element_type); + $line->objelement = fetchObjectByElement($obj->element_id,$obj->element_type); $this->lines[$i] = $line; $i++; @@ -591,7 +591,7 @@ class Resource extends CommonObject $line->mandatory = $obj->mandatory; $line->fk_user_create = $obj->fk_user_create; - $this->lines[$i] = $this->fetchObjectByElement($obj->resource_id,$obj->resource_type); + $this->lines[$i] = fetchObjectByElement($obj->resource_id,$obj->resource_type); $i++; } @@ -814,7 +814,7 @@ class Resource extends CommonObject $i=0; foreach($resources as $nb => $resource) { - $this->lines[$i] = $this->fetchObjectByElement($resource['resource_id'],$resource['resource_type']); + $this->lines[$i] = fetchObjectByElement($resource['resource_id'],$resource['resource_type']); $i++; } return $i; From 106b4a669f203f2791ff1a607ca691d298e4b43d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Oct 2014 11:15:13 +0100 Subject: [PATCH 053/145] id_parent and id_children was not set. So introduce new method to return same with no risk to break current working code to address this. --- htdocs/user/class/user.class.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6f59ac5eadf..afb53bb5a5e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2220,8 +2220,6 @@ class User extends CommonObject * Reconstruit l'arborescence hierarchique des users sous la forme d'un tableau * Renvoi un tableau de tableau('id','id_parent',...) trie selon arbre et avec: * id = id du user - * id_parent = id du user parent - * id_children = tableau des id enfant * name = nom du user * fullname = nom avec chemin complet du user * fullpath = chemin complet compose des id @@ -2306,6 +2304,29 @@ class User extends CommonObject return $this->users; } + /** + * Return list of all childs users in herarchy. + * + * @return array Array of user id lower than user. This overwrite this->users. + */ + function getAllChildIds() + { + // Init this->users + $this->get_full_tree(); + + $idtoscan=$this->id; + $childids=array(); + + dol_syslog("Build childid for id = ".$idtoscan); + foreach($this->users as $id => $val) + { + //var_dump($val['fullpath']); + if (preg_match('/_'.$idtoscan.'_/', $val['fullpath'])) $childids[$val['id']]=$val['id']; + } + + return $childids; + } + /** * For user id_user and its childs available in this->users, define property fullpath and fullname * From e3041f45ee9f61dccfdfed370acbd97ce9364656 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Oct 2014 18:08:42 +0100 Subject: [PATCH 054/145] Update changelog --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index cc36bf92412..bab2b804a5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 3.5.6 compared to 3.5.5 ***** +Fix: Avoid missing class error for fetch_thirdparty method #1973 + ***** ChangeLog for 3.5.5 compared to 3.5.4 ***** Fix: Holiday module was broken. Initializaion of amount of holidays failed. Fix: [ bug #1523 ] suite bug #1334 : filtre et ordre de tri conjoints ne s'appliquent pas. From 57f49ec5d4ddcd4b30c24255eb8ac822aa110aad Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 30 Oct 2014 20:41:08 +0100 Subject: [PATCH 055/145] GPLv3 --- .../admin/adherent_type_extrafields.php | 3 +- htdocs/core/class/html.formcron.class.php | 3 +- htdocs/core/lib/invoice2.lib.php | 27 ++++++++-------- htdocs/install/mssql/functions/functions.sql | Bin 5088 -> 5010 bytes .../class/html.formresource.class.php | 29 +++++++++--------- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/htdocs/adherents/admin/adherent_type_extrafields.php b/htdocs/adherents/admin/adherent_type_extrafields.php index dca8796b681..aa5e8cfa8d9 100644 --- a/htdocs/adherents/admin/adherent_type_extrafields.php +++ b/htdocs/adherents/admin/adherent_type_extrafields.php @@ -7,7 +7,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -17,6 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index bce8d9f041e..4de88a7bfc9 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -4,7 +4,7 @@ * * 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -14,6 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * or see http://www.gnu.org/ */ /** diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index 9309d083187..fb9d8f90f70 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -2,19 +2,20 @@ /* * Copyright (C) 2009-2013 Laurent Destailleur * -* 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 . -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ /** * \file htdocs/core/lib/invoice2.lib.php diff --git a/htdocs/install/mssql/functions/functions.sql b/htdocs/install/mssql/functions/functions.sql index 93766a224064a3dc68cab3dc0878f1477af69f1d..1c2c76996dc312cc2440a2329d46530adb815d7c 100644 GIT binary patch delta 170 zcmaE$K1qE87c-;rW^QI(=6XE_1qM%sG$5JBkk3%UpaWzTGo%8c0)q`h22iAgp@6}P zK_3Xq!BCGO9jLaHK@X_D2*}oF$YIE2NCxW21M4gXir4{VxfpbTPywt8VJ4c1V%Uw` JEX{tD2LNb29=HGi delta 197 zcmbQF{y=>L7c-;LW^QI(W@T#z1%^z9G$5JBkk3%UpaW!;GZX>EN*Gds>=K6j$!nQZ zS-BW=8FVLKWD>6jsqh4H -* -* 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 . -*/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ /** * \file place/class/html.place.class.php From ccddf0d1bee301e91b65128ff757dfbe997683ae Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 31 Oct 2014 16:56:14 +0100 Subject: [PATCH 056/145] Fix : actioncomme report was not filtering by entity... --- htdocs/core/modules/action/rapport.pdf.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index d595dfe5579..ea92973101f 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -182,6 +182,7 @@ class CommActionRapport $sql.= " WHERE c.id=a.fk_action AND a.fk_user_author = u.rowid"; $sql.= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($this->year,$this->month,false))."'"; $sql.= " AND '".$this->db->idate(dol_get_last_day($this->year,$this->month,false))."'"; + $sql.= " AND a.entity = ".$conf->entity; $sql.= " ORDER BY a.datep DESC"; dol_syslog(get_class($this)."::_page sql=".$sql); From 53dfda1413069c1e8f4979a171be5a72053030fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 1 Nov 2014 19:34:20 +0100 Subject: [PATCH 057/145] Fix: Chars - is no more allowed into value for code for extra fields. --- ChangeLog | 3 ++- htdocs/core/class/extrafields.class.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index abbe486707f..28d86310494 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,7 +10,8 @@ English Dolibarr ChangeLog - Fix: box of customer and propsects were not correctly disabled. - Fix: [ bug #1618 ] PHP Error thrown when saving a barcode - Fix: Civility & birthdate wasn't save into adherent module. -- Fix: webservice Thirdparty parameter lastname for invidual creation is now lastname and not ref +- Fix: webservice Thirdparty parameter lastname for invidual creation is now lastname and not ref +- Fix: Chars - is no more allowed into value for code for extra fields. ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 16583c0703c..8ce0a1b3b45 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -154,7 +154,7 @@ class ExtraFields { $table=$elementtype.'_extrafields'; - if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname)) + if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/",$attrname) && ! is_numeric($attrname)) { if ($type=='boolean') { $typedb='int'; From 627f5694f0a71b0b7fdb6a82188d732c54d029b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Nov 2014 21:16:31 +0100 Subject: [PATCH 058/145] Fix: Infinite loop --- htdocs/core/lib/date.lib.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 48ccec88cf1..6a5024c1c80 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -563,9 +563,10 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR') $nbFerie = 0; // Check to ensure we use correct parameters - if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hour and be GMT dates'; + if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates'; - while ($timestampStart < $timestampEnd) // Loop end when equals + $i=0; + while ($timestampStart < $timestampEnd && ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop) { $ferie=false; $countryfound=0; @@ -573,7 +574,6 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR') $jour = date("d", $timestampStart); $mois = date("m", $timestampStart); $annee = date("Y", $timestampStart); - if ($countrycode == 'FR') { $countryfound=1; @@ -676,8 +676,10 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR') if ($ferie) $nbFerie++; // Increase number of days (on go up into loop) - $jour++; - $timestampStart=dol_mktime(0,0,0,$mois,$jour,$annee,1); // Generate GMT date for next day + $timestampStart=dol_time_plus_duree($timestampStart, 1, 'd'); + //var_dump($jour.' '.$mois.' '.$annee.' '.$timestampStart); + + $i++; } return $nbFerie; @@ -718,13 +720,16 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0) * @param int $inhour 0: return number of days, 1: return number of hours * @param int $lastday We include last day, 0: no, 1:yes * @param int $halfday Tag to define half day when holiday start and end + * @param string $countrycode Country code (company country code if not defined) * @return int Number of days or hours */ -function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0) +function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='') { - global $langs; + global $langs,$mysoc; - dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday); + if (empty($country_code)) $country_code=$mysoc->country_code; + + dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code); // Check parameters if (! is_int($timestampStart) && ! is_float($timestampStart)) return 'ErrorBadParameter_num_open_day'; @@ -733,7 +738,9 @@ function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $ha //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; if ($timestampStart < $timestampEnd) { - $nbOpenDay = num_between_day($timestampStart, $timestampEnd, $lastday) - num_public_holiday($timestampStart, $timestampEnd, $lastday); + $numdays = num_between_day($timestampStart, $timestampEnd, $lastday); + $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code); + $nbOpenDay = $numdays - $numholidays; $nbOpenDay.= " " . $langs->trans("Days"); if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); From ca69bf9d7eb7b611bc09f8b32faaf69531df4edb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Nov 2014 21:20:24 +0100 Subject: [PATCH 059/145] Fix: Infinite loop --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 28d86310494..25d8c7d638d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ English Dolibarr ChangeLog - Fix: Civility & birthdate wasn't save into adherent module. - Fix: webservice Thirdparty parameter lastname for invidual creation is now lastname and not ref - Fix: Chars - is no more allowed into value for code for extra fields. +( Fix: [ bug #1622 ] Requesting holiday than spans across two years cause high CPU usage by Apache ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: From d177a2fbb4b0eebb2586cc8fd562391a68ff5872 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 4 Nov 2014 16:13:51 +0100 Subject: [PATCH 060/145] fix bug on thm --- htdocs/projet/class/task.class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index c97b51e53a4..642441a27b6 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -769,7 +769,7 @@ class Task extends CommonObject if ($this->db->query($sql) ) { $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); - $ret = $tasktme_id; + $ret = $tasktime_id; if (! $notrigger) { @@ -801,10 +801,7 @@ class Task extends CommonObject dol_syslog(get_class($this)."::addTimeSpent error -2 ".$this->error, LOG_ERR); $ret = -2; } - } - - if ($ret >= 0) - { + $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; $sql.= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->timespent_fk_user.")"; $sql.= " WHERE rowid = ".$tasktime_id; From 31c38cedbc4119965d02bb2d9b844791e6f90f30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Nov 2014 16:26:11 +0100 Subject: [PATCH 061/145] Fix: checkstyle --- htdocs/core/lib/date.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 6a5024c1c80..924d3da2259 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -524,7 +524,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false) } $tmpmonth = $prev_month; $tmpyear = $prev_year; - + //Get first day of next week $tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0); $tmptime-=24*60*60*7; @@ -720,7 +720,7 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0) * @param int $inhour 0: return number of days, 1: return number of hours * @param int $lastday We include last day, 0: no, 1:yes * @param int $halfday Tag to define half day when holiday start and end - * @param string $countrycode Country code (company country code if not defined) + * @param string $country_code Country code (company country code if not defined) * @return int Number of days or hours */ function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='') From 24439eb1a31208118f7fb6150876f8d8a6c1149f Mon Sep 17 00:00:00 2001 From: Drosis Nikos Date: Fri, 7 Nov 2014 15:31:06 +0200 Subject: [PATCH 062/145] Fix : tva not coming from multiprice --- htdocs/compta/facture.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 02356e94b52..25330ba548b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1152,6 +1152,8 @@ else if ($action == 'addline' && $user->rights->facture->creer) $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; $price_min = $prod->multiprices_min[$object->client->price_level]; $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; } elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { From 92cdef71e814ef21bd1b31ed3ad06af7e6387dab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Nov 2014 14:58:43 +0100 Subject: [PATCH 063/145] Fix: Graph report rubbish information. Better to have them as option. --- htdocs/product/index.php | 2 +- htdocs/societe/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 33025dd1551..a8502498e41 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -167,7 +167,7 @@ print $total; print ''; print '
'.$langs->trans("Total").'
'.$langs->trans("Total").''.price($total)."  '; if ($objp->minsellprice != '') From 756b1d31ad24a7908a875e180ebc7a759ef31311 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Oct 2014 01:01:30 +0200 Subject: [PATCH 041/145] Add function dolEscapeXML --- htdocs/core/lib/functions.lib.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b5bac3b0ab0..c7d1546e976 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -427,6 +427,18 @@ function dol_string_nospecial($str,$newstr='_',$badchars='') return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str)); } + +/** + * Encode string for xml usage + * + * @param string $string String to encode + * @return string String encoded + */ +function dolEscapeXML($string) +{ + return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>')); +} + /** * Returns text escaped for inclusion into javascript code * @@ -3468,6 +3480,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false) } } + /** * This function is called to encode a string into a HTML string but differs from htmlentities because * all entities but &,<,> are converted. This permits to encode special chars to entities with no double From a94f7dc3ad0ca782941c5c9129828e2c32f9524d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Oct 2014 01:21:33 +0200 Subject: [PATCH 042/145] Revert "Add function dolEscapeXML" This reverts commit 756b1d31ad24a7908a875e180ebc7a759ef31311. --- htdocs/core/lib/functions.lib.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c7d1546e976..b5bac3b0ab0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -427,18 +427,6 @@ function dol_string_nospecial($str,$newstr='_',$badchars='') return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str)); } - -/** - * Encode string for xml usage - * - * @param string $string String to encode - * @return string String encoded - */ -function dolEscapeXML($string) -{ - return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>')); -} - /** * Returns text escaped for inclusion into javascript code * @@ -3480,7 +3468,6 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false) } } - /** * This function is called to encode a string into a HTML string but differs from htmlentities because * all entities but &,<,> are converted. This permits to encode special chars to entities with no double From eeffe4ed34aa28d149a1234fac2b1e5521fc8996 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 16 Oct 2014 13:57:07 +0200 Subject: [PATCH 043/145] Reload object when product clone failed (cause of ref already exists) if not done result is blanck pages (header wannot be rewrite (location herder index.php) around line 1542 --- htdocs/product/fiche.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index a73d5817b3a..7e5b9b76c78 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -422,10 +422,10 @@ if (empty($reshook)) $_error++; $action = ""; - $mesg='
'.$langs->trans("ErrorProductAlreadyExists",$object->ref); + $mesg=$langs->trans("ErrorProductAlreadyExists",$object->ref); $mesg.=' '.$langs->trans("ShowCardHere").'.'; - $mesg.='
'; setEventMessage($mesg, 'errors'); + $object->fetch($id); //dol_print_error($object->db); } else From 48b2d818dab5a7644aff19f47738976f72768027 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Oct 2014 16:29:22 +0200 Subject: [PATCH 044/145] Update changelog --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 42a8d6d6b28..a1ec979f287 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ English Dolibarr ChangeLog - Fix: bug 1588 : relative discount - Fix: label of input method not tranlated. - Fix: box of customer and propsects were not correctly disabled. +- Fix: right and error management #1961 +- Fix: Fix Error when trying to clone an Order #1943 ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: From 29db45c76330900046cb456de645357f17f6a107 Mon Sep 17 00:00:00 2001 From: jfefe Date: Thu, 23 Oct 2014 01:15:05 +0200 Subject: [PATCH 045/145] Avoid missing class error for fetch_thirdparty method --- htdocs/core/class/commonobject.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6439e3e003e..e363eda6e4a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -575,6 +575,9 @@ abstract class CommonObject global $conf; if (empty($this->socid)) return 0; + + if (!class_exists('Societe')) + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $thirdparty = new Societe($this->db); $result=$thirdparty->fetch($this->socid); From 41f0920656a8eb26ee40f48a21cbed9362897d73 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Oct 2014 23:50:10 +0200 Subject: [PATCH 046/145] Fix for debian --- build/debian/control | 8 +++++--- build/debian/copyright | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build/debian/control b/build/debian/control index fc0cee30319..164b919e066 100755 --- a/build/debian/control +++ b/build/debian/control @@ -3,7 +3,7 @@ Section: web Priority: optional Maintainer: Laurent Destailleur (eldy) # Uploaders: Laurent Destailleur (eldy) # Only if differs from Maintainer -Standards-Version: 3.9.4 +Standards-Version: 3.9.6 Homepage: http://www.dolibarr.org Build-Depends: debhelper (>= 9), po-debconf # This package need at least debian 7 or ubuntu 13.04 or any distribution based on this version @@ -16,7 +16,8 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | php5-mysql | php5-mysqli, php5-curl, php5-gd, php5-ldap, php5-geoip, # Required PHP libraries php-pear, php-mail-mime, -# php-tcpdf, libfpdi-php, libfpdf-tpl-php, php-fpdf, +# php-tcpdf, libfpdi-php, +# libfpdf-tpl-php, php-fpdf, # libphp-adodb, # libnusoap-php, # libphp-pclzip, @@ -26,9 +27,10 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | # fonts-dejavu-core | ttf-dejavu-core, xdg-utils, mysql-server, + mysql-client, ${misc:Depends}, ${perl:Depends} -Recommends: mysql-client, apache2 | lighttpd | httpd +Recommends: apache2 | lighttpd | httpd Suggests: www-browser Description: Web based software to manage a company or foundation Dolibarr ERP & CRM is an easy to use open source/free software for small diff --git a/build/debian/copyright b/build/debian/copyright index 73109152034..080965c31a3 100644 --- a/build/debian/copyright +++ b/build/debian/copyright @@ -1,7 +1,7 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Dolibarr Upstream-Contact: Laurent Destailleur -Source: http://sourceforge.net/projects/dolibarr/files/ +Source: http://www.dolibarr.org/files/stable/standard/ Files: * Copyright: 2002-2009, Rodolphe Quiedeville From 1405c03f7d78dc6b65d8c1880dcfde2900cf0d6d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 26 Oct 2014 06:48:08 +0100 Subject: [PATCH 047/145] Fix: Civility & birthdate wasn't save into adherent module --- ChangeLog | 11 ++++++----- htdocs/adherents/class/adherent.class.php | 13 +++++++------ htdocs/adherents/fiche.php | 5 +++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1ec979f287..cc1c3c0de2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,17 +4,18 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** -- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice -- Fix: bug 1588 : relative discount +- Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. +- Fix: bug 1588 : relative discount. - Fix: label of input method not tranlated. - Fix: box of customer and propsects were not correctly disabled. -- Fix: right and error management #1961 -- Fix: Fix Error when trying to clone an Order #1943 +- Fix: right and error management #1961. +- Fix: Fix Error when trying to clone an Order #1943. +- Fix: Civility & birthdate wasn't save into adherent module. ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: - Fix: Can upload files on services. -- Fix: sql errors on updat fichinter. +- Fix: sql errors on update fichinter. - Fix: debian script syntax error. - Fix: error "menu param is not inside list" into pos module. - Fix: Salary payments are not reflected on the reporting sheets. diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 04056e0bbb0..0fa60a0d421 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2014 Alexandre Spangaro * * 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 @@ -124,7 +125,7 @@ class Adherent extends CommonObject /** - * Fonction envoyant un email a l'adherent avec le texte fourni en parametre. + * Function sending an email has the adherent with the text supplied in parameter. * * @param string $text Content of message (not html entities encoded) * @param string $subject Subject of message @@ -247,9 +248,9 @@ class Adherent extends CommonObject /** - * Renvoie le libelle traduit de la nature d'un adherent (physique ou morale) + * Return translated label by the nature of a adherent (physical or moral) * - * @param string $morphy Nature physique ou morale de l'adherent + * @param string $morphy Nature of the adherent (physical or moral) * @return string Label */ function getmorphylib($morphy='') @@ -348,12 +349,12 @@ class Adherent extends CommonObject if (! $notrigger) { - // Appel des triggers + // Call triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); $result=$interface->run_triggers('MEMBER_CREATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers + // End call triggers } if (count($this->errors)) @@ -1101,7 +1102,7 @@ class Adherent extends CommonObject $this->ref = $obj->rowid; $this->id = $obj->rowid; $this->ref_ext = $obj->ref_ext; - $this->civility_id = $obj->civility; + $this->civility_id = $obj->civility_id; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; $this->login = $obj->login; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index cd398c75859..ef04edeeb53 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Marcos García * Copyright (C) 2012-2013 Philippe Grand + * Copyright (C) 2014 Alexandre Spangaro * * 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 @@ -707,7 +708,7 @@ else { /* ************************************************************************** */ /* */ - /* Fiche creation */ + /* Creation card */ /* */ /* ************************************************************************** */ $object->canvas=$canvas; @@ -870,7 +871,7 @@ else // Birthday print "
".$langs->trans("Birthday")."\n"; - $form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc'); + $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc'); print "
'; -if (! empty($conf->categorie->enabled)) +if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_PRODUCTS)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; print '
'; diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 3cf38a58b90..84fc4326fe4 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -159,7 +159,7 @@ print $total; print ''; print ''; -if (! empty($conf->categorie->enabled)) +if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $elementtype = 'societe'; From 7ed496d7d9e64664fa502dfa8bd6072599665702 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 12 Nov 2014 17:51:26 +0100 Subject: [PATCH 064/145] FIX: copy extrafields when creating order from propale and creating invoice from order --- htdocs/commande/class/commande.class.php | 12 +++++++++++- htdocs/compta/facture/class/facture.class.php | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7a8fd63c8f1..d1a776d3d24 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -972,7 +972,12 @@ class Commande extends CommonOrder $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; - $this->lines[$i] = $line; + // get extrafields from original line + $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + foreach($object->lines[$i]->array_options as $options_key => $value) + $line->array_options[$options_key] = $value; + + $this->lines[$i] = $line; } $this->socid = $object->socid; @@ -991,6 +996,11 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; + // get extrafields from original line + $object->fetch_optionals($object->id); + foreach($object->array_options as $options_key => $value) + $this->array_options[$options_key] = $value; + // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 93e245746a0..0d91d7944b8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -701,6 +701,11 @@ class Facture extends CommonInvoice $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $line->pa_ht = $marginInfos[0]; + // get extrafields from original line + $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + foreach($object->lines[$i]->array_options as $options_key => $value) + $line->array_options[$options_key] = $value; + $this->lines[$i] = $line; } @@ -720,6 +725,11 @@ class Facture extends CommonInvoice $this->origin = $object->element; $this->origin_id = $object->id; + // get extrafields from original line + $object->fetch_optionals($object->id); + foreach($object->array_options as $options_key => $value) + $this->array_options[$options_key] = $value; + // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) From c0a3606a595fa21a015ef262ce98fd0e32453412 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 12 Nov 2014 22:53:23 +0100 Subject: [PATCH 065/145] Fix problem on task creation with chrome for french browser. --- htdocs/core/lib/functions.lib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e238b1e5834..d679882161f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1053,7 +1053,11 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) $default_timezone=@date_default_timezone_get(); } } - else $localtz = new DateTimeZone('UTC'); + + if (empty($localtz)) { + $localtz = new DateTimeZone('UTC'); + } + $dt = new DateTime(null,$localtz); $dt->setDate($year,$month,$day); $dt->setTime((int) $hour, (int) $minute, (int) $second); From 00c6033e11b35d5f004fddacd82f3f3464d1ea9e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 14 Nov 2014 13:28:49 +0100 Subject: [PATCH 066/145] Fix display user signature when WYSIWYG is enabled --- htdocs/user/fiche.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index a0523bcbc28..9b1845d6bff 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -1208,7 +1208,11 @@ else // Signature print ''.$langs->trans('Signature').''; - print dol_htmlentitiesbr($object->signature); + if (empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)) { + print dol_htmlentitiesbr($object->signature); + } else { + print $object->signature; + } print "\n"; // Hierarchy From 01279edfc82213a4b875d709c5e452a44bfc791f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 16 Nov 2014 16:36:32 +0100 Subject: [PATCH 067/145] Fixed: [ bug #1570 ] Negative supplier invoices do not appear in bank planned transactions. --- htdocs/compta/bank/treso.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index f6c59530605..b9274c34eb5 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -164,7 +164,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " ORDER BY dlr ASC"; // Supplier invoices - $sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref_supplier as ref, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; + $sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.ref as ref, ff.ref_supplier as ref_supplier, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; $sql2.= " s.rowid as socid, s.nom, s.fournisseur"; $sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; @@ -260,12 +260,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) if ($obj->family == 'invoice_supplier') { - // TODO This code is to avoid to count suppliers credit note (ff.type = 2) - // Ajouter gestion des avoirs fournisseurs, champ - if (($obj->total_ttc < 0 && $obj->type != 2) - || ($obj->total_ttc > 0 && $obj->type == 2)) + $showline=1; + // Uncomment this line to avoid to count suppliers credit note (ff.type = 2) + //$showline=(($obj->total_ttc < 0 && $obj->type != 2) || ($obj->total_ttc > 0 && $obj->type == 2)) + if ($showline) { - $facturefournstatic->ref=$obj->ref; + $ref=$obj->ref; + $facturefournstatic->ref=$ref; $facturefournstatic->id=$obj->objid; $facturefournstatic->type=$obj->type; $ref = $facturefournstatic->getNomUrl(1,''); @@ -304,7 +305,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) if ($paiement) $total_ttc = $obj->total_ttc - $paiement; $solde += $total_ttc; - // We discard with a remain to pay to 0 + // We discard lines with a remainder to pay to 0 if (price2num($total_ttc) != 0) { $var=!$var; From d0dc792b3cd829c6ef86fa555f880ed8400d3deb Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 17 Nov 2014 11:17:45 +0100 Subject: [PATCH 068/145] check extrafields before inserting in DB --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e363eda6e4a..5af3f5a93c3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2195,7 +2195,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut - if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + if (isset($extrafields->attribute_type[$attributeKey]) && $extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; @@ -2203,7 +2203,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field o fattribut - if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + if(isset($extrafields->attribute_type[$attributeKey]) && $extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) { if ($this->array_options[$key] != '') { From 1b24356e0f9b7b4cfd8a19464096c788d2cc2560 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Nov 2014 17:13:08 +0100 Subject: [PATCH 069/145] ssl option is set to CURL_SSLVERSION_TLSv1. Some site disabled ssl v1 to 3 (ex: paypal). --- htdocs/paypal/lib/paypal.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 02a16c68b1f..7b161ac30be 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -683,7 +683,8 @@ function hash_call($methodName,$nvpStr) exit;*/ curl_setopt($ch, CURLOPT_URL, $API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); - curl_setopt($ch, CURLOPT_SSLVERSION, 3); // Force SSLv3 + //curl_setopt($ch, CURLOPT_SSLVERSION, 3); // Force SSLv3 + curl_setopt($ch, CURLOPT_SSLVERSION, 1); // Force TLSv1 //turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); From 3dacdf4e4a5ff54dc7a57a262d95465fc4580569 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Wed, 19 Nov 2014 09:41:21 +0100 Subject: [PATCH 070/145] Fix: Conflicts and remove duplicate code --- htdocs/core/class/commonobject.class.php | 4 +--- htdocs/product/class/product.class.php | 8 +------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b5aac7adc74..72eeba4d59f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2011-2014 Philippe Grand * Copyright (C) 2012 Marcos García @@ -611,8 +611,6 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdparty = new Societe($this->db); $result=$thirdparty->fetch(isset($this->socid)?$this->socid:$this->fk_soc); $this->client = $thirdparty; // deprecated diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1faa192bd0d..2987d0de8fd 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4,16 +4,10 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007-2011 Jean Heimburger -<<<<<<< HEAD * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2013-2014 Cedric GROSS - * Copyright (C) 2013 Marcos García - * Copyright (C) 2011-2014 Alexandre Spangaro -======= - * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2013 Cedric GROSS * Copyright (C) 2013-2014 Marcos García ->>>>>>> refs/remotes/origin/3.5 + * Copyright (C) 2011-2014 Alexandre Spangaro * * 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 From 7d8cf99d58a61603ae52cc4cf429b505ba9e79d8 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 19 Nov 2014 18:19:27 +0100 Subject: [PATCH 071/145] FIX: bad margin and buy_price calculation when total_ht = 0 (discount 100%) on a line --- htdocs/margin/agentMargins.php | 4 ++-- htdocs/margin/customerMargins.php | 4 ++-- htdocs/margin/productMargins.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 51166bc472b..40a617daecd 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -109,8 +109,8 @@ $sql = "SELECT"; if ($agentid > 0) $sql.= " s.rowid as socid, s.nom, s.code_client, s.client,"; $sql.= " u.rowid as agent, u.login, u.lastname, u.firstname,"; $sql.= " sum(d.total_ht) as selling_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht <=0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht <=0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge" ; +$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; +$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge" ; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 6675753d4d6..77a50189b1b 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -164,8 +164,8 @@ $sql = "SELECT"; $sql.= " s.rowid as socid, s.nom, s.code_client, s.client,"; if ($client) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; $sql.= " sum(d.total_ht) as selling_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht <=0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht <=0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; +$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; +$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index a394b42686e..b8d5f7f66ba 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -167,8 +167,8 @@ $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref,"; if ($id > 0) $sql.= " d.fk_product,"; if ($id > 0) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; $sql.= " sum(d.total_ht) as selling_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht <=0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht <=0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; +$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; +$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; From fdac53bfca37b034a8decfb4f0e568cbc93a5b27 Mon Sep 17 00:00:00 2001 From: BENKE Charles Date: Wed, 19 Nov 2014 18:53:33 +0100 Subject: [PATCH 072/145] Update objectline_create.tpl.php add label tags for product mode type --- htdocs/core/tpl/objectline_create.tpl.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index a51a6505416..6e9b3251fbd 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -107,7 +107,9 @@ else { print ''; } else {*/ + echo ''; /* if (empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans("Type"); else if (! empty($forceall) || (! empty($conf->product->enabled) && ! empty($conf->service->enabled))) echo $langs->trans("FreeLineOfType"); @@ -123,7 +125,7 @@ else { { echo '
'; echo ' '; - + echo ''; echo ' '; $filtertype=''; From 891f8d9442d5532dba9a3440c8028caf31ff02c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 22 Nov 2014 19:02:15 +0100 Subject: [PATCH 073/145] Fix bug 1692 Can't update phone_pro with the contact webservice --- htdocs/webservices/server_contact.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index 126e4202018..1d7336e1482 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -655,6 +655,7 @@ function updateContact($authentication,$contact) $object->province_id=$contact['province_id']; + $object->phone_pro=$contact['phone_pro']; $object->phone_perso=$contact['phone_perso']; $object->phone_mobile=$contact['phone_mobile']; $object->fax=$contact['fax']; From 7a272afd120029ba06d00ff6d56d7a8e129cbb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 23 Nov 2014 16:03:49 +0100 Subject: [PATCH 074/145] Fixed [ bug #1595 ] Selected boolean extrafield in intervention creation page, does not save state --- ChangeLog | 3 ++- htdocs/fichinter/fiche.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 99b29a81f56..34dd86aa02e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,8 @@ English Dolibarr ChangeLog - Fix: Civility & birthdate wasn't save into adherent module. - Fix: webservice Thirdparty parameter lastname for invidual creation is now lastname and not ref - Fix: Chars - is no more allowed into value for code for extra fields. -( Fix: [ bug #1622 ] Requesting holiday than spans across two years cause high CPU usage by Apache +- Fix: [ bug #1622 ] Requesting holiday than spans across two years cause high CPU usage by Apache +- Fix: [ bug #1595 ] Selected boolean extrafield in intervention creation page, does not save state ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 944dbae6b45..9be7d67115e 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -152,6 +152,11 @@ else if ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->fich else if ($action == 'add' && $user->rights->ficheinter->creer) { + // Fill array 'array_options' with data from add form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error ++; + $object->socid = $socid; $object->duree = GETPOST('duree','int'); $object->fk_project = GETPOST('projectid','int'); From 18406fc550d68bb5e851e242b6f928327bbe1a20 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 25 Nov 2014 14:26:45 +0100 Subject: [PATCH 075/145] Fix: Show sender Country on PDF docs Show sender Country on PDF docs when sender Country != receiver Country --- ChangeLog | 1 + htdocs/core/lib/functions.lib.php | 9 +++++---- htdocs/core/lib/pdf.lib.php | 5 ++++- .../core/modules/commande/doc/pdf_einstein.modules.php | 2 +- .../core/modules/commande/doc/pdf_proforma.modules.php | 2 +- htdocs/core/modules/contract/doc/pdf_strato.modules.php | 2 +- htdocs/core/modules/expedition/doc/pdf_merou.modules.php | 2 +- .../core/modules/expedition/doc/pdf_rouget.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php | 2 +- htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- .../modules/supplier_invoice/pdf/pdf_canelle.modules.php | 2 +- .../modules/supplier_order/pdf/pdf_muscadet.modules.php | 2 +- 14 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34dd86aa02e..05f46019350 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ English Dolibarr ChangeLog - Fix: Chars - is no more allowed into value for code for extra fields. - Fix: [ bug #1622 ] Requesting holiday than spans across two years cause high CPU usage by Apache - Fix: [ bug #1595 ] Selected boolean extrafield in intervention creation page, does not save state +- Fix: Show sender Country on PDF docs when sender Country <> receiver Country ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d679882161f..f6f09dd1567 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -719,11 +719,12 @@ function dol_bc($var,$moreclass='') * @param Object $object A company or contact object * @param int $withcountry 1=Add country into address string * @param string $sep Separator to use to build string + * @param Tranlsate $outputlangs Object lang that contains language for text translation. * @return string Formated string */ -function dol_format_address($object,$withcountry=0,$sep="\n") +function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='') { - global $conf; + global $conf,$langs; $ret=''; $countriesusingstate=array('AU','US','IN','GB','ES','UK','TR'); @@ -768,8 +769,8 @@ function dol_format_address($object,$withcountry=0,$sep="\n") $ret.=", ".$object->state; } } - - if ($withcountry) $ret.=($object->country?$sep.$object->country:''); + if (! is_object($outputlangs)) $outputlangs=$langs; + if ($withcountry) $ret.=($object->country_code?$sep.$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); return $ret; } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 17c1185e2e0..8b0091a6f6d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -309,7 +309,10 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target if ($mode == 'source') { - $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany))."\n"; + $withCountry = 0; + if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; + + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) { diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index b3dd27a8a7a..2f569f1e47f 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1177,7 +1177,7 @@ class pdf_einstein extends ModelePDFCommandes if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index 49e3c374752..cf5a562e2ef 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -1134,7 +1134,7 @@ class pdf_proforma extends ModelePDFCommandes if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 238f51e78cd..88645973f6c 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -520,7 +520,7 @@ class pdf_strato extends ModelePDFContract $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 14bc79bf935..cc9d884a831 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -516,7 +516,7 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetTextColor(0,0,0); // Sender properties - $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); $pdf->SetFont('','', $default_font_size - 3); $pdf->SetXY($blSocX,$blSocY+4); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 37e3f8b911f..eedc4b91827 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -564,7 +564,7 @@ class pdf_rouget extends ModelePdfExpedition $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posx=$this->marge_gauche; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 6b66d9d2df3..e8ea460fb9b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1363,7 +1363,7 @@ class pdf_crabe extends ModelePDFFactures if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index c94cd154251..2c8214457e2 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -505,7 +505,7 @@ class pdf_soleil extends ModelePDFFicheinter $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index 3aae0e5a18e..ba58279c8ec 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -749,7 +749,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 29fea0d9c1a..d7d4b3150cf 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1269,7 +1269,7 @@ class pdf_azur extends ModelePDFPropales $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index d3cf60295f6..4124d4745f6 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -961,7 +961,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 78a33f76a29..83d1aac952b 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -1005,7 +1005,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); // Show sender $posy=42; From b1a4b8e7d0aa8ff376e5dbfcf89260eb6e189d62 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 25 Nov 2014 21:20:13 +0100 Subject: [PATCH 076/145] Fix: [ bug #1624 ] POS set buy price for margin Use lowest buying price for margin when selling with POS or external module. A POS user does not worry about suppliers. --- ChangeLog | 1 + htdocs/comm/propal/class/propal.class.php | 20 +++++++++++++++++-- htdocs/commande/class/commande.class.php | 20 +++++++++++++++++-- htdocs/compta/facture/class/facture.class.php | 18 ++++++++++++++++- 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05f46019350..bae7da7ce64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ English Dolibarr ChangeLog - Fix: [ bug #1622 ] Requesting holiday than spans across two years cause high CPU usage by Apache - Fix: [ bug #1595 ] Selected boolean extrafield in intervention creation page, does not save state - Fix: Show sender Country on PDF docs when sender Country <> receiver Country +- Fix: [ bug #1624 ] Use lowest buying price for margin when selling with POS ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 363776c7e6f..846bb5acb10 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -413,7 +413,15 @@ class Propal extends CommonObject // infos marge - $this->line->fk_fournprice = $fk_fournprice; + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } $this->line->pa_ht = $pa_ht; // Mise en option de la ligne @@ -565,7 +573,15 @@ class Propal extends CommonObject $this->line->skip_update_total = $skip_update_total; // infos marge - $this->line->fk_fournprice = $fk_fournprice; + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } $this->line->pa_ht = $pa_ht; $this->line->date_start=$date_start; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 001a4972dd7..8501f04e8b8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1214,7 +1214,15 @@ class Commande extends CommonOrder $this->line->date_end=$date_end; // infos marge - $this->line->fk_fournprice = $fk_fournprice; + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } $this->line->pa_ht = $pa_ht; // TODO Ne plus utiliser @@ -2421,7 +2429,15 @@ class Commande extends CommonOrder $this->line->skip_update_total=$skip_update_total; // infos marge - $this->line->fk_fournprice = $fk_fournprice; + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + //by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } $this->line->pa_ht = $pa_ht; // TODO deprecated diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6def5560deb..1df0696486c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2213,7 +2213,15 @@ class Facture extends CommonInvoice $this->line->skip_update_total = $skip_update_total; // infos marge - $this->line->fk_fournprice = $fk_fournprice; + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // POS or external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } $this->line->pa_ht = $pa_ht; if (is_array($array_option) && count($array_option)>0) { @@ -3477,6 +3485,14 @@ class FactureLigne extends CommonInvoiceLine return -1; } } + + // POS or by external module, take lowest buying price + if (!empty($this->fk_product) && empty($this->fk_fournprice) && empty($this->pa_ht)) { + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($this->fk_product); + $this->fk_fournprice = $productFournisseur->product_fourn_price_id; + } $this->db->begin(); From a81c4830613a12700d6cb907312fa28068858db4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Nov 2014 02:14:25 +0100 Subject: [PATCH 077/145] Revert "Update objectline_create.tpl.php" This reverts commit fdac53bfca37b034a8decfb4f0e568cbc93a5b27. --- htdocs/core/tpl/objectline_create.tpl.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 6e9b3251fbd..a51a6505416 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -107,9 +107,7 @@ else { print ''; } else {*/ - echo ''; /* if (empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans("Type"); else if (! empty($forceall) || (! empty($conf->product->enabled) && ! empty($conf->service->enabled))) echo $langs->trans("FreeLineOfType"); @@ -125,7 +123,7 @@ else { { echo '
'; echo ' '; - echo ''; echo ' '; $filtertype=''; From f6ab7ca0c96f69822f10c5173eb71d062294f6bb Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 2 Dec 2014 20:42:47 +0100 Subject: [PATCH 078/145] Typo --- htdocs/admin/ihm.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index fe375d7668c..358bf486607 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -117,7 +117,7 @@ if ($action == 'edit') // Edit print_fiche_titre($langs->trans("Language"),'','').'
'; print ''; - print ''; + print ''; print ''; print ''; @@ -159,7 +159,7 @@ if ($action == 'edit') // Edit // Other print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameters").''.$langs->trans("Value").' 
'; - print ''; + print ''; print ''; print ''; @@ -283,7 +283,7 @@ else // Show // Language print_fiche_titre($langs->trans("Language"),'','').'
'; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameters").''.$langs->trans("Value").' 
'; - print ''; + print ''; $var=!$var; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'.$langs->trans("Parameters").''.$langs->trans("Value").' 
'.$langs->trans("DefaultLanguage").''; @@ -327,7 +327,7 @@ else // Show // Other $var=true; print ''; - print ''; + print ''; $var=!$var; print ''; From 5a05d4a4b8efa4d546e84970b491267f0649585f Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 2 Dec 2014 20:59:00 +0100 Subject: [PATCH 079/145] Untranslatable token Calendar in datepicker --- htdocs/core/datepicker.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index 7e0333bc5aa..67af3c7e083 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -39,6 +39,7 @@ require_once '../main.inc.php'; if (GETPOST('lang')) $langs->setDefaultLang(GETPOST('lang')); // If language was forced on URL by the main.inc.php $langs->load("main"); +$langs->load("agenda"); $right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); $left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); @@ -57,7 +58,7 @@ if (GETPOST('mode') && GETPOST('mode') == 'test') } else { - print 'Calendar'; + print ''.$langs->trans("Calendar").''; } // Define tradMonths javascript array (we define this in datapicker AND in parent page to avoid errors with IE8) From 477aeecdac467663a3fbe42aaa5cdf27130b17e5 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 2 Dec 2014 22:30:40 +0100 Subject: [PATCH 080/145] #1725 Missing table cells in services list header --- htdocs/product/liste.php | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index cab06a7f387..44a6a69da2e 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -324,12 +324,16 @@ else print ''; + + // Barcode if (! empty($conf->barcode->enabled)) { print ''; } + + // Date modification print ''; @@ -363,16 +367,7 @@ else print ''; - //desiredstock - print ''; - } - else - { - print ''; + // Desired stock print ''; @@ -501,15 +496,6 @@ else print $product_static->stock_reel; print ''; } - else - { - print ''; - print ''; - } } // Status (to buy) From 9e1b0d1abceeaebd96cfeac2c623dd16cec10eeb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Dec 2014 15:09:47 +0100 Subject: [PATCH 081/145] Prepare 3.5.6 --- ChangeLog | 8 ++++++++ build/debian/changelog | 7 +++++++ build/exe/doliwamp/doliwamp.iss | 4 ++-- build/makepack-howto.txt | 1 - build/rpm/dolibarr_fedora.spec | 3 +++ build/rpm/dolibarr_generic.spec | 3 +++ build/rpm/dolibarr_mandriva.spec | 3 +++ build/rpm/dolibarr_opensuse.spec | 3 +++ htdocs/filefunc.inc.php | 2 +- 9 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index bab2b804a5c..7a65eef7fc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,14 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 +Fix: Can't update phone_pro from web service +Fix: Some security holes. +Fix: copy extrafields when creating order from proposal. +Fix: report on action was not filtering by environment. +Fix: Avoid missing class error. +Fix: Add function dolEscapeXML. +Fix: Bad days and month reported by function. +Fix: Bad margin calculation. ***** ChangeLog for 3.5.5 compared to 3.5.4 ***** Fix: Holiday module was broken. Initializaion of amount of holidays failed. diff --git a/build/debian/changelog b/build/debian/changelog index aeba0dfa190..e1f40514d9a 100644 --- a/build/debian/changelog +++ b/build/debian/changelog @@ -1,3 +1,10 @@ +dolibarr (3.5.6-3) unstable; urgency=low + + [ Laurent Destailleur (eldy) ] + * New upstream release. + + -- Laurent Destailleur (eldy) Tue, 2 Dec 2014 12:00:00 +0100 + dolibarr (3.5.5-3) unstable; urgency=low [ Laurent Destailleur (eldy) ] diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 5ff4e7770b0..f06ec591712 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -17,9 +17,9 @@ ; ----- Change this ----- AppName=DoliWamp ; DoliWamp-x.x.x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x -AppVerName=DoliWamp-3.5.5 +AppVerName=DoliWamp-3.5.6 ; DoliWamp-x.x x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x -OutputBaseFilename=DoliWamp-3.5.5 +OutputBaseFilename=DoliWamp-3.5.6 ; ----- End of change ;OutputManifestFile=build\doliwampbuild.log ; Define full path from which all relative path are defined diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index 7ab0da72138..24e5f809185 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -13,7 +13,6 @@ beta version of Dolibarr, step by step. - Update version number with x.y.z-w in build/debian/changelog - Update version number with x.y.z-w in build/exe/doliwamp/doliwamp.iss - Update version number with x.y.z-w in build/rpm/*.spec -- Update version number with x.y in build/doxygen/dolibarr-doxygen.doxyfile - Commit all changes. - Add a Tag (x.y.betaz_YYYYMMDD) and push it: git push --tags - Create a branch (x.y). diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 92b097801b4..242d19239a5 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -331,6 +331,9 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog +* Tue Dec 2 2014 Laurent Destailleur 3.5.6-0.3 +- Upstream release + * Tue Jul 8 2014 Laurent Destailleur 3.5.5-0.3 - Upstream release diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index b2b7e745b34..d8e8349f9fb 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -567,6 +567,9 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog +* Tue Dec 2 2014 Laurent Destailleur 3.5.6-0.3 +- Upstream release + * Tue Jul 8 2014 Laurent Destailleur 3.5.5-0.3 - Upstream release diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 658601980f7..9238530a308 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -336,6 +336,9 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog +* Tue Dec 2 2014 Laurent Destailleur 3.5.6-0.3 +- Upstream release + * Tue Jul 8 2014 Laurent Destailleur 3.5.5-0.3 - Upstream release diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index d11630c3bb9..94ce0e7e549 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -347,6 +347,9 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog +* Tue Dec 2 2014 Laurent Destailleur 3.5.6-0.3 +- Upstream release + * Tue Jul 8 2014 Laurent Destailleur 3.5.5-0.3 - Upstream release diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 95916901c6d..9705eee2028 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -29,7 +29,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.5.5'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.5.6'); if (! defined('EURO')) define('EURO',chr(128)); // Define syslog constants From aaf2cca45f3488a81ffd713e148ea9c3572efaf8 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 27 Oct 2014 19:31:42 +0100 Subject: [PATCH 082/145] Fix bug n sellist extrafield filtered --- htdocs/core/class/extrafields.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 451598a5830..228fef11d10 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -727,11 +727,11 @@ class ExtraFields if (strpos($InfoFieldList[4], 'extra')!==false) { $sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra'; - $sqlwhere.= ' AND extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4]; + $sqlwhere.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4]; } else { - $sqlwhere.= ' AND '.$InfoFieldList[4]; + $sqlwhere.= ' WHERE '.$InfoFieldList[4]; } } if (in_array($InfoFieldList[0],array('tablewithentity'))) $sqlwhere.= ' AND entity = '.$conf->entity; // Some tables may have field, some other not. For the moment we disable it. From bd8b393d8a8e383e6345488be2836e61d7e1004c Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 5 Dec 2014 21:24:16 +0100 Subject: [PATCH 083/145] Fix [ bug #1740 ] Clone project make task date crazy --- htdocs/projet/class/task.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 4f883e1b743..68b6c867442 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1007,7 +1007,8 @@ class Task extends CommonObject $error=0; - $now=dol_now(); + //Use 00:00 of today if time is use on task. + $now=dol_mktime(0,0,0,dol_print_date(dol_now(),'%m'),dol_print_date(dol_now(),'%d'),dol_print_date(dol_now(),'%Y')); $datec = $now; From 146107280160f090dfd7fb1cdf8c37996ae3f7f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 Dec 2014 01:12:52 +0100 Subject: [PATCH 084/145] Fix: Paypal link were broken dur to SSL v3 closed. --- ChangeLog | 2 ++ htdocs/paypal/lib/paypal.lib.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7a65eef7fc9..949492346b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 3.5.7 compared to 3.5.6 ***** +Fix: Paypal link were broken dur to SSL v3 closed. ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 31ed9b97ff8..3d9dcf16d02 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -683,7 +683,8 @@ function hash_call($methodName,$nvpStr) exit;*/ curl_setopt($ch, CURLOPT_URL, $API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); - curl_setopt($ch, CURLOPT_SSLVERSION, 3); // Force SSLv3 + //curl_setopt($ch, CURLOPT_SSLVERSION, 3); // Force SSLv3 + curl_setopt($ch, CURLOPT_SSLVERSION, 1); // Force TLSv1 //turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); From 666e66e78f54ca45ed926f20e41fe442c20289d3 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 9 Dec 2014 05:04:12 +0100 Subject: [PATCH 085/145] Correct link in activity box --- htdocs/core/boxes/box_activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index bddeb4b957e..8e0bd6a8a21 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -114,7 +114,7 @@ class box_activity extends ModeleBoxes $billurl="viewstatut=2&paye=1&year=".$objp->annee; $this->info_box_contents[$i][2] = array('td' => 'align="right"', - 'text' => $objp->nb, 'url' => DOL_URL_ROOT."/compta/facture/liste.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills" + 'text' => $objp->nb, 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills" ); $this->info_box_contents[$i][3] = array('td' => 'align="right"', From 81dc1415deabd45c2c3da2f4376d841c825166f4 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 9 Dec 2014 05:04:39 +0100 Subject: [PATCH 086/145] Untranslatable token in activity box --- htdocs/core/class/html.formother.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 5150f2d4e41..c54991af434 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1017,6 +1017,7 @@ class FormOther if ($nbboxactivated) { $langs->load("boxes"); + $langs->load("projects"); $emptybox=new ModeleBoxes($db); From a1bba472a03e146975fd932a1c91490cdddcf57d Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 12 Dec 2014 11:57:20 +0100 Subject: [PATCH 087/145] FIX: hook insertExtraFields must return a returnvalue (0,1,-1) --- htdocs/core/class/hookmanager.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 849b6bb0370..2a54354aedf 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -131,6 +131,7 @@ class HookManager // Define type of hook ('output', 'returnvalue' or 'addreplace'). 'addreplace' should be type for all hooks. 'output' and 'returnvalue' are deprecated. $hooktype='output'; if (preg_match('/^pdf_/',$method)) $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are returnvalue hooks. When there is 2 hooks of this type, only last one win. + if ($method =='insertExtraFields') $hooktype='returnvalue'; if (in_array( $method, array( From 27b47a4f4836f4bbb49898187a1be06d9ca00841 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 12 Dec 2014 14:31:36 +0100 Subject: [PATCH 088/145] FIX: dont put a mess with date and datetime extrafield value if already in right format (the bug was in propale/order/invoice extrafields, mainly visible with 2 datetime extrafields) --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5af3f5a93c3..3b7623f43ca 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2178,10 +2178,10 @@ abstract class CommonObject $this->array_options[$key] = price2num($this->array_options[$key]); break; case 'date': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + if (is_numeric($this->array_options[$key])) $this->array_options[$key]=$this->db->idate($this->array_options[$key]); break; case 'datetime': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + if (is_numeric($this->array_options[$key])) $this->array_options[$key]=$this->db->idate($this->array_options[$key]); break; } } From a4a1a991b85b88e418740837bcf4b0f5e0a846a1 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 15 Dec 2014 14:13:57 +0100 Subject: [PATCH 089/145] FIX: avoid milestones in margin calculation --- htdocs/margin/agentMargins.php | 1 + htdocs/margin/customerMargins.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 51166bc472b..30adf727318 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -119,6 +119,7 @@ $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND sc.fk_soc = f.fk_soc"; +$sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; if (! empty($conf->global->AGENT_CONTACT_TYPE)) $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))"; else diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 6675753d4d6..38691d4f43b 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -173,6 +173,7 @@ $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut > 0"; $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND d.fk_facture = f.rowid"; +$sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; if ($client) $sql.= " AND f.fk_soc = ".$socid; if (!empty($startdate)) From c9f69279c7ca0eca48e436e48f0e5570c4738305 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 16 Dec 2014 16:21:31 +0100 Subject: [PATCH 090/145] FIX: pagebreak on fichinter like in other documents --- .../fichinter/doc/pdf_soleil.modules.php | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 6a0feda2e9d..ad5516f2bf6 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -255,19 +255,44 @@ class pdf_soleil extends ModelePDFFicheinter $txt=''.dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true)." - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration),1,$outputlangs->charset_output).''; $desc=dol_htmlentitiesbr($objectligne->desc,1); - $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0); - + $pdf->startTransaction(); + $pdf->writeHTMLCell(0, 0, $curX, $curY, $txt.'
'.$desc, LR, 1, 0); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->writeHTMLCell(0, 0, $curX, $curY, $txt.'
'.$desc, LR, 1, 0); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + $pdf->setPage($pageposafter+1); + } + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - + // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut // Detect if some page were added automatically and output _tableau for past pages From c209d168818d489fb6689a6f0cf41b95a2c79f5a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 18 Dec 2014 15:42:28 +0100 Subject: [PATCH 091/145] [ bug #1749 ] Undefined $mailchimp --- ChangeLog | 1 + htdocs/projet/element.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e6c6ecf1c7d..bbede2377ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ English Dolibarr ChangeLog - Fix: [ bug #1595 ] Selected boolean extrafield in intervention creation page, does not save state - Fix: Show sender Country on PDF docs when sender Country <> receiver Country - Fix: [ bug #1624 ] Use lowest buying price for margin when selling with POS +- Fix: [ bug #1749 ] Undefined $mailchimp ***** ChangeLog for 3.6.1 compared to 3.6.* ***** For users: diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 53559c74333..4a0c70e04af 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -212,7 +212,7 @@ if ($action=="addelement") $elementselectid = GETPOST("elementselect"); $result=$project->update_element($tablename, $elementselectid); if ($result<0) { - setEventMessage($mailchimp->error,'errors'); + setEventMessage($project->error,'errors'); } } From b1c4d32fbf00dd9a831fae912f1bbc846bf17b90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Dec 2014 23:53:17 +0100 Subject: [PATCH 092/145] Update phpcs file --- dev/codesniffer/ruleset.xml | 64 +++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml index 38ea1310d22..b2146ce65b5 100755 --- a/dev/codesniffer/ruleset.xml +++ b/dev/codesniffer/ruleset.xml @@ -17,6 +17,10 @@ + + 0 + + 0 @@ -105,7 +109,7 @@ - + @@ -162,7 +166,41 @@ 0 - + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + 0 + + + 0 + + + 0 + + + 0 + + @@ -10,7 +17,17 @@ - + + + 0 + + + 0 + + + 0 + + 0 @@ -46,6 +63,9 @@ --> + + + @@ -93,7 +113,7 @@ - + @@ -150,7 +170,75 @@ 0 - + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + 0 + + + 0 + + + 0 + + + 0 + + '."\n"; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans("EnableShowLogo").'' . yn($conf->global->MAIN_SHOW_LOGO) . ''; print ''; print ''; print ''; print ''; print ' '; print ''; print ' '; print ''; - print ' '; - print ''; - print ' '; - print ''; print ' '; print ''; - print ' '; - print ''; - print ' '; - print '
'; - print ''; - print ''; - print '
'; if ($obj->rowid == 0) { print ''; @@ -621,9 +619,6 @@ class FormCompany print ''; } print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php','',$minLength); - print '
'; print "\n"; return $socid; } From ed839114ab3b4fcc7f27f8a31f6c04c948af22b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 18:42:19 +0100 Subject: [PATCH 137/145] Fixed loading of external numeration modules in FactureFournisseur and Propal --- htdocs/comm/propal/class/propal.class.php | 13 ++++++++----- htdocs/fourn/class/fournisseur.facture.class.php | 10 +++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 846bb5acb10..84b0f65d679 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2564,11 +2564,14 @@ class Propal extends CommonObject $classname = $conf->global->PROPALE_ADDON; // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/propale/"; - // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/propale/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; } if (! $mybool) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 786d619665e..918baea1425 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1497,10 +1497,14 @@ class FactureFournisseur extends CommonInvoice $file = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER.".php"; $classname = $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER; + // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/supplier_invoice/"; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/supplier_invoice/"); + // Load file with numbering class (if found) $mybool|=@include_once $dir.$file; } From 41e01a22a3dfb5aa762ec212d3199f04a21f51b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 18:58:05 +0100 Subject: [PATCH 138/145] Fixed loading of external numeration modules in Contrat, Commande, Facture, Contrat, Expedition, Fichinter, CommandeFournisseur and uniformized code --- htdocs/commande/class/commande.class.php | 17 ++-- htdocs/compta/facture/class/facture.class.php | 80 +++++++++++-------- htdocs/contrat/class/contrat.class.php | 38 +++++---- htdocs/expedition/class/expedition.class.php | 43 ++++++---- htdocs/fichinter/class/fichinter.class.php | 29 ++++--- .../class/fournisseur.commande.class.php | 54 +++++++------ 6 files changed, 155 insertions(+), 106 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 52e454bf14e..573778e808c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -137,17 +137,20 @@ class Commande extends CommonOrder $classname = $conf->global->COMMANDE_ADDON; // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/commande/"; - // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/commande/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; } if (! $mybool) { - dol_print_error('',"Failed to include file ".$file); - return ''; + dol_print_error('',"Failed to include file ".$file); + return ''; } $obj = new $classname(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1df0696486c..63cdcaeb865 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2504,52 +2504,64 @@ class Facture extends CommonInvoice else if ($conf->global->FACTURE_ADDON=='terre') $conf->global->FACTURE_ADDON='mod_facture_terre'; else if ($conf->global->FACTURE_ADDON=='mercure') $conf->global->FACTURE_ADDON='mod_facture_mercure'; - $mybool=false; - - $file = $conf->global->FACTURE_ADDON.".php"; - $classname = $conf->global->FACTURE_ADDON; - // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) + if (! empty($conf->global->FACTURE_ADDON)) { - $dir = $dirroot."/core/modules/facture/"; - // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; - } + $mybool=false; + + $file = $conf->global->FACTURE_ADDON.".php"; + $classname = $conf->global->FACTURE_ADDON; - // For compatibility - if (! $mybool) - { - $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; - $classname = "mod_facture_".$conf->global->FACTURE_ADDON; - $classname = preg_replace('/\-.*$/','',$classname); // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/facture/"; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/facture/"); + // Load file with numbering class (if found) $mybool|=@include_once $dir.$file; } - } - //print "xx".$mybool.$dir.$file."-".$classname; - if (! $mybool) - { - dol_print_error('',"Failed to include file ".$file); - return ''; - } + // For compatibility + if (! $mybool) + { + $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; + $classname = "mod_facture_".$conf->global->FACTURE_ADDON; + $classname = preg_replace('/\-.*$/','',$classname); + // Include file with class + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot."/core/modules/facture/"; + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + } - $obj = new $classname(); - $numref = ""; - $numref = $obj->getNumRef($soc,$this,$mode); + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } - if ($numref != "") - { - return $numref; + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this,$mode); + + if ($numref != "") + { + return $numref; + } + else + { + dol_print_error($db,"Facture::getNextNumRef ".$obj->error); + return ""; + } } else { - //dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); - return false; + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 6cf04c10522..3e4605a8f2c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -92,23 +92,31 @@ class Contrat extends CommonObject global $db, $langs, $conf; $langs->load("contracts"); - $dir = DOL_DOCUMENT_ROOT . "/core/modules/contract"; - - if (empty($conf->global->CONTRACT_ADDON)) + if (!empty($conf->global->CONTRACT_ADDON)) { - $conf->global->CONTRACT_ADDON='mod_contract_serpis'; - } + $mybool = false; - $file = $conf->global->CONTRACT_ADDON.".php"; + $file = $conf->global->CONTRACT_ADDON.".php"; + $classname = $conf->global->CONTRACT_ADDON; - // Chargement de la classe de numerotation - $classname = $conf->global->CONTRACT_ADDON; + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/contract/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } - $result=include_once $dir.'/'.$file; - if ($result) - { $obj = new $classname(); - $numref = ""; $numref = $obj->getNextValue($soc,$this); @@ -118,15 +126,17 @@ class Contrat extends CommonObject } else { + $this->error = $obj->error; dol_print_error($db,get_class($this)."::getNextValue ".$obj->error); return ""; } } else { - print $langs->trans("Error")." ".$langs->trans("Error_CONTRACT_ADDON_NotDefined"); + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); return ""; - } + } } /** diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b6cdf5457d3..1045bed42be 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -119,21 +119,30 @@ class Expedition extends CommonObject global $db, $langs, $conf; $langs->load("sendings"); - $dir = DOL_DOCUMENT_ROOT . "/core/modules/expedition"; - - if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) + if (!empty($conf->global->EXPEDITION_ADDON_NUMBER)) { - $conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor'; - } + $mybool = false; - $file = $conf->global->EXPEDITION_ADDON_NUMBER.".php"; + $file = $conf->global->EXPEDITION_ADDON_NUMBER.".php"; + $classname = $conf->global->EXPEDITION_ADDON_NUMBER; - // Chargement de la classe de numerotation - $classname = $conf->global->EXPEDITION_ADDON_NUMBER; + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/expedition/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } - $result=include_once $dir.'/'.$file; - if ($result) - { $obj = new $classname(); $numref = ""; $numref = $obj->getNextValue($soc,$this); @@ -147,12 +156,12 @@ class Expedition extends CommonObject dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } - } - else - { - print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); - return ""; - } + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined"); + return ""; + } } /** diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 5c556ff2356..42c9208ff08 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -599,25 +599,33 @@ class Fichinter extends CommonObject global $conf, $db, $langs; $langs->load("interventions"); - $dir = DOL_DOCUMENT_ROOT . "/core/modules/fichinter/"; - if (! empty($conf->global->FICHEINTER_ADDON)) { + $mybool = false; + $file = $conf->global->FICHEINTER_ADDON.".php"; $classname = $conf->global->FICHEINTER_ADDON; - if (! file_exists($dir.$file)) - { - $file='mod_'.$file; - $classname='mod_'.$classname; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/fichinter/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; } - // Chargement de la classe de numerotation - require_once $dir.$file; + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } $obj = new $classname(); - $numref = ""; - $numref = $obj->getNumRef($soc,$this); + $numref = $obj->getNextValue($soc,$this); if ( $numref != "") { @@ -631,6 +639,7 @@ class Fichinter extends CommonObject } else { + $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"); return ""; } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3aa9d77f5de..8e618ba0eee 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -551,44 +551,50 @@ class CommandeFournisseur extends CommonOrder global $db, $langs, $conf; $langs->load("orders"); - $dir = DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/'; - if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER)) { + $mybool = false; + $file = $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER.'.php'; + $classname=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER; - if (is_readable($dir.'/'.$file)) + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/supplier_order/"); + + // Load file with numbering class (if found) + $mybool|=@include_once $dir.$file; + } + + if (! $mybool) { - // Definition du nom de modele de numerotation de commande fournisseur - $modName=$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER; - require_once $dir.'/'.$file; + dol_print_error('',"Failed to include file ".$file); + return ''; + } - // Recuperation de la nouvelle reference - $objMod = new $modName($this->db); + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this); - $numref = ""; - $numref = $objMod->commande_get_num($soc,$this); - - if ( $numref != "") - { - return $numref; - } - else - { - dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error); - return -1; - } + if ( $numref != "") + { + return $numref; } else { - print $langs->trans("Error")." ".$langs->trans("Error_FailedToLoad_COMMANDE_SUPPLIER_ADDON_File",$conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER); - return -2; + $this->error = $obj->error; + dol_print_error($db, get_class($this)."::getNextNumRef ".$obj->error); + return ""; } } else { - print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_SUPPLIER_ADDON_NotDefined"); - return -3; + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; } } From 103a433bdf912cb8bacd819f7a4192e2b778ccb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:00:44 +0100 Subject: [PATCH 139/145] Fix: [ bug #1796 ] Unable to use numeration modules from an external module --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..6b25a471b81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1796 ] Unable to use numeration modules from an external module ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. From cc9197e4c85df1daae9c66dbdddd20348d9c1f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:13:38 +0100 Subject: [PATCH 140/145] Fixed problem with Fichinter::getNextNumRef --- htdocs/fichinter/class/fichinter.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 42c9208ff08..c1ec1bef0fc 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -603,8 +603,8 @@ class Fichinter extends CommonObject { $mybool = false; - $file = $conf->global->FICHEINTER_ADDON.".php"; - $classname = $conf->global->FICHEINTER_ADDON; + $file = "mod_".$conf->global->FICHEINTER_ADDON.".php"; + $classname = "mod_".$conf->global->FICHEINTER_ADDON; // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); From 7f59cf919403d858f00fd3028e6eab875b03d96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:28:27 +0100 Subject: [PATCH 141/145] Fix: [ bug #1787 ] Incorrect behaviour of doActions hook --- ChangeLog | 1 + htdocs/adherents/fiche.php | 942 ++++----- htdocs/comm/fiche.php | 132 +- htdocs/comm/mailing/fiche.php | 902 ++++---- htdocs/comm/propal.php | 1704 +++++++-------- htdocs/comm/prospect/list.php | 12 +- htdocs/commande/fiche.php | 2137 +++++++++---------- htdocs/compta/facture.php | 3289 +++++++++++++++-------------- htdocs/compta/paiement.php | 330 +-- htdocs/expedition/fiche.php | 882 ++++---- htdocs/fourn/facture/paiement.php | 262 +-- htdocs/fourn/fiche.php | 57 +- htdocs/product/document.php | 12 +- htdocs/product/fournisseurs.php | 204 +- htdocs/resource/card.php | 69 +- 15 files changed, 5480 insertions(+), 5455 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..e19f3947a59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1787 ] Incorrect behaviour of doActions hook ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index ef04edeeb53..97d71d1572a 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -121,556 +121,558 @@ $hookmanager->initHooks(array('membercard')); $parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) -{ - $error=0; - if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only - { - if ($userid != $user->id && $userid != $object->user_id) - { - $error++; - $mesg='
'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'
'; - } - } +if (empty($reshook)) { - if (! $error) + if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { - if ($userid != $object->user_id) // If link differs from currently in database + $error=0; + if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only { - $result=$object->setUserId($userid); - if ($result < 0) dol_print_error($object->db,$object->error); - $action=''; - } - } -} - -if ($action == 'setsocid') -{ - $error=0; - if (! $error) - { - if ($socid != $object->fk_soc) // If link differs from currently in database - { - $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql.=" WHERE fk_soc = '".$socid."'"; - $sql.=" AND entity = ".$conf->entity; - $resql = $db->query($sql); - if ($resql) + if ($userid != $user->id && $userid != $object->user_id) { - $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) - { - $othermember=new Adherent($db); - $othermember->fetch($obj->rowid); - $thirdparty=new Societe($db); - $thirdparty->fetch($socid); - $error++; - $errmsg='
'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'
'; - } + $error++; + $mesg='
'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'
'; } + } - if (! $error) + if (! $error) + { + if ($userid != $object->user_id) // If link differs from currently in database { - $result=$object->setThirdPartyId($socid); + $result=$object->setUserId($userid); if ($result < 0) dol_print_error($object->db,$object->error); $action=''; } } } -} -// Create user from a member -if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) -{ - if ($result > 0) + if ($action == 'setsocid') { - // Creation user - $nuser = new User($db); - $result=$nuser->create_from_member($object,GETPOST('login')); - - if ($result < 0) + $error=0; + if (! $error) { - $langs->load("errors"); - $errmsg=$langs->trans($nuser->error); - } - } - else - { - $errmsg=$object->error; - } -} - -// Create third party from a member -if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) -{ - if ($result > 0) - { - // Creation user - $company = new Societe($db); - $result=$company->create_from_member($object,GETPOST('companyname')); - - if ($result < 0) - { - $langs->load("errors"); - $errmsg=$langs->trans($company->error); - $errmsgs=$company->errors; - } - } - else - { - $errmsg=$object->error; - } -} - -if ($action == 'confirm_sendinfo' && $confirm == 'yes') -{ - if ($object->email) - { - $from=$conf->email_from; - if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM; - - $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent")); - - $langs->load("mails"); - $mesg=$langs->trans("MailSuccessfulySent", $from, $object->email); - } -} - -if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $birthdate=''; - if (isset($_POST["birthday"]) && $_POST["birthday"] - && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) - { - $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); - } - $lastname=$_POST["lastname"]; - $firstname=$_POST["firstname"]; - $morphy=$morphy=$_POST["morphy"];; - if ($morphy != 'mor' && empty($lastname)) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; - } - if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; - } - - // Create new object - if ($result > 0 && ! $error) - { - $object->oldcopy=dol_clone($object); - - // Change values - $object->civility_id = trim($_POST["civility_id"]); - $object->firstname = trim($_POST["firstname"]); - $object->lastname = trim($_POST["lastname"]); - $object->login = trim($_POST["login"]); - $object->pass = trim($_POST["pass"]); - - $object->societe = trim($_POST["societe"]); - $object->company = trim($_POST["societe"]); - - $object->address = trim($_POST["address"]); - $object->zip = trim($_POST["zipcode"]); - $object->town = trim($_POST["town"]); - $object->state_id = $_POST["state_id"]; - $object->country_id = $_POST["country_id"]; - - $object->phone = trim($_POST["phone"]); - $object->phone_perso = trim($_POST["phone_perso"]); - $object->phone_mobile= trim($_POST["phone_mobile"]); - $object->email = trim($_POST["email"]); - $object->skype = trim($_POST["skype"]); - $object->birth = $birthdate; - - $object->typeid = $_POST["typeid"]; - //$object->note = trim($_POST["comment"]); - $object->morphy = $_POST["morphy"]; - - $object->amount = $_POST["amount"]; - - if (GETPOST('deletephoto')) $object->photo=''; - elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); - - // Get status and public property - $object->statut = $_POST["statut"]; - $object->public = $_POST["public"]; - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); - - // Check if we need to also synchronize user information - $nosyncuser=0; - if ($object->user_id) // If linked to a user - { - if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing - } - - // Check if we need to also synchronize password information - $nosyncuserpass=0; - if ($object->user_id) // If linked to a user - { - if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing - } - - $result=$object->update($user,0,$nosyncuser,$nosyncuserpass); - if ($result >= 0 && ! count($object->errors)) - { - // Logo/Photo save - $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos'; - $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if ($file_OK) + if ($socid != $object->fk_soc) // If link differs from currently in database { - if (GETPOST('deletephoto')) + $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; + $sql.=" WHERE fk_soc = '".$socid."'"; + $sql.=" AND entity = ".$conf->entity; + $resql = $db->query($sql); + if ($resql) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/'.$object->photo; - $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); + $obj = $db->fetch_object($resql); + if ($obj && $obj->rowid > 0) + { + $othermember=new Adherent($db); + $othermember->fetch($obj->rowid); + $thirdparty=new Societe($db); + $thirdparty->fetch($socid); + $error++; + $errmsg='
'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'
'; + } } - if (image_format_supported($_FILES['photo']['name']) > 0) + if (! $error) { - dol_mkdir($dir); + $result=$object->setThirdPartyId($socid); + if ($result < 0) dol_print_error($object->db,$object->error); + $action=''; + } + } + } + } - if (@is_dir($dir)) + // Create user from a member + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) + { + if ($result > 0) + { + // Creation user + $nuser = new User($db); + $result=$nuser->create_from_member($object,GETPOST('login')); + + if ($result < 0) + { + $langs->load("errors"); + $errmsg=$langs->trans($nuser->error); + } + } + else + { + $errmsg=$object->error; + } + } + + // Create third party from a member + if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) + { + if ($result > 0) + { + // Creation user + $company = new Societe($db); + $result=$company->create_from_member($object,GETPOST('companyname')); + + if ($result < 0) + { + $langs->load("errors"); + $errmsg=$langs->trans($company->error); + $errmsgs=$company->errors; + } + } + else + { + $errmsg=$object->error; + } + } + + if ($action == 'confirm_sendinfo' && $confirm == 'yes') + { + if ($object->email) + { + $from=$conf->email_from; + if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM; + + $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent")); + + $langs->load("mails"); + $mesg=$langs->trans("MailSuccessfulySent", $from, $object->email); + } + } + + if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $birthdate=''; + if (isset($_POST["birthday"]) && $_POST["birthday"] + && isset($_POST["birthmonth"]) && $_POST["birthmonth"] + && isset($_POST["birthyear"]) && $_POST["birthyear"]) + { + $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + } + $lastname=$_POST["lastname"]; + $firstname=$_POST["firstname"]; + $morphy=$morphy=$_POST["morphy"];; + if ($morphy != 'mor' && empty($lastname)) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; + } + if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; + } + + // Create new object + if ($result > 0 && ! $error) + { + $object->oldcopy=dol_clone($object); + + // Change values + $object->civility_id = trim($_POST["civility_id"]); + $object->firstname = trim($_POST["firstname"]); + $object->lastname = trim($_POST["lastname"]); + $object->login = trim($_POST["login"]); + $object->pass = trim($_POST["pass"]); + + $object->societe = trim($_POST["societe"]); + $object->company = trim($_POST["societe"]); + + $object->address = trim($_POST["address"]); + $object->zip = trim($_POST["zipcode"]); + $object->town = trim($_POST["town"]); + $object->state_id = $_POST["state_id"]; + $object->country_id = $_POST["country_id"]; + + $object->phone = trim($_POST["phone"]); + $object->phone_perso = trim($_POST["phone_perso"]); + $object->phone_mobile= trim($_POST["phone_mobile"]); + $object->email = trim($_POST["email"]); + $object->skype = trim($_POST["skype"]); + $object->birth = $birthdate; + + $object->typeid = $_POST["typeid"]; + //$object->note = trim($_POST["comment"]); + $object->morphy = $_POST["morphy"]; + + $object->amount = $_POST["amount"]; + + if (GETPOST('deletephoto')) $object->photo=''; + elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + + // Get status and public property + $object->statut = $_POST["statut"]; + $object->public = $_POST["public"]; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + + // Check if we need to also synchronize user information + $nosyncuser=0; + if ($object->user_id) // If linked to a user + { + if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing + } + + // Check if we need to also synchronize password information + $nosyncuserpass=0; + if ($object->user_id) // If linked to a user + { + if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing + } + + $result=$object->update($user,0,$nosyncuser,$nosyncuserpass); + if ($result >= 0 && ! count($object->errors)) + { + // Logo/Photo save + $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos'; + $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); + if ($file_OK) + { + if (GETPOST('deletephoto')) { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0) - { - $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; - } - else - { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/'.$object->photo; + $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + } - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + if (image_format_supported($_FILES['photo']['name']) > 0) + { + dol_mkdir($dir); + + if (@is_dir($dir)) + { + $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0) + { + $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; + } + else + { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + } } } + else + { + $errmsgs[] = "ErrorBadImageFormat"; + } } else { - $errmsgs[] = "ErrorBadImageFormat"; + switch($_FILES['photo']['error']) + { + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; + } + } + + $rowid=$object->id; + $action=''; + + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; } } else { - switch($_FILES['photo']['error']) - { - case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini - case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - $errors[] = "ErrorFileSizeTooLarge"; - break; - case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; + if ($object->error) $errmsg=$object->error; + else $errmsgs=$object->errors; + $action=''; + } + } + else + { + $action='edit'; + } + } + + if ($action == 'add' && $user->rights->adherent->creer) + { + if ($canvas) $object->canvas=$canvas; + $birthdate=''; + if (isset($_POST["birthday"]) && $_POST["birthday"] + && isset($_POST["birthmonth"]) && $_POST["birthmonth"] + && isset($_POST["birthyear"]) && $_POST["birthyear"]) + { + $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + } + $datecotisation=''; + if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) + { + $datecotisation=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + } + + $typeid=$_POST["typeid"]; + $civility_id=$_POST["civility_id"]; + $lastname=$_POST["lastname"]; + $firstname=$_POST["firstname"]; + $societe=$_POST["societe"]; + $address=$_POST["address"]; + $zip=$_POST["zipcode"]; + $town=$_POST["town"]; + $state_id=$_POST["state_id"]; + $country_id=$_POST["country_id"]; + + $phone=$_POST["phone"]; + $phone_perso=$_POST["phone_perso"]; + $phone_mobile=$_POST["phone_mobile"]; + $skype=$_POST["member_skype"]; + $email=$_POST["member_email"]; + $login=$_POST["member_login"]; + $pass=$_POST["password"]; + $photo=$_POST["photo"]; + //$comment=$_POST["comment"]; + $morphy=$_POST["morphy"]; + $cotisation=$_POST["cotisation"]; + $public=$_POST["public"]; + + $userid=$_POST["userid"]; + $socid=$_POST["socid"]; + + $object->civility_id = $civility_id; + $object->firstname = $firstname; + $object->lastname = $lastname; + $object->societe = $societe; + $object->address = $address; + $object->zip = $zip; + $object->town = $town; + $object->state_id = $state_id; + $object->country_id = $country_id; + $object->phone = $phone; + $object->phone_perso = $phone_perso; + $object->phone_mobile= $phone_mobile; + $object->skype = $skype; + $object->email = $email; + $object->login = $login; + $object->pass = $pass; + $object->naiss = $birthdate; + $object->photo = $photo; + $object->typeid = $typeid; + //$object->note = $comment; + $object->morphy = $morphy; + $object->user_id = $userid; + $object->fk_soc = $socid; + $object->public = $public; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + + // Check parameters + if (empty($morphy) || $morphy == "-1") { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."
\n"; + } + // Test si le login existe deja + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + if (empty($login)) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."
\n"; + } + else { + $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + } + if ($num) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."
\n"; } } + if (empty($pass)) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."
\n"; + } + } + if ($morphy != 'mor' && empty($lastname)) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; + } + if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; + } + if (! ($typeid > 0)) { // Keep () before ! + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."
\n"; + } + if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorBadEMail",$email)."
\n"; + } + $public=0; + if (isset($public)) $public=1; - $rowid=$object->id; - $action=''; + if (! $error) + { + $db->begin(); + // Email a peu pres correct et le login n'existe pas + $result=$object->create($user); + if ($result > 0) + { + $db->commit(); + $rowid=$object->id; + $action=''; + } + else + { + $db->rollback(); + + if ($object->error) $errmsg=$object->error; + else $errmsgs=$object->errors; + + $action = 'create'; + } + } + else { + $action = 'create'; + } + } + + if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') + { + $result=$object->delete($rowid); + if ($result > 0) + { if (! empty($backtopage)) { header("Location: ".$backtopage); exit; } + else + { + header("Location: liste.php"); + exit; + } } else { - if ($object->error) $errmsg=$object->error; - else $errmsgs=$object->errors; - $action=''; + $errmesg=$object->error; } } - else + + if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { - $action='edit'; - } -} + $error=0; -if ($action == 'add' && $user->rights->adherent->creer) -{ - if ($canvas) $object->canvas=$canvas; - $birthdate=''; - if (isset($_POST["birthday"]) && $_POST["birthday"] - && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) - { - $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); - } - $datecotisation=''; - if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) - { - $datecotisation=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - } - - $typeid=$_POST["typeid"]; - $civility_id=$_POST["civility_id"]; - $lastname=$_POST["lastname"]; - $firstname=$_POST["firstname"]; - $societe=$_POST["societe"]; - $address=$_POST["address"]; - $zip=$_POST["zipcode"]; - $town=$_POST["town"]; - $state_id=$_POST["state_id"]; - $country_id=$_POST["country_id"]; - - $phone=$_POST["phone"]; - $phone_perso=$_POST["phone_perso"]; - $phone_mobile=$_POST["phone_mobile"]; - $skype=$_POST["member_skype"]; - $email=$_POST["member_email"]; - $login=$_POST["member_login"]; - $pass=$_POST["password"]; - $photo=$_POST["photo"]; - //$comment=$_POST["comment"]; - $morphy=$_POST["morphy"]; - $cotisation=$_POST["cotisation"]; - $public=$_POST["public"]; - - $userid=$_POST["userid"]; - $socid=$_POST["socid"]; - - $object->civility_id = $civility_id; - $object->firstname = $firstname; - $object->lastname = $lastname; - $object->societe = $societe; - $object->address = $address; - $object->zip = $zip; - $object->town = $town; - $object->state_id = $state_id; - $object->country_id = $country_id; - $object->phone = $phone; - $object->phone_perso = $phone_perso; - $object->phone_mobile= $phone_mobile; - $object->skype = $skype; - $object->email = $email; - $object->login = $login; - $object->pass = $pass; - $object->naiss = $birthdate; - $object->photo = $photo; - $object->typeid = $typeid; - //$object->note = $comment; - $object->morphy = $morphy; - $object->user_id = $userid; - $object->fk_soc = $socid; - $object->public = $public; - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); - - // Check parameters - if (empty($morphy) || $morphy == "-1") { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."
\n"; - } - // Test si le login existe deja - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { - if (empty($login)) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."
\n"; - } - else { - $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - } - if ($num) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."
\n"; - } - } - if (empty($pass)) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."
\n"; - } - } - if ($morphy != 'mor' && empty($lastname)) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; - } - if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; - } - if (! ($typeid > 0)) { // Keep () before ! - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."
\n"; - } - if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail",$email)."
\n"; - } - $public=0; - if (isset($public)) $public=1; - - if (! $error) - { $db->begin(); - // Email a peu pres correct et le login n'existe pas - $result=$object->create($user); - if ($result > 0) + $adht = new AdherentType($db); + $adht->fetch($object->typeid); + + $result=$object->validate($user); + + if ($result >= 0 && ! count($object->errors)) + { + // Send confirmation Email (selon param du type adherent sinon generique) + if ($object->email && GETPOST("send_mail")) + { + $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); + if ($result < 0) + { + $error++; + $errmsg.=$object->error; + } + } + } + else + { + $error++; + if ($object->error) $errmsg=$object->error; + else $errmsgs=$object->errors; + } + + if (! $error) { $db->commit(); - $rowid=$object->id; - $action=''; } else { $db->rollback(); - - if ($object->error) $errmsg=$object->error; - else $errmsgs=$object->errors; - - $action = 'create'; } + $action=''; } - else { - $action = 'create'; - } -} -if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') -{ - $result=$object->delete($rowid); - if ($result > 0) + if ($user->rights->adherent->supprimer && $action == 'confirm_resign') { - if (! empty($backtopage)) + if ($confirm == 'yes') + { + $adht = new AdherentType($db); + $adht->fetch($object->typeid); + + $result=$object->resiliate($user); + + if ($result >= 0 && ! count($object->errors)) + { + if ($object->email && GETPOST("send_mail")) + { + $result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); + } + if ($result < 0) + { + $errmsg.=$object->error; + } + } + else + { + if ($object->error) $errmsg=$object->error; + else $errmsgs=$object->errors; + $action=''; + } + } + if (! empty($backtopage) && ! $errmsg) { header("Location: ".$backtopage); exit; } - else - { - header("Location: liste.php"); - exit; - } } - else + + // SPIP Management + if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') { - $errmesg=$object->error; - } -} - -if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') -{ - $error=0; - - $db->begin(); - - $adht = new AdherentType($db); - $adht->fetch($object->typeid); - - $result=$object->validate($user); - - if ($result >= 0 && ! count($object->errors)) - { - // Send confirmation Email (selon param du type adherent sinon generique) - if ($object->email && GETPOST("send_mail")) + if (! count($object->errors)) { - $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); - if ($result < 0) + if (!$mailmanspip->del_to_spip($object)) { - $error++; - $errmsg.=$object->error; + $errmsg.= $langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error."
\n"; } } } - else - { - $error++; - if ($object->error) $errmsg=$object->error; - else $errmsgs=$object->errors; - } - if (! $error) + if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') { - $db->commit(); - } - else - { - $db->rollback(); - } - $action=''; -} - -if ($user->rights->adherent->supprimer && $action == 'confirm_resign') -{ - if ($confirm == 'yes') - { - $adht = new AdherentType($db); - $adht->fetch($object->typeid); - - $result=$object->resiliate($user); - - if ($result >= 0 && ! count($object->errors)) + if (! count($object->errors)) { - if ($object->email && GETPOST("send_mail")) + if (!$mailmanspip->add_to_spip($object)) { - $result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); - } - if ($result < 0) - { - $errmsg.=$object->error; + $errmsg.= $langs->trans('AddIntoSpipError').': '.$mailmanspip->error."
\n"; } } - else - { - if ($object->error) $errmsg=$object->error; - else $errmsgs=$object->errors; - $action=''; - } - } - if (! empty($backtopage) && ! $errmsg) - { - header("Location: ".$backtopage); - exit; } } -// SPIP Management -if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') -{ - if (! count($object->errors)) - { - if (!$mailmanspip->del_to_spip($object)) - { - $errmsg.= $langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error."
\n"; - } - } -} - -if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') -{ - if (! count($object->errors)) - { - if (!$mailmanspip->add_to_spip($object)) - { - $errmsg.= $langs->trans('AddIntoSpipError').': '.$mailmanspip->error."
\n"; - } - } -} - - /* * View diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 307a8c57385..0741b468ed9 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -79,76 +79,78 @@ $object = new Societe($db); $parameters = array('socid' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some -//Some actions show a "cancel" input submit button with name="cancel" -$cancelbutton = GETPOST('cancel'); +if (empty($reshook)) { + //Some actions show a "cancel" input submit button with name="cancel" + $cancelbutton = GETPOST('cancel'); -if ($action == 'setcustomeraccountancycode') -{ - if (!$cancelbutton) { - $result=$object->fetch($id); - $object->code_compta=$_POST["customeraccountancycode"]; - $result=$object->update($object->id,$user,1,1,0); - if ($result < 0) - { - $mesgs[]=join(',',$object->errors); + if ($action == 'setcustomeraccountancycode') + { + if (!$cancelbutton) { + $result=$object->fetch($id); + $object->code_compta=$_POST["customeraccountancycode"]; + $result=$object->update($object->id,$user,1,1,0); + if ($result < 0) + { + $mesgs[]=join(',',$object->errors); + } + $action=""; } - $action=""; } -} -// conditions de reglement -if ($action == 'setconditions' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); - if ($result < 0) dol_print_error($db,$object->error); -} -// mode de reglement -if ($action == 'setmode' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); - if ($result < 0) dol_print_error($db,$object->error); -} -// assujetissement a la TVA -if ($action == 'setassujtva' && $user->rights->societe->creer) -{ - $object->fetch($id); - $object->tva_assuj=$_POST['assujtva_value']; - - // TODO move to DAO class - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$id."'"; - $result = $db->query($sql); - if (! $result) dol_print_error($result); -} - -// set prospect level -if ($action == 'setprospectlevel' && $user->rights->societe->creer) -{ - $object->fetch($id); - $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); - $result=$object->set_prospect_level($user); - if ($result < 0) setEventMessage($object->error,'errors'); -} - -// Update communication level -if ($action == 'cstc') -{ - $object->fetch($id); - $object->stcomm_id=GETPOST('stcomm','int'); - $result=$object->set_commnucation_level($user); - if ($result < 0) setEventMessage($object->error,'errors'); -} - -// Update communication level -if ($action == 'setOutstandingBill') -{ - if (!$cancelbutton) { + // conditions de reglement + if ($action == 'setconditions' && $user->rights->societe->creer) + { $object->fetch($id); - $object->outstanding_limit = GETPOST('OutstandingBill'); - $result = $object->set_OutstandingBill($user); - if ($result < 0) { - setEventMessage($object->error, 'errors'); + $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); + if ($result < 0) dol_print_error($db,$object->error); + } + // mode de reglement + if ($action == 'setmode' && $user->rights->societe->creer) + { + $object->fetch($id); + $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); + if ($result < 0) dol_print_error($db,$object->error); + } + // assujetissement a la TVA + if ($action == 'setassujtva' && $user->rights->societe->creer) + { + $object->fetch($id); + $object->tva_assuj=$_POST['assujtva_value']; + + // TODO move to DAO class + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET tva_assuj='".$_POST['assujtva_value']."' WHERE rowid='".$id."'"; + $result = $db->query($sql); + if (! $result) dol_print_error($result); + } + + // set prospect level + if ($action == 'setprospectlevel' && $user->rights->societe->creer) + { + $object->fetch($id); + $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); + $result=$object->set_prospect_level($user); + if ($result < 0) setEventMessage($object->error,'errors'); + } + + // Update communication level + if ($action == 'cstc') + { + $object->fetch($id); + $object->stcomm_id=GETPOST('stcomm','int'); + $result=$object->set_commnucation_level($user); + if ($result < 0) setEventMessage($object->error,'errors'); + } + + // Update communication level + if ($action == 'setOutstandingBill') + { + if (!$cancelbutton) { + $object->fetch($id); + $object->outstanding_limit = GETPOST('OutstandingBill'); + $result = $object->set_OutstandingBill($user); + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } } } } diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index d803de28357..6e7546fb70d 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -102,446 +102,390 @@ $object->substitutionarrayfortest=array( $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') -{ - if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) +if (empty($reshook)) { + + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes') { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; - } - else - { - $result=$object->createFromClone($object->id,$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]); - if ($result > 0) + if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); - exit; + $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; } else { - $mesg=$object->error; - } - } - $action=''; -} - -// Action send emailing for everybody -if ($action == 'sendallconfirmed' && $confirm == 'yes') -{ - if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) - { - // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, - // on affiche donc juste un message - $mesg='
'.$langs->trans("MailingNeedCommand").'
'; - $mesg.='
'; - $mesg.='

'.$langs->trans("MailingNeedCommand2").'
'; - $action=''; - } - else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) - { - $mesg='
'.$langs->trans("NotEnoughPermissions").'
'; - $action=''; - } - else - { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - if ($object->statut == 0) - { - dol_print_error('','ErrorMailIsNotValidated'); - exit; - } - - $id = $object->id; - $subject = $object->sujet; - $message = $object->body; - $from = $object->email_from; - $replyto = $object->email_replyto; - $errorsto = $object->email_errorsto; - // Le message est-il en html - $msgishtml=-1; // Unknown by default - if (preg_match('/[\s\t]*/i',$message)) $msgishtml=1; - - // Warning, we must not use begin-commit transaction here - // because we want to save update for each mail sent. - - $nbok=0; $nbko=0; - - // On choisit les mails non deja envoyes pour ce mailing (statut=0) - // ou envoyes en erreur (statut=-1) - $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; - $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; - - dol_syslog("fiche.php: select targets sql=".$sql, LOG_DEBUG); - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); // nb of possible recipients - - if ($num) + $result=$object->createFromClone($object->id,$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]); + if ($result > 0) { - dol_syslog("comm/mailing/fiche.php: nb of targets = ".$num, LOG_DEBUG); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + $mesg=$object->error; + } + } + $action=''; + } - $now=dol_now(); + // Action send emailing for everybody + if ($action == 'sendallconfirmed' && $confirm == 'yes') + { + if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) + { + // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, + // on affiche donc juste un message + $mesg='
'.$langs->trans("MailingNeedCommand").'
'; + $mesg.='
'; + $mesg.='

'.$langs->trans("MailingNeedCommand2").'
'; + $action=''; + } + else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) + { + $mesg='
'.$langs->trans("NotEnoughPermissions").'
'; + $action=''; + } + else + { + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - // Positionne date debut envoi - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate($now)." WHERE rowid=".$object->id; + if ($object->statut == 0) + { + dol_print_error('','ErrorMailIsNotValidated'); + exit; + } + + $id = $object->id; + $subject = $object->sujet; + $message = $object->body; + $from = $object->email_from; + $replyto = $object->email_replyto; + $errorsto = $object->email_errorsto; + // Le message est-il en html + $msgishtml=-1; // Unknown by default + if (preg_match('/[\s\t]*/i',$message)) $msgishtml=1; + + // Warning, we must not use begin-commit transaction here + // because we want to save update for each mail sent. + + $nbok=0; $nbko=0; + + // On choisit les mails non deja envoyes pour ce mailing (statut=0) + // ou envoyes en erreur (statut=-1) + $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id; + + dol_syslog("fiche.php: select targets sql=".$sql, LOG_DEBUG); + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); // nb of possible recipients + + if ($num) + { + dol_syslog("comm/mailing/fiche.php: nb of targets = ".$num, LOG_DEBUG); + + $now=dol_now(); + + // Positionne date debut envoi + $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi=".$db->idate($now)." WHERE rowid=".$object->id; + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + + // Loop on each email and send it + $i = 0; + + while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) + { + + $res=1; + + $obj = $db->fetch_object($resql); + + // sendto en RFC2822 + $sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname))." <".$obj->email.">"; + + // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... + $other=explode(';',$obj->other); + $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) + $substitutionarray=array( + '__ID__' => $obj->source_id, + '__EMAIL__' => $obj->email, + '__LASTNAME__' => $obj->lastname, + '__FIRSTNAME__' => $obj->firstname, + '__MAILTOEMAIL__' => ''.$obj->email.'', + '__OTHER1__' => $other1, + '__OTHER2__' => $other2, + '__OTHER3__' => $other3, + '__OTHER4__' => $other4, + '__OTHER5__' => $other5, + '__CHECK_READ__' => '', + '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'' + ); + if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + { + $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); + } + $substitutionisok=true; + complete_substitutions_array($substitutionarray, $langs); + $newsubject=make_substitutions($subject,$substitutionarray); + $newmessage=make_substitutions($message,$substitutionarray); + + $arr_file = array(); + $arr_mime = array(); + $arr_name = array(); + $arr_css = array(); + + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $arr_file[]=$listofpaths[$key]['fullname']; + $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); + $arr_name[]=$listofpaths[$key]['name']; + } + } + + // Fabrication du mail + $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css); + + if ($mail->error) + { + $res=0; + } + if (! $substitutionisok) + { + $mail->error='Some substitution failed'; + $res=0; + } + + // Send mail + if ($res) + { + $res=$mail->sendfile(); + } + + if ($res) + { + // Mail successful + $nbok++; + + dol_syslog("comm/mailing/fiche.php: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql.=" SET statut=1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + else + { + //if cheack read is use then update prospect contact status + if (strpos($message, '__CHECK_READ__') !== false) + { + //Update status communication of thirdparty prospect + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; + dol_syslog("fiche.php: set prospect thirdparty status sql=".$sql, LOG_DEBUG); + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + + //Update status communication of contact prospect + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + dol_syslog("fiche.php: set prospect contact status sql=".$sql, LOG_DEBUG); + + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + } + } + + + //test if CHECK READ change statut prospect contact + } + else + { + // Mail failed + $nbko++; + + dol_syslog("comm/mailing/fiche.php: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_WARNING); + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + } + + $i++; + } + } + else + { + setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo")); + } + + // Loop finished, set global statut of mail + if ($nbko > 0) + { + $statut=2; // Status 'sent partially' (because at least one error) + if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + } + else + { + if ($nbok >= $num) + { + $statut=3; // Send to everybody + setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + } + else + { + $statut=2; // Status 'sent partially' (because not send to everybody) + setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + } + } + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; + dol_syslog("comm/mailing/fiche.php: update global status sql=".$sql, LOG_DEBUG); $resql2=$db->query($sql); if (! $resql2) { dol_print_error($db); } - - // Loop on each email and send it - $i = 0; - - while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) - { - - $res=1; - - $obj = $db->fetch_object($resql); - - // sendto en RFC2822 - $sendto = str_replace(',',' ',dolGetFirstLastname($obj->firstname, $obj->lastname))." <".$obj->email.">"; - - // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... - $other=explode(';',$obj->other); - $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) - $substitutionarray=array( - '__ID__' => $obj->source_id, - '__EMAIL__' => $obj->email, - '__LASTNAME__' => $obj->lastname, - '__FIRSTNAME__' => $obj->firstname, - '__MAILTOEMAIL__' => ''.$obj->email.'', - '__OTHER1__' => $other1, - '__OTHER2__' => $other2, - '__OTHER3__' => $other3, - '__OTHER4__' => $other4, - '__OTHER5__' => $other5, - '__CHECK_READ__' => '', - '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'' - ); - if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { - $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2); - } - $substitutionisok=true; - complete_substitutions_array($substitutionarray, $langs); - $newsubject=make_substitutions($subject,$substitutionarray); - $newmessage=make_substitutions($message,$substitutionarray); - - $arr_file = array(); - $arr_mime = array(); - $arr_name = array(); - $arr_css = array(); - - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $arr_file[]=$listofpaths[$key]['fullname']; - $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); - $arr_name[]=$listofpaths[$key]['name']; - } - } - - // Fabrication du mail - $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css); - - if ($mail->error) - { - $res=0; - } - if (! $substitutionisok) - { - $mail->error='Some substitution failed'; - $res=0; - } - - // Send mail - if ($res) - { - $res=$mail->sendfile(); - } - - if ($res) - { - // Mail successful - $nbok++; - - dol_syslog("comm/mailing/fiche.php: ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - else - { - //if cheack read is use then update prospect contact status - if (strpos($message, '__CHECK_READ__') !== false) - { - //Update status communication of thirdparty prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; - dol_syslog("fiche.php: set prospect thirdparty status sql=".$sql, LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - - //Update status communication of contact prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; - dol_syslog("fiche.php: set prospect contact status sql=".$sql, LOG_DEBUG); - - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - } - } - - - //test if CHECK READ change statut prospect contact - } - else - { - // Mail failed - $nbko++; - - dol_syslog("comm/mailing/fiche.php: error for #".$i.($mail->error?' - '.$mail->error:''), LOG_WARNING); - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj->rowid; - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - } - - $i++; - } } else { - setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo")); - } - - // Loop finished, set global statut of mail - if ($nbko > 0) - { - $statut=2; // Status 'sent partially' (because at least one error) - if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - } - else - { - if ($nbok >= $num) - { - $statut=3; // Send to everybody - setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - } - else - { - $statut=2; // Status 'sent partially' (because not send to everybody) - setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - } - } - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; - dol_syslog("comm/mailing/fiche.php: update global status sql=".$sql, LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) - { + dol_syslog($db->error()); dol_print_error($db); } + + $action = ''; } - else - { - dol_syslog($db->error()); - dol_print_error($db); - } - - $action = ''; - } -} - -// Action send test emailing -if ($action == 'send' && empty($_POST["cancel"])) -{ - $error=0; - - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - $object->sendto = $_POST["sendto"]; - if (! $object->sendto) - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'
'; - $error++; } - if (! $error) + // Action send test emailing + if ($action == 'send' && empty($_POST["cancel"])) { - // Le message est-il en html - $msgishtml=-1; // Inconnu par defaut - if (preg_match('/[\s\t]*/i',$object->body)) $msgishtml=1; + $error=0; - // Pratique les substitutions sur le sujet et message - $tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest); - $tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest); + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - $arr_file = array(); - $arr_mime = array(); - $arr_name = array(); - $arr_css = array(); - - // Ajout CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/',$object->bgcolor)?'':'#').$object->bgcolor; - if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; - - // Attached files - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); - if (count($listofpaths)) + $object->sendto = $_POST["sendto"]; + if (! $object->sendto) { - foreach($listofpaths as $key => $val) + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'
'; + $error++; + } + + if (! $error) + { + // Le message est-il en html + $msgishtml=-1; // Inconnu par defaut + if (preg_match('/[\s\t]*/i',$object->body)) $msgishtml=1; + + // Pratique les substitutions sur le sujet et message + $tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest); + $tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest); + + $arr_file = array(); + $arr_mime = array(); + $arr_name = array(); + $arr_css = array(); + + // Ajout CSS + if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/',$object->bgcolor)?'':'#').$object->bgcolor; + if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; + + // Attached files + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); + if (count($listofpaths)) { - $arr_file[]=$listofpaths[$key]['fullname']; - $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); - $arr_name[]=$listofpaths[$key]['name']; + foreach($listofpaths as $key => $val) + { + $arr_file[]=$listofpaths[$key]['fullname']; + $arr_mime[]=dol_mimetype($listofpaths[$key]['name']); + $arr_name[]=$listofpaths[$key]['name']; + } } + + $mailfile = new CMailFile($tmpsujet,$object->sendto,$object->email_from,$tmpbody, $arr_file,$arr_mime,$arr_name,'', '', 0, $msgishtml,$object->email_errorsto,$arr_css); + + $result=$mailfile->sendfile(); + if ($result) + { + $mesg='
'.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)).'
'; + } + else + { + $mesg='
'.$langs->trans("ResultKo").'
'.$mailfile->error.' '.$result.'
'; + } + + $action=''; } - - $mailfile = new CMailFile($tmpsujet,$object->sendto,$object->email_from,$tmpbody, $arr_file,$arr_mime,$arr_name,'', '', 0, $msgishtml,$object->email_errorsto,$arr_css); - - $result=$mailfile->sendfile(); - if ($result) - { - $mesg='
'.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)).'
'; - } - else - { - $mesg='
'.$langs->trans("ResultKo").'
'.$mailfile->error.' '.$result.'
'; - } - - $action=''; - } -} - -// Action add emailing -if ($action == 'add') -{ - $object->email_from = trim($_POST["from"]); - $object->email_replyto = trim($_POST["replyto"]); - $object->email_errorsto = trim($_POST["errorsto"]); - $object->titre = trim($_POST["titre"]); - $object->sujet = trim($_POST["sujet"]); - $object->body = trim($_POST["body"]); - $object->bgcolor = trim($_POST["bgcolor"]); - $object->bgimage = trim($_POST["bgimage"]); - - if (! $object->titre) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); - if (! $object->sujet) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTopic")); - if (! $object->body) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailMessage")); - - if (! $mesg) - { - if ($object->create($user) >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - $mesg=$object->error; } - $mesg='
'.$mesg.'
'; - $action="create"; -} - -// Action update description of emailing -if ($action == 'settitre' || $action == 'setemail_from' || $actino == 'setreplyto' || $action == 'setemail_errorsto') -{ - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - if ($action == 'settitre') $object->titre = trim(GETPOST('titre','alpha')); - else if ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from','alpha')); - else if ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto','alpha')); - else if ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto','alpha')); - - else if ($action == 'settitre' && empty($object->titre)) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); - else if ($action == 'setfrom' && empty($object->email_from)) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom")); - - if (! $mesg) - { - if ($object->update($user) >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - $mesg=$object->error; - } - - $mesg='
'.$mesg.'
'; - $action=""; -} - -/* - * Add file in email form - */ -if (! empty($_POST['addfile'])) -{ - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory - dol_add_file_process($upload_dir,0,0); - - $action="edit"; -} - -// Action remove file -if (! empty($_POST["removedfile"])) -{ - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); - - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - dol_remove_file_process($_POST['removedfile'],0); - - $action="edit"; -} - -// Action update emailing -if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $isupload=0; - - if (! $isupload) + // Action add emailing + if ($action == 'add') { + $object->email_from = trim($_POST["from"]); + $object->email_replyto = trim($_POST["replyto"]); + $object->email_errorsto = trim($_POST["errorsto"]); + $object->titre = trim($_POST["titre"]); $object->sujet = trim($_POST["sujet"]); $object->body = trim($_POST["body"]); $object->bgcolor = trim($_POST["bgcolor"]); $object->bgimage = trim($_POST["bgimage"]); + if (! $object->titre) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); if (! $object->sujet) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTopic")); if (! $object->body) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailMessage")); + if (! $mesg) + { + if ($object->create($user) >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + $mesg=$object->error; + } + + $mesg='
'.$mesg.'
'; + $action="create"; + } + + // Action update description of emailing + if ($action == 'settitre' || $action == 'setemail_from' || $actino == 'setreplyto' || $action == 'setemail_errorsto') + { + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + + if ($action == 'settitre') $object->titre = trim(GETPOST('titre','alpha')); + else if ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from','alpha')); + else if ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto','alpha')); + else if ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto','alpha')); + + else if ($action == 'settitre' && empty($object->titre)) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle")); + else if ($action == 'setfrom' && empty($object->email_from)) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom")); + if (! $mesg) { if ($object->update($user) >= 0) @@ -553,78 +497,136 @@ if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel" } $mesg='
'.$mesg.'
'; + $action=""; + } + + /* + * Add file in email form + */ + if (! empty($_POST['addfile'])) + { + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory + dol_add_file_process($upload_dir,0,0); + $action="edit"; } - else + + // Action remove file + if (! empty($_POST["removedfile"])) { + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + dol_remove_file_process($_POST['removedfile'],0); + $action="edit"; } -} -// Action confirmation validation -if ($action == 'confirm_valid' && $confirm == 'yes') -{ - if ($object->id > 0) + // Action update emailing + if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) { - $object->valid($user); - setEventMessage($langs->trans("MailingSuccessfullyValidated")); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - dol_print_error($db); - } -} + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -// Resend -if ($action == 'confirm_reset' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $db->begin(); + $isupload=0; - $result=$object->valid($user); - if ($result > 0) + if (! $isupload) { - $result=$object->reset_targets_status($user); + $object->sujet = trim($_POST["sujet"]); + $object->body = trim($_POST["body"]); + $object->bgcolor = trim($_POST["bgcolor"]); + $object->bgimage = trim($_POST["bgimage"]); + + if (! $object->sujet) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTopic")); + if (! $object->body) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailMessage")); + + if (! $mesg) + { + if ($object->update($user) >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + $mesg=$object->error; + } + + $mesg='
'.$mesg.'
'; + $action="edit"; } - - if ($result > 0) + else { - $db->commit(); + $action="edit"; + } + } + + // Action confirmation validation + if ($action == 'confirm_valid' && $confirm == 'yes') + { + if ($object->id > 0) + { + $object->valid($user); + setEventMessage($langs->trans("MailingSuccessfullyValidated")); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { - $mesg=$object->error; - $db->rollback(); + dol_print_error($db); } } - else + + // Resend + if ($action == 'confirm_reset' && $confirm == 'yes') { - dol_print_error($db); + if ($object->id > 0) + { + $db->begin(); + + $result=$object->valid($user); + if ($result > 0) + { + $result=$object->reset_targets_status($user); + } + + if ($result > 0) + { + $db->commit(); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + $mesg=$object->error; + $db->rollback(); + } + } + else + { + dol_print_error($db); + } + } + + // Action confirmation suppression + if ($action == 'confirm_delete' && $confirm == 'yes') + { + if ($object->delete($object->id)) + { + $url= (! empty($urlfrom) ? $urlfrom : 'liste.php'); + header("Location: ".$url); + exit; + } + } + + if (! empty($_POST["cancel"])) + { + $action = ''; } } -// Action confirmation suppression -if ($action == 'confirm_delete' && $confirm == 'yes') -{ - if ($object->delete($object->id)) - { - $url= (! empty($urlfrom) ? $urlfrom : 'liste.php'); - header("Location: ".$url); - exit; - } -} - -if (! empty($_POST["cancel"])) -{ - $action = ''; -} - - /* * View diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 4929ee9c70e..945f6498ce5 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -106,65 +106,46 @@ $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some // hooks -include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once +if (empty($reshook)) { + include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') { - if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); - } else { - if ($object->id > 0) { - $result = $object->createFromClone($socid); - if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); - exit(); - } else { - setEventMessage($object->error, 'errors'); - $action = ''; + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes') { + if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { + setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + } else { + if ($object->id > 0) { + $result = $object->createFromClone($socid); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + exit(); + } else { + setEventMessage($object->error, 'errors'); + $action = ''; + } } } } -} -// Delete proposal -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) { - $result = $object->delete($user); - if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php'); - exit(); - } else { - $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); - } -} - -// Remove line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) { - $result = $object->deleteline($lineid); - // reorder lines - if ($result) - $object->line_order(true); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); + // Delete proposal + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) { + $result = $object->delete($user); + if ($result > 0) { + header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php'); + exit(); + } else { + $langs->load("errors"); + setEventMessage($langs->trans($object->error), 'errors'); } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); - exit(); -} + // Remove line + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) { + $result = $object->deleteline($lineid); + // reorder lines + if ($result) + $object->line_order(true); -// Validation -else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) { - $result = $object->valid($user); - if ($result >= 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -176,148 +157,587 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr $ret = $object->fetch($id); // Reload to get new records propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } else { - $langs->load("errors"); - if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); - else setEventMessage($langs->trans($object->error), 'errors'); - } -} -else if ($action == 'setdate' && $user->rights->propal->creer) { - $datep = dol_mktime(12, 0, 0, $_POST ['remonth'], $_POST ['reday'], $_POST ['reyear']); - - if (empty($datep)) { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + exit(); } - if (! $error) { - $result = $object->set_date($user, $datep); + // Validation + else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) { + $result = $object->valid($user); + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } else { + $langs->load("errors"); + if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); + else setEventMessage($langs->trans($object->error), 'errors'); + } + } + + else if ($action == 'setdate' && $user->rights->propal->creer) { + $datep = dol_mktime(12, 0, 0, $_POST ['remonth'], $_POST ['reday'], $_POST ['reyear']); + + if (empty($datep)) { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); + } + + if (! $error) { + $result = $object->set_date($user, $datep); + if ($result < 0) + dol_print_error($db, $object->error); + } + } else if ($action == 'setecheance' && $user->rights->propal->creer) { + $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST ['echmonth'], $_POST ['echday'], $_POST ['echyear'])); + if ($result < 0) + dol_print_error($db, $object->error); + } else if ($action == 'setdate_livraison' && $user->rights->propal->creer) { + $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST ['liv_month'], $_POST ['liv_day'], $_POST ['liv_year'])); if ($result < 0) dol_print_error($db, $object->error); } -} else if ($action == 'setecheance' && $user->rights->propal->creer) { - $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST ['echmonth'], $_POST ['echday'], $_POST ['echyear'])); - if ($result < 0) - dol_print_error($db, $object->error); -} else if ($action == 'setdate_livraison' && $user->rights->propal->creer) { - $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST ['liv_month'], $_POST ['liv_day'], $_POST ['liv_year'])); - if ($result < 0) - dol_print_error($db, $object->error); -} -// Positionne ref client -else if ($action == 'set_ref_client' && $user->rights->propal->creer) { - $object->set_ref_client($user, $_POST ['ref_client']); -} - -// Create proposal -else if ($action == 'add' && $user->rights->propal->creer) { - $object->socid = $socid; - $object->fetch_thirdparty(); - - $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $duration = GETPOST('duree_validite'); - - if (empty($datep)) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); - $action = 'create'; - $error ++; - } - if (empty($duration)) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); - $action = 'create'; - $error ++; + // Positionne ref client + else if ($action == 'set_ref_client' && $user->rights->propal->creer) { + $object->set_ref_client($user, $_POST ['ref_client']); } - if ($socid < 1) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); - $action = 'create'; - $error ++; - } + // Create proposal + else if ($action == 'add' && $user->rights->propal->creer) { + $object->socid = $socid; + $object->fetch_thirdparty(); - if (! $error) { - $db->begin(); + $datep = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $date_delivery = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $duration = GETPOST('duree_validite'); - // Si on a selectionne une propal a copier, on realise la copie - if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal')) { - if ($object->fetch(GETPOST('copie_propal')) > 0) { + if (empty($datep)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), 'errors'); + $action = 'create'; + $error ++; + } + if (empty($duration)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); + $action = 'create'; + $error ++; + } + + if ($socid < 1) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); + $action = 'create'; + $error ++; + } + + if (! $error) { + $db->begin(); + + // Si on a selectionne une propal a copier, on realise la copie + if (GETPOST('createmode') == 'copy' && GETPOST('copie_propal')) { + if ($object->fetch(GETPOST('copie_propal')) > 0) { + $object->ref = GETPOST('ref'); + $object->datep = $datep; + $object->date_livraison = $date_delivery; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->duree_validite = $duration; + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = GETPOST('remise_absolue'); + $object->socid = GETPOST('socid'); + $object->contactid = GETPOST('contactidp'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); + $object->author = $user->id; // deprecated + $object->note = GETPOST('note'); + $object->statut = 0; + + $id = $object->create_from($user); + } else { + setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); + } + } else { $object->ref = GETPOST('ref'); + $object->ref_client = GETPOST('ref_client'); $object->datep = $datep; $object->date_livraison = $date_delivery; $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); $object->fk_delivery_address = GETPOST('fk_address'); - $object->duree_validite = $duration; + $object->duree_validite = GETPOST('duree_validite'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->remise_percent = GETPOST('remise_percent'); - $object->remise_absolue = GETPOST('remise_absolue'); - $object->socid = GETPOST('socid'); + $object->contactid = GETPOST('contactidp'); $object->fk_project = GETPOST('projectid'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note'); - $object->statut = 0; - $id = $object->create_from($user); - } else { - setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); - } - } else { - $object->ref = GETPOST('ref'); - $object->ref_client = GETPOST('ref_client'); - $object->datep = $datep; - $object->date_livraison = $date_delivery; - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->fk_delivery_address = GETPOST('fk_address'); - $object->duree_validite = GETPOST('duree_validite'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->origin = GETPOST('origin'); + $object->origin_id = GETPOST('originid'); - $object->contactid = GETPOST('contactidp'); - $object->fk_project = GETPOST('projectid'); - $object->modelpdf = GETPOST('model'); - $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); - - $object->origin = GETPOST('origin'); - $object->origin_id = GETPOST('originid'); - - for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { - if ($_POST ['idprod' . $i]) { - $xid = 'idprod' . $i; - $xqty = 'qty' . $i; - $xremise = 'remise' . $i; - $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); - } - } - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error ++; - $action = 'create'; - } - } - - if (! $error) { - $id = $object->create($user); - - if ($id > 0) { - // Insertion contact par defaut si defini - if (GETPOST('contactidp') > 0) { - $result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external'); - if ($result < 0) { - $error ++; - setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { + if ($_POST ['idprod' . $i]) { + $xid = 'idprod' . $i; + $xqty = 'qty' . $i; + $xremise = 'remise' . $i; + $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); } } - if (! $error) { + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + $action = 'create'; + } + } + + if (! $error) { + $id = $object->create($user); + + if ($id > 0) { + // Insertion contact par defaut si defini + if (GETPOST('contactidp') > 0) { + $result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external'); + if ($result < 0) { + $error ++; + setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + } + } + + if (! $error) { + $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + exit(); + } else { + $db->rollback(); + } + } else { + dol_print_error($db, $object->error); + $db->rollback(); + exit(); + } + } + } + } + + // Classify billed + else if ($action == 'classifybilled' && $user->rights->propal->cloturer) { + $object->cloture($user, 4, ''); + } + + // Reopen proposal + else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { + // prevent browser refresh from reopening proposal several times + if ($object->statut == 2 || $object->statut == 3) { + $object->reopen($user, 1); + } + } + + // Close proposal + else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { + if (! GETPOST('statut')) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); + $action = 'statut'; + } else { + // prevent browser refresh from closing proposal several times + if ($object->statut == 1) { + $object->cloture($user, GETPOST('statut'), GETPOST('note')); + } + } + } + + // Add file in email form + if (GETPOST('addfile')) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; + + dol_add_file_process($upload_dir_tmp, 0, 0); + $action = 'presend'; + } + + // Remove file in email form + if (GETPOST('removedfile')) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process($_POST ['removedfile'], 0); + $action = 'presend'; + } + + /* + * Send mail + */ + if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { + $langs->load('mails'); + + if ($object->id > 0) { + if ($_POST ['sendto']) { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST ['sendto']; + $sendtoid = 0; + } elseif ($_POST ['receiver'] != '-1') { + // Recipient was provided from combo list + if ($_POST ['receiver'] == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST ['receiver'], 'email'); + $sendtoid = $_POST ['receiver']; + } + } + + if (dol_strlen($sendto)) { + $langs->load("commercial"); + + $from = $_POST ['fromname'] . ' <' . $_POST ['frommail'] . '>'; + $replyto = $_POST ['replytoname'] . ' <' . $_POST ['replytomail'] . '>'; + $message = $_POST ['message']; + $sendtocc = $_POST ['sendtocc']; + $deliveryreceipt = $_POST ['deliveryreceipt']; + + if (dol_strlen($_POST ['subject'])) + $subject = $_POST ['subject']; + else + $subject = $langs->transnoentities('Propal') . ' ' . $object->ref; + $actiontypecode = 'AC_PROP'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + if ($message) { + $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; + $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; + $actionmsg .= $message; + } + $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); + + // Create form object + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles = $formmail->get_attached_files(); + $filepath = $attachedfiles ['paths']; + $filename = $attachedfiles ['names']; + $mimetype = $attachedfiles ['mimes']; + + // Envoi de la propal + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + if ($mailfile->error) { + setEventMessage($mailfile->error, 'errors'); + } else { + $result = $mailfile->sendfile(); + if ($result) { + // Initialisation donnees + $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('PROPAL_SENTBYMAIL', $object, $user, $langs, $conf); + if ($result < 0) { + $error++; + $object->errors = $interface->errors; + } + // Fin appel triggers + + if (! $error) { + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); + setEventMessage($mesg); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + exit(); + } else { + dol_print_error($db); + } + } else { + $langs->load("other"); + if ($mailfile->error) { + $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); + $mesg .= '
' . $mailfile->error; + } else { + $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + setEventMessage($mesg, 'errors'); + } + } + } else { + $langs->load("other"); + setEventMessage($langs->trans('ErrorMailRecipientIsEmpty') . '!', 'errors'); + dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); + } + } else { + $langs->load("other"); + setEventMessage($langs->trans('ErrorFailedToReadEntity', $langs->trans("Proposal")), 'errors'); + dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Proposal"))); + } + } + + // Go back to draft + if ($action == 'modif' && $user->rights->propal->creer) { + $object->set_draft($user); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { + if ($_POST ["remise_id"]) { + if ($object->id > 0) { + $result = $object->insert_discount($_POST ["remise_id"]); + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } + } + } + } + + // Add line + else if ($action == 'addline' && $user->rights->propal->creer) { + + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } + + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST ["options_" . $key]); + } + } + + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; + } + + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); + $error ++; + } + + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + $pu_ht = 0; + $pu_ttc = 0; + $price_min = 0; + $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); + + $db->begin(); + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + if (! empty($idprod)) { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + + // If prices fields are update + $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); + + // On defini prix unitaire + if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) + { + $pu_ht = $prod->multiprices[$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; + $price_min = $prod->multiprices_min[$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) { + if (count($prodcustprice->lines) > 0) { + $found = true; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; + }else { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + }else { + setEventMessage($prodcustprice->error,'errors'); + } + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + + // if price ht is forced (ie: calculated by margin rate and cost price) + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $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). + elseif ($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'); + } + } + + $desc = ''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } else { + $desc = $prod->description; + } + + $desc = dol_concatdesc($desc, $product_desc); + + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + } + + $type = $prod->type; + } else { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); + + $date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->client); + $localtax2_tx = get_localtax($tva_tx, 2, $object->client); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessage($mesg, 'errors'); + } else { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_option); + + if ($result > 0) { $db->commit(); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -332,411 +752,120 @@ else if ($action == 'add' && $user->rights->propal->creer) { propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); - exit(); + unset($_POST ['prod_entry_mode']); + + unset($_POST ['qty']); + unset($_POST ['type']); + unset($_POST ['remise_percent']); + unset($_POST ['price_ht']); + unset($_POST ['price_ttc']); + unset($_POST ['tva_tx']); + unset($_POST ['product_ref']); + unset($_POST ['product_label']); + unset($_POST ['product_desc']); + unset($_POST ['fournprice']); + unset($_POST ['buying_price']); + unset($_POST ['np_marginRate']); + unset($_POST ['np_markRate']); + unset($_POST ['dp_desc']); + unset($_POST ['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { $db->rollback(); - } - } else { - dol_print_error($db, $object->error); - $db->rollback(); - exit(); - } - } - } -} -// Classify billed -else if ($action == 'classifybilled' && $user->rights->propal->cloturer) { - $object->cloture($user, 4, ''); -} - -// Reopen proposal -else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { - // prevent browser refresh from reopening proposal several times - if ($object->statut == 2 || $object->statut == 3) { - $object->reopen($user, 1); - } -} - -// Close proposal -else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) { - if (! GETPOST('statut')) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), 'errors'); - $action = 'statut'; - } else { - // prevent browser refresh from closing proposal several times - if ($object->statut == 1) { - $object->cloture($user, GETPOST('statut'), GETPOST('note')); - } - } -} - -// Add file in email form -if (GETPOST('addfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; - - dol_add_file_process($upload_dir_tmp, 0, 0); - $action = 'presend'; -} - -// Remove file in email form -if (GETPOST('removedfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST ['removedfile'], 0); - $action = 'presend'; -} - -/* - * Send mail - */ -if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { - $langs->load('mails'); - - if ($object->id > 0) { - if ($_POST ['sendto']) { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST ['sendto']; - $sendtoid = 0; - } elseif ($_POST ['receiver'] != '-1') { - // Recipient was provided from combo list - if ($_POST ['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST ['receiver'], 'email'); - $sendtoid = $_POST ['receiver']; - } - } - - if (dol_strlen($sendto)) { - $langs->load("commercial"); - - $from = $_POST ['fromname'] . ' <' . $_POST ['frommail'] . '>'; - $replyto = $_POST ['replytoname'] . ' <' . $_POST ['replytomail'] . '>'; - $message = $_POST ['message']; - $sendtocc = $_POST ['sendtocc']; - $deliveryreceipt = $_POST ['deliveryreceipt']; - - if (dol_strlen($_POST ['subject'])) - $subject = $_POST ['subject']; - else - $subject = $langs->transnoentities('Propal') . ' ' . $object->ref; - $actiontypecode = 'AC_PROP'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; - } - $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); - - // Create form object - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles ['paths']; - $filename = $attachedfiles ['names']; - $mimetype = $attachedfiles ['mimes']; - - // Envoi de la propal - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); - if ($mailfile->error) { - setEventMessage($mailfile->error, 'errors'); - } else { - $result = $mailfile->sendfile(); - if ($result) { - // Initialisation donnees - $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('PROPAL_SENTBYMAIL', $object, $user, $langs, $conf); - if ($result < 0) { - $error++; - $object->errors = $interface->errors; - } - // Fin appel triggers - - if (! $error) { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); - setEventMessage($mesg); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); - exit(); - } else { - dol_print_error($db); - } - } else { - $langs->load("other"); - if ($mailfile->error) { - $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); - $mesg .= '
' . $mailfile->error; - } else { - $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - setEventMessage($mesg, 'errors'); + setEventMessage($object->error, 'errors'); } } - } else { - $langs->load("other"); - setEventMessage($langs->trans('ErrorMailRecipientIsEmpty') . '!', 'errors'); - dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); - } - } else { - $langs->load("other"); - setEventMessage($langs->trans('ErrorFailedToReadEntity', $langs->trans("Proposal")), 'errors'); - dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Proposal"))); - } -} - -// Go back to draft -if ($action == 'modif' && $user->rights->propal->creer) { - $object->set_draft($user); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } -} - -else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { - if ($_POST ["remise_id"]) { - if ($object->id > 0) { - $result = $object->insert_discount($_POST ["remise_id"]); - if ($result < 0) { - setEventMessage($object->error, 'errors'); - } - } - } -} - -// Add line -else if ($action == 'addline' && $user->rights->propal->creer) { - - // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - if (GETPOST('prod_entry_mode') == 'free') - { - $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { - $idprod=GETPOST('idprod', 'int'); - $tva_tx = ''; - } - - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); } } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; - } - - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. - { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); - $error ++; - } - - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - $pu_ht = 0; - $pu_ttc = 0; - $price_min = 0; - $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); - - $db->begin(); - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - - // If prices fields are update - $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); - - // On defini prix unitaire - if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) - { - $pu_ht = $prod->multiprices[$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; - $price_min = $prod->multiprices_min[$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) { - if (count($prodcustprice->lines) > 0) { - $found = true; - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; - }else { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - }else { - setEventMessage($prodcustprice->error,'errors'); - } - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - - // if price ht is forced (ie: calculated by margin rate and cost price) - if (! empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $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). - elseif ($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'); - } - } - - $desc = ''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } - - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } - - $type = $prod->type; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); - } - - // Margin - $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - - $date_start = dol_mktime(0, 0, 0, GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(0, 0, 0, GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->client); - $localtax2_tx = get_localtax($tva_tx, 2, $object->client); - + // Mise a jour d'une ligne dans la propale + else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) { + // Define info_bits $info_bits = 0; - if ($tva_npr) + if (preg_match('/\*/', GETPOST('tva_tx'))) $info_bits |= 0x01; - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); - } else { - // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_option); + // Clean parameters + $description = dol_htmlcleanlastbr(GETPOST('product_desc')); - if ($result > 0) { + // Define vat_rate + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->client); + $localtax2_rate = get_localtax($vat_rate, 2, $object->client); + $pu_ht = GETPOST('price_ht'); + + // Add buying price + $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); + + $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST ["options_" . $key]); + } + } + + // Define special_code for special lines + $special_code=GETPOST('special_code'); + if (! GETPOST('qty')) $special_code=3; + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) { + $product = new Product($db); + $res = $product->fetch($productid); + + $type = $product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + $price_min = $product->multiprices_min [$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); + + if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + $error ++; + } + } else { + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; + } + } + + if (! $error) { + $db->begin(); + + $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_option); + + if ($result >= 0) { $db->commit(); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -751,10 +880,9 @@ else if ($action == 'addline' && $user->rights->propal->creer) { propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - unset($_POST ['prod_entry_mode']); - unset($_POST ['qty']); unset($_POST ['type']); + unset($_POST ['productid']); unset($_POST ['remise_percent']); unset($_POST ['price_ht']); unset($_POST ['price_ttc']); @@ -764,23 +892,6 @@ else if ($action == 'addline' && $user->rights->propal->creer) { unset($_POST ['product_desc']); unset($_POST ['fournprice']); unset($_POST ['buying_price']); - unset($_POST ['np_marginRate']); - unset($_POST ['np_markRate']); - unset($_POST ['dp_desc']); - unset($_POST ['idprod']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); } else { $db->rollback(); @@ -788,303 +899,194 @@ else if ($action == 'addline' && $user->rights->propal->creer) { } } } -} -// Mise a jour d'une ligne dans la propale -else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) { - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', GETPOST('tva_tx'))) - $info_bits |= 0x01; - - // Clean parameters - $description = dol_htmlcleanlastbr(GETPOST('product_desc')); - - // Define vat_rate - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $object->client); - $localtax2_rate = get_localtax($vat_rate, 2, $object->client); - $pu_ht = GETPOST('price_ht'); - - // Add buying price - $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); - - $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); - } + else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + exit(); } - // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; - - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { - $product = new Product($db); - $res = $product->fetch($productid); - - $type = $product->type; - - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - $price_min = $product->multiprices_min [$object->client->price_level]; - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - - if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; + // Generation doc (depuis lien ou depuis cartouche doc) + else if ($action == 'builddoc' && $user->rights->propal->creer) { + if (GETPOST('model')) { + $object->setDocModel($user, GETPOST('model')); } - } else { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - // Check parameters - if (GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); } - } + $ret = $object->fetch($id); // Reload to get new records + $result = propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if (! $error) { - $db->begin(); - - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_option); - - if ($result >= 0) { - $db->commit(); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['productid']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); + if ($result <= 0) { + dol_print_error($db, $result); + exit(); } else { - $db->rollback(); - - setEventMessage($object->error, 'errors'); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); + exit(); } } -} -else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition - exit(); -} - -// Generation doc (depuis lien ou depuis cartouche doc) -else if ($action == 'builddoc' && $user->rights->propal->creer) { - if (GETPOST('model')) { - $object->setDocModel($user, GETPOST('model')); - } - - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - $result = propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($result <= 0) { - dol_print_error($db, $result); - exit(); - } else { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); - exit(); - } -} - -// Remove file in doc form -else if ($action == 'remove_file' && $user->rights->propal->creer) { - if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $conf->propal->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); - } -} - -// Set project -else if ($action == 'classin' && $user->rights->propal->creer) { - $object->setProject($_POST ['projectid']); -} - -// Delai de livraison -else if ($action == 'setavailability' && $user->rights->propal->creer) { - $result = $object->availability($_POST ['availability_id']); -} - -// Origine de la propale -else if ($action == 'setdemandreason' && $user->rights->propal->creer) { - $result = $object->demand_reason($_POST ['demand_reason_id']); -} - -// Conditions de reglement -else if ($action == 'setconditions' && $user->rights->propal->creer) { - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); -} - -else if ($action == 'setremisepercent' && $user->rights->propal->creer) { - $result = $object->set_remise_percent($user, $_POST ['remise_percent']); -} - -else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) { - $result = $object->set_remise_absolue($user, $_POST ['remise_absolue']); -} - -// Mode de reglement -else if ($action == 'setmode' && $user->rights->propal->creer) { - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); -} - -/* - * Ordonnancement des lignes -*/ - -else if ($action == 'up' && $user->rights->propal->creer) { - $object->line_up(GETPOST('rowid')); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); - exit(); -} - -else if ($action == 'down' && $user->rights->propal->creer) { - $object->line_down(GETPOST('rowid')); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); - exit(); -} else if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; - - if (! $error) { - // Actions on extra fields (by external module or standard code) - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('propaldao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been - // modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) - $error ++; - } - - if ($error) - $action = 'edit_extras'; -} - -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) { - if ($action == 'addcontact') { + // Remove file in doc form + else if ($action == 'remove_file' && $user->rights->propal->creer) { if ($object->id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST ["type"], $_POST ["source"]); + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $langs->load("other"); + $upload_dir = $conf->propal->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) + setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + } + } + + // Set project + else if ($action == 'classin' && $user->rights->propal->creer) { + $object->setProject($_POST ['projectid']); + } + + // Delai de livraison + else if ($action == 'setavailability' && $user->rights->propal->creer) { + $result = $object->availability($_POST ['availability_id']); + } + + // Origine de la propale + else if ($action == 'setdemandreason' && $user->rights->propal->creer) { + $result = $object->demand_reason($_POST ['demand_reason_id']); + } + + // Conditions de reglement + else if ($action == 'setconditions' && $user->rights->propal->creer) { + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + } + + else if ($action == 'setremisepercent' && $user->rights->propal->creer) { + $result = $object->set_remise_percent($user, $_POST ['remise_percent']); + } + + else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) { + $result = $object->set_remise_absolue($user, $_POST ['remise_absolue']); + } + + // Mode de reglement + else if ($action == 'setmode' && $user->rights->propal->creer) { + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + } + + /* + * Ordonnancement des lignes + */ + + else if ($action == 'up' && $user->rights->propal->creer) { + $object->line_up(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); + exit(); + } + + else if ($action == 'down' && $user->rights->propal->creer) { + $object->line_down(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id . '#' . GETPOST('rowid')); + exit(); + } else if ($action == 'update_extras') { + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) + $error ++; + + if (! $error) { + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('propaldao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been + // modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + } + + if ($error) + $action = 'edit_extras'; + } + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) { + if ($action == 'addcontact') { + if ($object->id > 0) { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST ["type"], $_POST ["source"]); + } + + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); } else { - setEventMessage($object->error, 'errors'); + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + } else { + setEventMessage($object->error, 'errors'); + } } } - } - // Bascule du statut d'un contact - else if ($action == 'swapstatut') { - if ($object->fetch($id) > 0) { - $result = $object->swapContactStatus(GETPOST('ligne')); - } else { - dol_print_error($db); + // Bascule du statut d'un contact + else if ($action == 'swapstatut') { + if ($object->fetch($id) > 0) { + $result = $object->swapContactStatus(GETPOST('ligne')); + } else { + dol_print_error($db); + } } - } - // Efface un contact - else if ($action == 'deletecontact') { - $object->fetch($id); - $result = $object->delete_contact($lineid); + // Efface un contact + else if ($action == 'deletecontact') { + $object->fetch($id); + $result = $object->delete_contact($lineid); - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - dol_print_error($db); + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + dol_print_error($db); + } } } } diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 58a384df6d0..fdfa2495411 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -162,11 +162,13 @@ $hookmanager->initHooks(array('prospectlist')); $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks -if ($action == 'cstc') -{ - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"]; - $sql .= " WHERE rowid = ".$_GET["socid"]; - $result=$db->query($sql); +if (empty($reshook)) { + if ($action == 'cstc') + { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"]; + $sql .= " WHERE rowid = ".$_GET["socid"]; + $result=$db->query($sql); + } } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 1c01b975a3b..02e6c74c13c 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -101,44 +101,88 @@ $permissionnote = $user->rights->commande->creer; // Used by the include of acti $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once +if (empty($reshook)) { -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) -{ - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; - } - else - { - if ($object->id > 0) + if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { - // Because createFromClone modifies the object, we must clone it so that we can restore it later - $orig = dol_clone($object); + $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; + } + else + { + if ($object->id > 0) + { + // Because createFromClone modifies the object, we must clone it so that we can restore it later + $orig = dol_clone($object); - $result=$object->createFromClone($socid); + $result=$object->createFromClone($socid); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + setEventMessage($object->error, 'errors'); + $object = $orig; + $action=''; + } + } + } + } + + // Reopen a closed order + else if ($action == 'reopen' && $user->rights->commande->creer) { + if ($object->statut == 3) { + $result = $object->set_reopen($user); if ($result > 0) { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { setEventMessage($object->error, 'errors'); - $object = $orig; - $action=''; } } } -} -// Reopen a closed order -else if ($action == 'reopen' && $user->rights->commande->creer) { - if ($object->statut == 3) { - $result = $object->set_reopen($user); - if ($result > 0) - { + // Suppression de la commande + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) { + $result = $object->delete($user); + if ($result > 0) { + header('Location: index.php'); + exit; + } + else { + setEventMessage($object->error, 'errors'); + } + } + + // Remove a product line + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) { + $result = $object->deleteline($lineid); + if ($result > 0) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } @@ -147,697 +191,299 @@ else if ($action == 'reopen' && $user->rights->commande->creer) { setEventMessage($object->error, 'errors'); } } -} -// Suppression de la commande -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) { - $result = $object->delete($user); - if ($result > 0) { - header('Location: index.php'); - exit; + // Categorisation dans projet + else if ($action == 'classin' && $user->rights->commande->creer) { + $object->setProject(GETPOST('projectid')); } - else { - setEventMessage($object->error, 'errors'); - } -} -// Remove a product line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) { - $result = $object->deleteline($lineid); - if ($result > 0) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + // Add order + else if ($action == 'add' && $user->rights->commande->creer) { + $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + + if ($datecommande == '') { + $mesg = '
' . $langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')) . '
'; + $action = 'create'; + $error ++; } - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - setEventMessage($object->error, 'errors'); - } -} + if ($socid < 1) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); + $action = 'create'; + $error ++; + } -// Categorisation dans projet -else if ($action == 'classin' && $user->rights->commande->creer) { - $object->setProject(GETPOST('projectid')); -} + if (! $error) { + $object->socid = $socid; + $object->fetch_thirdparty(); -// Add order -else if ($action == 'add' && $user->rights->commande->creer) { - $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $db->begin(); - if ($datecommande == '') { - $mesg = '
' . $langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')) . '
'; - $action = 'create'; - $error ++; - } + $object->date_commande = $datecommande; + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); + $object->source = GETPOST('source_id'); + $object->fk_project = GETPOST('projectid'); + $object->ref_client = GETPOST('ref_client'); + $object->modelpdf = GETPOST('model'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->date_livraison = $datelivraison; + $object->fk_delivery_address = GETPOST('fk_address'); + $object->contactid = GETPOST('contactidp'); - if ($socid < 1) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); - $action = 'create'; - $error ++; - } + // If creation from another object of another module (Example: origin=propal, originid=1) + if (! empty($origin) && ! empty($originid)) { + // Parse element/subelement (ex: project_task) + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { + $element = $regs [1]; + $subelement = $regs [2]; + } - if (! $error) { - $object->socid = $socid; - $object->fetch_thirdparty(); + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; + $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } - $db->begin(); + $object->origin = $origin; + $object->origin_id = $originid; - $object->date_commande = $datecommande; - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); - $object->source = GETPOST('source_id'); - $object->fk_project = GETPOST('projectid'); - $object->ref_client = GETPOST('ref_client'); - $object->modelpdf = GETPOST('model'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->date_livraison = $datelivraison; - $object->fk_delivery_address = GETPOST('fk_address'); - $object->contactid = GETPOST('contactidp'); + // Possibility to add external linked objects with hooks + $object->linked_objects [$object->origin] = $object->origin_id; + $other_linked_objects = GETPOST('other_linked_objects', 'array'); + if (! empty($other_linked_objects)) { + $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); + } - // If creation from another object of another module (Example: origin=propal, originid=1) - if (! empty($origin) && ! empty($originid)) { - // Parse element/subelement (ex: project_task) - $element = $subelement = $origin; - if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { - $element = $regs [1]; - $subelement = $regs [2]; - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) + $error ++; - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; - $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - - $object->origin = $origin; - $object->origin_id = $originid; - - // Possibility to add external linked objects with hooks - $object->linked_objects [$object->origin] = $object->origin_id; - $other_linked_objects = GETPOST('other_linked_objects', 'array'); - if (! empty($other_linked_objects)) { - $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); - } - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) - $error ++; - - if (! $error) - { - $object_id = $object->create($user); - - if ($object_id > 0) + if (! $error) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + $object_id = $object->create($user); - $classname = ucfirst($subelement); - $srcobject = new $classname($db); - - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); - if ($result > 0) + if ($object_id > 0) { - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); + if ($result > 0) { - $srcobject->fetch_lines(); $lines = $srcobject->lines; - } - - $fk_parent_line = 0; - $num = count($lines); - - for($i = 0; $i < $num; $i ++) - { - $label = (! empty($lines [$i]->label) ? $lines [$i]->label : ''); - $desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle); - $product_type = (! empty($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; - - // Reset fk_parent_line for no child products and special product - if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) // For avoid conflicts if - // trigger used + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { - $lines [$i]->fetch_optionals($lines [$i]->rowid); - $array_option = $lines [$i]->array_options; + $srcobject->fetch_lines(); + $lines = $srcobject->lines; } - $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); + $fk_parent_line = 0; + $num = count($lines); - if ($result < 0) { + for($i = 0; $i < $num; $i ++) + { + $label = (! empty($lines [$i]->label) ? $lines [$i]->label : ''); + $desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle); + $product_type = (! empty($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; + + // Reset fk_parent_line for no child products and special product + if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) // For avoid conflicts if + // trigger used + { + $lines [$i]->fetch_optionals($lines [$i]->rowid); + $array_option = $lines [$i]->array_options; + } + + $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); + + if ($result < 0) { + $error ++; + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines [$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) $error ++; - break; - } - - // Defined the new fk_parent_line - if ($result > 0 && $lines [$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - - // Hooks - $parameters = array('objFrom' => $srcobject); - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if ($reshook < 0) + } else { + $mesg = $srcobject->error; $error ++; + } } else { - $mesg = $srcobject->error; + $mesg = $object->error; $error ++; } } else { - $mesg = $object->error; - $error ++; + // Required extrafield left blank, error message already defined by setOptionalsFromPost() + $action = 'create'; } } else { - // Required extrafield left blank, error message already defined by setOptionalsFromPost() - $action = 'create'; - } - } else { - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) - $error ++; - - if (! $error) { - $object_id = $object->create($user); - - // If some invoice's lines already known - $NBLINES = 8; - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST ['idprod' . $i]) { - $xid = 'idprod' . $i; - $xqty = 'qty' . $i; - $xremise = 'remise_percent' . $i; - $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); - } - } - } - } - - // Insert default contacts if defined - if ($object_id > 0) { - if (GETPOST('contactidp')) { - $result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external'); - if ($result < 0) { - $mesg = '
' . $langs->trans("ErrorFailedToAddContact") . '
'; + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error ++; - } - } - $id = $object_id; - $action = ''; - } + if (! $error) { + $object_id = $object->create($user); - // End of object creation, we show it - if ($object_id > 0 && ! $error) { - $db->commit(); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object_id); - exit(); - } else { - $db->rollback(); - $action = 'create'; - if (! $mesg) - $mesg = '
' . $object->error . '
'; - } - } -} - -else if ($action == 'classifybilled' && $user->rights->commande->creer) -{ - $ret=$object->classifyBilled(); - - if ($ret < 0) { - setEventMessage($object->error, 'errors'); - } -} - -// Positionne ref commande client -else if ($action == 'set_ref_client' && $user->rights->commande->creer) { - $object->set_ref_client($user, GETPOST('ref_client')); -} - -else if ($action == 'setremise' && $user->rights->commande->creer) { - $object->set_remise($user, GETPOST('remise')); -} - -else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { - if (GETPOST('remise_id')) { - if ($object->id > 0) { - $object->insert_discount(GETPOST('remise_id')); - } else { - dol_print_error($db, $object->error); - } - } -} - -else if ($action == 'setdate' && $user->rights->commande->creer) { - // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); - - $result = $object->set_date($user, $date); - if ($result < 0) { - $mesg = '
' . $object->error . '
'; - } -} - -else if ($action == 'setdate_livraison' && $user->rights->commande->creer) { - // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - - $result = $object->set_date_livraison($user, $datelivraison); - if ($result < 0) { - $mesg = '
' . $object->error . '
'; - } -} - -else if ($action == 'setmode' && $user->rights->commande->creer) { - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setavailability' && $user->rights->commande->creer) { - $result = $object->availability(GETPOST('availability_id')); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setdemandreason' && $user->rights->commande->creer) { - $result = $object->demand_reason(GETPOST('demand_reason_id')); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setconditions' && $user->rights->commande->creer) { - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) { - dol_print_error($db, $object->error); - } else { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - $newlang = GETPOST('lang_id', 'alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $ret = $object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } -} - -else if ($action == 'setremisepercent' && $user->rights->commande->creer) { - $result = $object->set_remise($user, GETPOST('remise_percent')); -} - -else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) { - $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); -} - -// Add a new line -else if ($action == 'addline' && $user->rights->commande->creer) { - $langs->load('errors'); - $error = 0; - - // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - if (GETPOST('prod_entry_mode') == 'free') - { - $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { - $idprod=GETPOST('idprod', 'int'); - $tva_tx = ''; - } - - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); - } - } - - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { - setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' - { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; - } - if ($qty == '') { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error ++; - } - - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - // Clean parameters - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), 0, GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), 0, GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - // Ecrase $base_price_type par celui du produit - if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - - // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); - - // multiprix - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - { - $pu_ht = $prod->multiprices [$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc [$object->client->price_level]; - $price_min = $prod->multiprices_min [$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type [$object->client->price_level]; - if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) { - if (count($prodcustprice->lines) > 0) { - $found = true; - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; - } else { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; + // If some invoice's lines already known + $NBLINES = 8; + for($i = 1; $i <= $NBLINES; $i ++) { + if ($_POST ['idprod' . $i]) { + $xid = 'idprod' . $i; + $xqty = 'qty' . $i; + $xremise = 'remise_percent' . $i; + $object->add_product($_POST [$xid], $_POST [$xqty], $_POST [$xremise]); } - } else { - setEventMessage($prodcustprice->error,'errors'); } } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } + } - // if price ht is forced (ie: calculated by margin rate and cost price) - if (! empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $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). - elseif ($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'); + // Insert default contacts if defined + if ($object_id > 0) { + if (GETPOST('contactidp')) { + $result = $object->add_contact(GETPOST('contactidp'), 'CUSTOMER', 'external'); + if ($result < 0) { + $mesg = '
' . $langs->trans("ErrorFailedToAddContact") . '
'; + $error ++; } } - $desc = ''; + $id = $object_id; + $action = ''; + } - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } - - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } - - $type = $prod->type; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); - } - - // Margin - $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->client); - $localtax2_tx = get_localtax($tva_tx, 2, $object->client); - - $desc = dol_htmlcleanlastbr($desc); - - $info_bits = 0; - if ($tva_npr) - $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); - } else { - // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); - - if ($result > 0) { - $ret = $object->fetch($object->id); // Reload to get new records - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST ['prod_entry_mode']); - - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); - unset($_POST ['np_marginRate']); - unset($_POST ['np_markRate']); - unset($_POST ['dp_desc']); - unset($_POST ['idprod']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); + // End of object creation, we show it + if ($object_id > 0 && ! $error) { + $db->commit(); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object_id); + exit(); } else { - setEventMessage($object->error, 'errors'); + $db->rollback(); + $action = 'create'; + if (! $mesg) + $mesg = '
' . $object->error . '
'; } } } -} -/* - * Mise a jour d'une ligne dans la commande -*/ -else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('save') == $langs->trans('Save')) { - // Clean parameters - $date_start=''; - $date_end=''; - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description=dol_htmlcleanlastbr(GETPOST('product_desc')); - $pu_ht=GETPOST('price_ht'); - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + else if ($action == 'classifybilled' && $user->rights->commande->creer) + { + $ret=$object->classifyBilled(); - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) - $info_bits |= 0x01; - - // Define vat_rate - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $object->client); - $localtax2_rate = get_localtax($vat_rate, 2, $object->client); - - // Add buying price - $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); - - // Extrafields Lines - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); - // Unset extrafield POST Data - if (is_array($extralabelsline)) { - foreach ($extralabelsline as $key => $value) { - unset($_POST ["options_" . $key]); + if ($ret < 0) { + setEventMessage($object->error, 'errors'); } } - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { - $product = new Product($db); - $product->fetch($productid); + // Positionne ref commande client + else if ($action == 'set_ref_client' && $user->rights->commande->creer) { + $object->set_ref_client($user, GETPOST('ref_client')); + } - $type = $product->type; + else if ($action == 'setremise' && $user->rights->commande->creer) { + $object->set_remise($user, GETPOST('remise')); + } - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - $price_min = $product->multiprices_min [$object->client->price_level]; - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - - if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; - } - } else { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - - // Check parameters - if (GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; + else if ($action == 'setabsolutediscount' && $user->rights->commande->creer) { + if (GETPOST('remise_id')) { + if ($object->id > 0) { + $object->insert_discount(GETPOST('remise_id')); + } else { + dol_print_error($db, $object->error); + } } } - if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); + else if ($action == 'setdate' && $user->rights->commande->creer) { + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); - if ($result >= 0) { + $result = $object->set_date($user, $date); + if ($result < 0) { + $mesg = '
' . $object->error . '
'; + } + } + + else if ($action == 'setdate_livraison' && $user->rights->commande->creer) { + // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + + $result = $object->set_date_livraison($user, $datelivraison); + if ($result < 0) { + $mesg = '
' . $object->error . '
'; + } + } + + else if ($action == 'setmode' && $user->rights->commande->creer) { + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setavailability' && $user->rights->commande->creer) { + $result = $object->availability(GETPOST('availability_id')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setdemandreason' && $user->rights->commande->creer) { + $result = $object->demand_reason(GETPOST('demand_reason_id')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setconditions' && $user->rights->commande->creer) { + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + if ($result < 0) { + dol_print_error($db, $object->error); + } else { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); + $newlang = GETPOST('lang_id', 'alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->client->default_lang; if (! empty($newlang)) { @@ -848,491 +494,848 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $ret = $object->fetch($object->id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } + } + } - unset($_POST ['qty']); - unset($_POST ['type']); - unset($_POST ['productid']); - unset($_POST ['remise_percent']); - unset($_POST ['price_ht']); - unset($_POST ['price_ttc']); - unset($_POST ['tva_tx']); - unset($_POST ['product_ref']); - unset($_POST ['product_label']); - unset($_POST ['product_desc']); - unset($_POST ['fournprice']); - unset($_POST ['buying_price']); + else if ($action == 'setremisepercent' && $user->rights->commande->creer) { + $result = $object->set_remise($user, GETPOST('remise_percent')); + } + + else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) { + $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); + } + + // Add a new line + else if ($action == 'addline' && $user->rights->commande->creer) { + $langs->load('errors'); + $error = 0; + + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } + + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST ["options_" . $key]); + } + } + + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error ++; + } + if ($qty == '') { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); + $error ++; + } + + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + // Clean parameters + $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), 0, GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), 0, GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + // Ecrase $base_price_type par celui du produit + if (! empty($idprod)) { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + + // Update if prices fields are defined + $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); + + // multiprix + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + { + $pu_ht = $prod->multiprices [$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc [$object->client->price_level]; + $price_min = $prod->multiprices_min [$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type [$object->client->price_level]; + if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) { + if (count($prodcustprice->lines) > 0) { + $found = true; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; + } else { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + } else { + setEventMessage($prodcustprice->error,'errors'); + } + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + + // if price ht is forced (ie: calculated by margin rate and cost price) + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $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). + elseif ($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'); + } + } + + $desc = ''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } else { + $desc = $prod->description; + } + + $desc = dol_concatdesc($desc, $product_desc); + + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + } + + $type = $prod->type; + } else { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->client); + $localtax2_tx = get_localtax($tva_tx, 2, $object->client); + + $desc = dol_htmlcleanlastbr($desc); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessage($mesg, 'errors'); + } else { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); + + if ($result > 0) { + $ret = $object->fetch($object->id); // Reload to get new records + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang = GETPOST('lang_id', 'alpha'); + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST ['prod_entry_mode']); + + unset($_POST ['qty']); + unset($_POST ['type']); + unset($_POST ['remise_percent']); + unset($_POST ['price_ht']); + unset($_POST ['price_ttc']); + unset($_POST ['tva_tx']); + unset($_POST ['product_ref']); + unset($_POST ['product_label']); + unset($_POST ['product_desc']); + unset($_POST ['fournprice']); + unset($_POST ['buying_price']); + unset($_POST ['np_marginRate']); + unset($_POST ['np_markRate']); + unset($_POST ['dp_desc']); + unset($_POST ['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + } else { + setEventMessage($object->error, 'errors'); + } + } + } + } + + /* + * Mise a jour d'une ligne dans la commande + */ + else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('save') == $langs->trans('Save')) { + // Clean parameters + $date_start=''; + $date_end=''; + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description=dol_htmlcleanlastbr(GETPOST('product_desc')); + $pu_ht=GETPOST('price_ht'); + $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) + $info_bits |= 0x01; + + // Define vat_rate + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->client); + $localtax2_rate = get_localtax($vat_rate, 2, $object->client); + + // Add buying price + $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : ''); + + // Extrafields Lines + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + // Unset extrafield POST Data + if (is_array($extralabelsline)) { + foreach ($extralabelsline as $key => $value) { + unset($_POST ["options_" . $key]); + } + } + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) { + $product = new Product($db); + $product->fetch($productid); + + $type = $product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + $price_min = $product->multiprices_min [$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); + + if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + $error ++; + } } else { - setEventMessage($object->error, 'errors'); - } - } -} + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); -else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('cancel') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition - exit(); -} - -else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { - $idwarehouse = GETPOST('idwarehouse'); - - $qualified_for_stock_change=0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change=$object->hasProductsOrServices(2); - } - else - { - $qualified_for_stock_change=$object->hasProductsOrServices(1); - } - - // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (! $idwarehouse || $idwarehouse == -1) - { - $error++; - $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; - $action=''; - } - } - - if (! $error) { - $result = $object->valid($user, $idwarehouse); - if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - } -} -// Go back to draft status -else if ($action == 'confirm_modif' && $user->rights->commande->creer) { - $idwarehouse = GETPOST('idwarehouse'); + if (! $error) { + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); - $qualified_for_stock_change=0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change=$object->hasProductsOrServices(2); - } - else - { - $qualified_for_stock_change=$object->hasProductsOrServices(1); - } + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (! $idwarehouse || $idwarehouse == -1) - { - $error++; - $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; - $action=''; - } - } + $ret = $object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } - if (! $error) { - $result = $object->set_draft($user, $idwarehouse); - if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + unset($_POST ['qty']); + unset($_POST ['type']); + unset($_POST ['productid']); + unset($_POST ['remise_percent']); + unset($_POST ['price_ht']); + unset($_POST ['price_ttc']); + unset($_POST ['tva_tx']); + unset($_POST ['product_ref']); + unset($_POST ['product_label']); + unset($_POST ['product_desc']); + unset($_POST ['fournprice']); + unset($_POST ['buying_price']); + } else { + setEventMessage($object->error, 'errors'); } } } -} -else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { - $result = $object->cloture($user); - if ($result < 0) { - setEventMessage($object->error, 'errors'); - } -} - -else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { - $idwarehouse = GETPOST('idwarehouse'); - - $qualified_for_stock_change=0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) - { - $qualified_for_stock_change=$object->hasProductsOrServices(2); - } - else - { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('cancel') == $langs->trans('Cancel')) { + header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + exit(); } - // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) - { - if (! $idwarehouse || $idwarehouse == -1) + else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { + $idwarehouse = GETPOST('idwarehouse'); + + $qualified_for_stock_change=0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $error++; - $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; - $action=''; + $qualified_for_stock_change=$object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change=$object->hasProductsOrServices(1); + } + + // Check parameters + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } + + if (! $error) { + $result = $object->valid($user, $idwarehouse); + if ($result >= 0) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } } } - if (! $error) { - $result = $object->cancel($idwarehouse); + // Go back to draft status + else if ($action == 'confirm_modif' && $user->rights->commande->creer) { + $idwarehouse = GETPOST('idwarehouse'); + $qualified_for_stock_change=0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change=$object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change=$object->hasProductsOrServices(1); + } + + // Check parameters + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } + + if (! $error) { + $result = $object->set_draft($user, $idwarehouse); + if ($result >= 0) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + } + } + + else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { + $result = $object->cloture($user); if ($result < 0) { setEventMessage($object->error, 'errors'); } } -} -/* - * Ordonnancement des lignes -*/ + else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { + $idwarehouse = GETPOST('idwarehouse'); -else if ($action == 'up' && $user->rights->commande->creer) { - $object->line_up(GETPOST('rowid')); + $qualified_for_stock_change=0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change=$object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change=$object->hasProductsOrServices(1); + } - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); + // Check parameters + if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + { + if (! $idwarehouse || $idwarehouse == -1) + { + $error++; + $mesgs[]='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")).'
'; + $action=''; + } + } + + if (! $error) { + $result = $object->cancel($idwarehouse); + + if ($result < 0) { + setEventMessage($object->error, 'errors'); + } + } } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); - exit(); -} - -else if ($action == 'down' && $user->rights->commande->creer) { - $object->line_down(GETPOST('rowid')); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); - exit(); -} - -else if ($action == 'builddoc') // In get or post -{ /* - * Generate order document - * define into /core/modules/commande/modules_commande.php - */ + * Ordonnancement des lignes + */ - // Save last template used to generate document - if (GETPOST('model')) - $object->setDocModel($user, GETPOST('model', 'alpha')); + else if ($action == 'up' && $user->rights->commande->creer) { + $object->line_up(GETPOST('rowid')); // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } - if ($result <= 0) { - dol_print_error($db, $result); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); exit(); } -} -// Remove file in doc form -else if ($action == 'remove_file') { - if ($object->id > 0) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + else if ($action == 'down' && $user->rights->commande->creer) { + $object->line_down(GETPOST('rowid')); - $langs->load("other"); - $upload_dir = $conf->commande->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '#' . GETPOST('rowid')); + exit(); + } + + else if ($action == 'builddoc') // In get or post + { + /* + * Generate order document + * define into /core/modules/commande/modules_commande.php + */ + + // Save last template used to generate document + if (GETPOST('model')) + $object->setDocModel($user, GETPOST('model', 'alpha')); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + if ($result <= 0) { + dol_print_error($db, $result); + exit(); + } + } + + // Remove file in doc form + else if ($action == 'remove_file') { + if ($object->id > 0) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $langs->load("other"); + $upload_dir = $conf->commande->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) + setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + $action = ''; + } + } + + // Print file + else if ($action == 'print_file' and $user->rights->printipp->read) { + require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; + $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); + $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); + setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); $action = ''; } -} -// Print file -else if ($action == 'print_file' and $user->rights->printipp->read) { - require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; - $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); - $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); - setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); - $action = ''; -} - -else if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; - - if (! $error) { - // Actions on extra fields (by external module or standard code) - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('orderdao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) + else if ($action == 'update_extras') { + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) $error ++; + + if (! $error) { + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('orderdao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + } + + if ($error) + $action = 'edit_extras'; } - if ($error) - $action = 'edit_extras'; -} + /* + * Add file in email form + */ + if (GETPOST('addfile')) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; -/* - * Add file in email form -*/ -if (GETPOST('addfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; + dol_add_file_process($upload_dir_tmp, 0, 0); + $action = 'presend'; + } - dol_add_file_process($upload_dir_tmp, 0, 0); - $action = 'presend'; -} + /* + * Remove file in email form + */ + if (GETPOST('removedfile')) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; -/* - * Remove file in email form -*/ -if (GETPOST('removedfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + // Set tmp user directory + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; - // Set tmp user directory - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; + // TODO Delete only files that was uploaded from email form + dol_remove_file_process(GETPOST('removedfile'), 0); + $action = 'presend'; + } - // TODO Delete only files that was uploaded from email form - dol_remove_file_process(GETPOST('removedfile'), 0); - $action = 'presend'; -} + /* + * Send mail + */ + if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { + $langs->load('mails'); -/* - * Send mail -*/ -if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) { - $langs->load('mails'); + if ($object->id > 0) { + // $ref = dol_sanitizeFileName($object->ref); + // $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - if ($object->id > 0) { - // $ref = dol_sanitizeFileName($object->ref); - // $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - - // if (is_readable($file)) - // { - if (GETPOST('sendto')) { - // Le destinataire a ete fourni via le champ libre - $sendto = GETPOST('sendto'); - $sendtoid = 0; - } elseif (GETPOST('receiver') != '-1') { - // Recipient was provided from combo list - if (GETPOST('receiver') == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; + // if (is_readable($file)) + // { + if (GETPOST('sendto')) { + // Le destinataire a ete fourni via le champ libre + $sendto = GETPOST('sendto'); $sendtoid = 0; - } else // Id du contact - { - $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email'); - $sendtoid = GETPOST('receiver'); - } - } - - if (dol_strlen($sendto)) { - $langs->load("commercial"); - - $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>'; - $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>'; - $message = GETPOST('message'); - $sendtocc = GETPOST('sendtocc'); - $deliveryreceipt = GETPOST('deliveryreceipt'); - - if ($action == 'send') { - if (dol_strlen(GETPOST('subject'))) - $subject = GETPOST('subject'); - else - $subject = $langs->transnoentities('Order') . ' ' . $object->ref; - $actiontypecode = 'AC_COM'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; + } elseif (GETPOST('receiver') != '-1') { + // Recipient was provided from combo list + if (GETPOST('receiver') == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } else // Id du contact + { + $sendto = $object->client->contact_get_property(GETPOST('receiver'), 'email'); + $sendtoid = GETPOST('receiver'); } - $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); } - // Create form object - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); + if (dol_strlen($sendto)) { + $langs->load("commercial"); - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles ['paths']; - $filename = $attachedfiles ['names']; - $mimetype = $attachedfiles ['mimes']; + $from = GETPOST('fromname') . ' <' . GETPOST('frommail') . '>'; + $replyto = GETPOST('replytoname') . ' <' . GETPOST('replytomail') . '>'; + $message = GETPOST('message'); + $sendtocc = GETPOST('sendtocc'); + $deliveryreceipt = GETPOST('deliveryreceipt'); - // Send mail - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); - if ($mailfile->error) { - $mesg = '
' . $mailfile->error . '
'; - } else { - $result = $mailfile->sendfile(); - if ($result) { - $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); // Must not - // contains " - - $error = 0; - - // Initialisation donnees - $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('ORDER_SENTBYMAIL', $object, $user, $langs, $conf); - if ($result < 0) { - $error ++; - $this->errors = $interface->errors; + if ($action == 'send') { + if (dol_strlen(GETPOST('subject'))) + $subject = GETPOST('subject'); + else + $subject = $langs->transnoentities('Order') . ' ' . $object->ref; + $actiontypecode = 'AC_COM'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + if ($message) { + $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; + $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; + $actionmsg .= $message; } - // Fin appel triggers + $actionmsg2 = $langs->transnoentities('Action' . $actiontypecode); + } - if ($error) { - dol_print_error($db); - } else { - // Redirect here - // This avoid sending mail twice if going out and then back to page - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&mesg=' . urlencode($mesg)); - exit(); - } + // Create form object + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles = $formmail->get_attached_files(); + $filepath = $attachedfiles ['paths']; + $filename = $attachedfiles ['names']; + $mimetype = $attachedfiles ['mimes']; + + // Send mail + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + if ($mailfile->error) { + $mesg = '
' . $mailfile->error . '
'; } else { - $langs->load("other"); - $mesg = '
'; - if ($mailfile->error) { - $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); - $mesg .= '
' . $mailfile->error; + $result = $mailfile->sendfile(); + if ($result) { + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); // Must not + // contains " + + $error = 0; + + // Initialisation donnees + $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('ORDER_SENTBYMAIL', $object, $user, $langs, $conf); + if ($result < 0) { + $error ++; + $this->errors = $interface->errors; + } + // Fin appel triggers + + if ($error) { + dol_print_error($db); + } else { + // Redirect here + // This avoid sending mail twice if going out and then back to page + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&mesg=' . urlencode($mesg)); + exit(); + } } else { - $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + $langs->load("other"); + $mesg = '
'; + if ($mailfile->error) { + $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); + $mesg .= '
' . $mailfile->error; + } else { + $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg .= '
'; } - $mesg .= '
'; + } + /* } + else + { + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + $action='presend'; + dol_syslog('Recipient email is empty'); + }*/ + } else { + $langs->load("errors"); + $mesg = '
' . $langs->trans('ErrorCantReadFile', $file) . '
'; + dol_syslog('Failed to read file: ' . $file); + } + } else { + $langs->load("other"); + $mesg = '
' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Order")) . '
'; + dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order"))); + } + } + + if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) { + if ($action == 'addcontact') { + if ($object->id > 0) { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); + } + + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + $mesg = '
' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '
'; + } else { + $mesg = '
' . $object->error . '
'; } } - /* } - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; - $action='presend'; - dol_syslog('Recipient email is empty'); - }*/ - } else { - $langs->load("errors"); - $mesg = '
' . $langs->trans('ErrorCantReadFile', $file) . '
'; - dol_syslog('Failed to read file: ' . $file); - } - } else { - $langs->load("other"); - $mesg = '
' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Order")) . '
'; - dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order"))); - } -} - -if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) { - if ($action == 'addcontact') { - if ($object->id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); } - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - $mesg = '
' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '
'; + // bascule du statut d'un contact + else if ($action == 'swapstatut') { + if ($object->id > 0) { + $result = $object->swapContactStatus(GETPOST('ligne')); } else { - $mesg = '
' . $object->error . '
'; + dol_print_error($db); } } - } - // bascule du statut d'un contact - else if ($action == 'swapstatut') { - if ($object->id > 0) { - $result = $object->swapContactStatus(GETPOST('ligne')); - } else { - dol_print_error($db); - } - } + // Efface un contact + else if ($action == 'deletecontact') { + $result = $object->delete_contact($lineid); - // Efface un contact - else if ($action == 'deletecontact') { - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - dol_print_error($db); + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + dol_print_error($db); + } } } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c6214f449cb..a3403e0d9dd 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -111,71 +111,1342 @@ $permissionnote = $user->rights->facture->creer; // Used by the include of actio $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once +if (empty($reshook)) { -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) { - if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { - $mesgs [] = '
' . $langs->trans("NoCloneOptionsSpecified") . '
'; - } else { - if ($object->fetch($id) > 0) { - $result = $object->createFromClone($socid); + include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once + + // Action clone object + if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) { + if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { + $mesgs [] = '
' . $langs->trans("NoCloneOptionsSpecified") . '
'; + } else { + if ($object->fetch($id) > 0) { + $result = $object->createFromClone($socid); + if ($result > 0) { + header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); + exit(); + } else { + setEventMessage($object->error, 'errors'); + $action = ''; + } + } + } + } + + // Change status of invoice + else if ($action == 'reopen' && $user->rights->facture->creer) { + $result = $object->fetch($id); + if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced')) { + $result = $object->set_unpaid($user); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); exit(); } else { setEventMessage($object->error, 'errors'); + } + } + } + + // Delete invoice + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) { + $result = $object->fetch($id); + $object->fetch_thirdparty(); + + $idwarehouse = GETPOST('idwarehouse'); + + $qualified_for_stock_change = 0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } else { + $qualified_for_stock_change = $object->hasProductsOrServices(1); + } + + $result = $object->delete(0, 0, $idwarehouse); + if ($result > 0) { + header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php'); + exit(); + } else { + setEventMessage($object->error, 'errors'); + $action=''; + } + } + + // Delete line + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { + $object->fetch($id); + $object->fetch_thirdparty(); + + $result = $object->deleteline($_GET ['lineid'], $user); + if ($result > 0) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($id); // Reload to get new records + $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + if ($result >= 0) { + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + exit(); + } + } else { + setEventMessage($object->error, 'errors'); + $action = ''; + } + } + + // Delete link of credit note to invoice + else if ($action == 'unlinkdiscount' && $user->rights->facture->creer) { + $discount = new DiscountAbsolute($db); + $result = $discount->fetch($_GET ["discountid"]); + $discount->unlink_invoice(); + } + + // Validation + else if ($action == 'valid' && $user->rights->facture->creer) { + $object->fetch($id); + + // On verifie signe facture + if ($object->type == Facture::TYPE_CREDIT_NOTE) { + // Si avoir, le signe doit etre negatif + if ($object->total_ht >= 0) { + $mesgs [] = '
' . $langs->trans("ErrorInvoiceAvoirMustBeNegative") . '
'; + $action = ''; + } + } else { + // Si non avoir, le signe doit etre positif + if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) { + $mesgs [] = '
' . $langs->trans("ErrorInvoiceOfThisTypeMustBePositive") . '
'; $action = ''; } } } -} -// Change status of invoice -else if ($action == 'reopen' && $user->rights->facture->creer) { - $result = $object->fetch($id); - if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced')) { - $result = $object->set_unpaid($user); - if ($result > 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); - exit(); - } else { - setEventMessage($object->error, 'errors'); + else if ($action == 'set_thirdparty' && $user->rights->facture->creer) { + $object->fetch($id); + $object->setValueFrom('fk_soc', $socid); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + exit(); + } + + else if ($action == 'classin' && $user->rights->facture->creer) { + $object->fetch($id); + $object->setProject($_POST['projectid']); + } + + else if ($action == 'setmode' && $user->rights->facture->creer) { + $object->fetch($id); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setinvoicedate' && $user->rights->facture->creer) + { + $object->fetch($id); + $old_date_lim_reglement = $object->date_lim_reglement; + $date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); + if (empty($date)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); + exit; + } + $object->date=$date; + $new_date_lim_reglement = $object->calculate_date_lim_reglement(); + if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; + if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; + $result = $object->update($user); + if ($result < 0) dol_print_error($db, $object->error); + } + + else if ($action == 'setconditions' && $user->rights->facture->creer) { + $object->fetch($id); + $object->cond_reglement_code = 0; // To clean property + $object->cond_reglement_id = 0; // To clean property + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + if ($result < 0) dol_print_error($db, $object->error); + + $old_date_lim_reglement = $object->date_lim_reglement; + $new_date_lim_reglement = $object->calculate_date_lim_reglement(); + if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; + if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; + $result = $object->update($user); + if ($result < 0) dol_print_error($db, $object->error); + } + + else if ($action == 'setpaymentterm' && $user->rights->facture->creer) { + $object->fetch($id); + $object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']); + if ($object->date_lim_reglement < $object->date) { + $object->date_lim_reglement = $object->calculate_date_lim_reglement(); + setEventMessage($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), 'warnings'); + } + $result = $object->update($user); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setrevenuestamp' && $user->rights->facture->creer) { + $object->fetch($id); + $object->revenuestamp = GETPOST('revenuestamp'); + $result = $object->update($user); + $object->update_price(1); + if ($result < 0) + dol_print_error($db, $object->error); + } + + else if ($action == 'setremisepercent' && $user->rights->facture->creer) { + $object->fetch($id); + $result = $object->set_remise($user, $_POST['remise_percent']); + } + + else if ($action == "setabsolutediscount" && $user->rights->facture->creer) { + // POST[remise_id] ou POST[remise_id_for_payment] + if (! empty($_POST["remise_id"])) { + $ret = $object->fetch($id); + if ($ret > 0) { + $result = $object->insert_discount($_POST["remise_id"]); + if ($result < 0) { + $mesgs [] = '
' . $object->error . '
'; + } + } else { + dol_print_error($db, $object->error); + } + } + if (! empty($_POST["remise_id_for_payment"])) { + require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + $discount = new DiscountAbsolute($db); + $discount->fetch($_POST["remise_id_for_payment"]); + + $result = $discount->link_to_invoice(0, $id); + if ($result < 0) { + $mesgs [] = '
' . $discount->error . '
'; + } } } -} -// Delete invoice -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) { - $result = $object->fetch($id); - $object->fetch_thirdparty(); - - $idwarehouse = GETPOST('idwarehouse'); - - $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + else if ($action == 'set_ref_client' && $user->rights->facture->creer) { + $object->fetch($id); + $object->set_ref_client($_POST['ref_client']); } - $result = $object->delete(0, 0, $idwarehouse); - if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php'); + // Classify to validated + else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) + { + $idwarehouse = GETPOST('idwarehouse'); + + $object->fetch($id); + $object->fetch_thirdparty(); + + // Check parameters + + // Check for mandatory prof id + for($i = 1; $i < 6; $i ++) + { + $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; + $idprof = 'idprof' . $i; + if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) { + if (! $error) + $langs->load("errors"); + $error ++; + + setEventMessage($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), 'errors'); + } + } + + $qualified_for_stock_change = 0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } else { + $qualified_for_stock_change = $object->hasProductsOrServices(1); + } + + // Check for warehouse + if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) { + if (! $idwarehouse || $idwarehouse == - 1) { + $error ++; + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors'); + $action = ''; + } + } + + if (! $error) + { + $result = $object->validate($user, '', $idwarehouse); + if ($result >= 0) + { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($id); // Reload to get new records + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } else { + if (count($object->errors)) setEventMessage($object->errors, 'errors'); + else setEventMessage($object->error, 'errors'); + } + } + } + + // Go back to draft status (unvalidate) + else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) { + $idwarehouse = GETPOST('idwarehouse'); + + $object->fetch($id); + $object->fetch_thirdparty(); + + $qualified_for_stock_change = 0; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } else { + $qualified_for_stock_change = $object->hasProductsOrServices(1); + } + + // Check parameters + if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) { + if (! $idwarehouse || $idwarehouse == - 1) { + $error ++; + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors'); + $action = ''; + } + } + + if (! $error) { + // On verifie si la facture a des paiements + $sql = 'SELECT pf.amount'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf'; + $sql .= ' WHERE pf.fk_facture = ' . $object->id; + + $result = $db->query($sql); + if ($result) { + $i = 0; + $num = $db->num_rows($result); + + while ($i < $num) { + $objp = $db->fetch_object($result); + $totalpaye += $objp->amount; + $i ++; + } + } else { + dol_print_error($db, ''); + } + + $resteapayer = $object->total_ttc - $totalpaye; + + // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees + $ventilExportCompta = $object->getVentilExportCompta(); + + // On verifie si aucun paiement n'a ete effectue + if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) { + $result=$object->set_draft($user, $idwarehouse); + if ($result<0) setEventMessage($object->error,'errors'); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($id); // Reload to get new records + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + } + } + + // Classify "paid" + else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) { + $object->fetch($id); + $result = $object->set_paid($user); + if ($result<0) setEventMessage($object->error,'errors'); + } // Classif "paid partialy" + else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) { + $object->fetch($id); + $close_code = $_POST["close_code"]; + $close_note = $_POST["close_note"]; + if ($close_code) { + $result = $object->set_paid($user, $close_code, $close_note); + if ($result<0) setEventMessage($object->error,'errors'); + } else { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors'); + } + } // Classify "abandoned" + else if ($action == 'confirm_canceled' && $confirm == 'yes') { + $object->fetch($id); + $close_code = $_POST["close_code"]; + $close_note = $_POST["close_note"]; + if ($close_code) { + $result = $object->set_canceled($user, $close_code, $close_note); + if ($result<0) setEventMessage($object->error,'errors'); + } else { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors'); + } + } + + // Convertir en reduc + else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) + { + $object->fetch($id); + $object->fetch_thirdparty(); + //$object->fetch_lines(); // Already done into fetch + + // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) + $discountcheck=new DiscountAbsolute($db); + $result=$discountcheck->fetch(0,$object->id); + + $canconvert=0; + if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed completely and not already converted (see real condition into condition used to show button converttoreduc) + if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + if ($canconvert) + { + $db->begin(); + + // Boucle sur chaque taux de tva + $i = 0; + foreach ($object->lines as $line) { + $amount_ht [$line->tva_tx] += $line->total_ht; + $amount_tva [$line->tva_tx] += $line->total_tva; + $amount_ttc [$line->tva_tx] += $line->total_ttc; + $i ++; + } + + // Insert one discount by VAT rate category + $discount = new DiscountAbsolute($db); + if ($object->type == Facture::TYPE_CREDIT_NOTE) + $discount->description = '(CREDIT_NOTE)'; + elseif ($object->type == Facture::TYPE_DEPOSIT) + $discount->description = '(DEPOSIT)'; + else { + setEventMessage($langs->trans('CantConvertToReducAnInvoiceOfThisType'),'errors'); + } + $discount->tva_tx = abs($object->total_ttc); + $discount->fk_soc = $object->socid; + $discount->fk_facture_source = $object->id; + + $error = 0; + foreach ($amount_ht as $tva_tx => $xxx) { + $discount->amount_ht = abs($amount_ht [$tva_tx]); + $discount->amount_tva = abs($amount_tva [$tva_tx]); + $discount->amount_ttc = abs($amount_ttc [$tva_tx]); + $discount->tva_tx = abs($tva_tx); + + $result = $discount->create($user); + if ($result < 0) + { + $error++; + break; + } + } + + if (empty($error)) + { + // Classe facture + $result = $object->set_paid($user); + if ($result >= 0) + { + //$mesgs[]='OK'.$discount->id; + $db->commit(); + } + else + { + setEventMessage($object->error,'errors'); + $db->rollback(); + } + } + else + { + setEventMessage($discount->error,'errors'); + $db->rollback(); + } + } + } + + /* + * Insert new invoice in database + */ + else if ($action == 'add' && $user->rights->facture->creer) + { + if ($socid > 0) $object->socid = GETPOST('socid', 'int'); + + $db->begin(); + + $error = 0; + + // Fill array 'array_options' with data from add form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error ++; + + // Replacement invoice + if ($_POST['type'] == Facture::TYPE_REPLACEMENT) + { + $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($dateinvoice)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + } + + if (! ($_POST['fac_replacement'] > 0)) { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), 'errors'); + } + + if (! $error) { + // This is a replacement invoice + $result = $object->fetch($_POST['fac_replacement']); + $object->fetch_thirdparty(); + + $object->date = $dateinvoice; + $object->note_public = trim($_POST['note_public']); + $object->note = trim($_POST['note']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = $_POST['cond_reglement_id']; + $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->remise_absolue = $_POST['remise_absolue']; + $object->remise_percent = $_POST['remise_percent']; + + // Proprietes particulieres a facture de remplacement + $object->fk_facture_source = $_POST['fac_replacement']; + $object->type = Facture::TYPE_REPLACEMENT; + + $id = $object->createFromCurrent($user); + if ($id <= 0) + $mesgs [] = $object->error; + } + } + + // Credit note invoice + if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE) + { + if (! ($_POST['fac_avoir'] > 0)) + { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), 'errors'); + } + + $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($dateinvoice)) + { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->trans("Date")), 'errors'); + } + + if (! $error) + { + $object->socid = GETPOST('socid','int'); + $object->number = $_POST['facnumber']; + $object->date = $dateinvoice; + $object->note_public = trim($_POST['note_public']); + $object->note = trim($_POST['note']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = 0; + $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->remise_absolue = $_POST['remise_absolue']; + $object->remise_percent = $_POST['remise_percent']; + + // Proprietes particulieres a facture avoir + $object->fk_facture_source = $_POST['fac_avoir']; + $object->type = Facture::TYPE_CREDIT_NOTE; + + $id = $object->create($user); + + if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + { + $facture_source = new Facture($db); // fetch origin object + if ($facture_source->fetch($object->fk_facture_source)>0) + { + + foreach($facture_source->lines as $line) + { + $line->fk_facture = $object->id; + + $line->subprice =-$line->subprice; // invert price for object + $line->pa_ht = -$line->pa_ht; + $line->total_ht=-$line->total_ht; + $line->total_tva=-$line->total_tva; + $line->total_ttc=-$line->total_ttc; + $line->total_localtax1=-$line->total_localtax1; + $line->total_localtax2=-$line->total_localtax2; + + $line->insert(); + + $object->lines[] = $line; // insert new line in current object + } + + $object->update_price(1); + } + + } + + if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) { + + $facture_source = new Facture($db); // fetch origin object if not previously defined + if($facture_source->fetch($object->fk_facture_source)>0) { + $totalpaye = $facture_source->getSommePaiement(); + $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); + $totaldeposits = $facture_source->getSumDepositsUsed(); + $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); + + $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); + } + } + + // Add predefined lines + /* + TODO delete + for($i = 1; $i <= $NBLINES; $i ++) { + if ($_POST['idprod' . $i]) { + $product = new Product($db); + $product->fetch($_POST['idprod' . $i]); + $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); + $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); + $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); + } + }*/ + } + } + + // Standard invoice or Deposit invoice created from a Predefined invoice + if (($_POST['type'] == 0 || $_POST['type'] == 3) && $_POST['fac_rec'] > 0) + { + $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($dateinvoice)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + } + + if (! $error) + { + $object->socid = GETPOST('socid','int'); + $object->type = $_POST['type']; + $object->number = $_POST['facnumber']; + $object->date = $dateinvoice; + $object->note_public = trim($_POST['note_public']); + $object->note_private = trim($_POST['note_private']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + + // Source facture + $object->fac_rec = $_POST['fac_rec']; + + $id = $object->create($user); + } + } + + // Standard or deposit or proforma invoice + if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0) + { + if (GETPOST('socid', 'int') < 1) + { + $error ++; + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); + } + + $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($dateinvoice)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + } + + if (! $error) + { + // Si facture standard + $object->socid = GETPOST('socid','int'); + $object->type = GETPOST('type'); + $object->number = $_POST['facnumber']; + $object->date = $dateinvoice; + $object->note_public = trim($_POST['note_public']); + $object->note_private = trim($_POST['note_private']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); + $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->amount = $_POST['amount']; + $object->remise_absolue = $_POST['remise_absolue']; + $object->remise_percent = $_POST['remise_percent']; + + $object->fetch_thirdparty(); + + // If creation from another object of another module (Example: origin=propal, originid=1) + 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 == 'inter') { + $element = $subelement = 'ficheinter'; + } + if ($element == 'shipping') { + $element = $subelement = 'expedition'; + } + + $object->origin = $_POST['origin']; + $object->origin_id = $_POST['originid']; + + // Possibility to add external linked objects with hooks + $object->linked_objects [$object->origin] = $object->origin_id; + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { + $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + } + + $id = $object->create($user); + + if ($id > 0) + { + // If deposit invoice + if ($_POST['type'] == 3) + { + $typeamount = GETPOST('typedeposit', 'alpha'); + $valuedeposit = GETPOST('valuedeposit', 'int'); + + if ($typeamount == 'amount') + { + $amountdeposit = $valuedeposit; + } + else + { + $amountdeposit = 0; + + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add deposit lines"); + $result = $srcobject->fetch($object->origin_id); + if ($result > 0) + { + $totalamount = 0; + $lines = $srcobject->lines; + $numlines=count($lines); + for ($i=0; $i<$numlines; $i++) + { + $qualified=1; + if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option + if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) + if ($qualified) $totalamount += $lines[$i]->total_ht; + } + + if ($totalamount != 0) { + $amountdeposit = ($totalamount * $valuedeposit) / 100; + } + } else { + $mesgs [] = $srcobject->error; + $error ++; + } + } + + $result = $object->addline( + $langs->trans('Deposit'), + $amountdeposit, // subprice + 1, // quantity + $lines [$i]->tva_tx, 0, // localtax1_tx + 0, // localtax2_tx + 0, // fk_product + 0, // remise_percent + 0, // date_start + 0, // date_end + 0, $lines [$i]->info_bits, // info_bits + 0, // info_bits + 'HT', + 0, + 0, // product_type + 1, + $lines [$i]->special_code, + $object->origin, + 0, + 0, + 0, + 0, + $langs->trans('Deposit') + ); + } + else + { + + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + { + $srcobject->fetch_lines(); + $lines = $srcobject->lines; + } + + $fk_parent_line=0; + $num=count($lines); + for ($i=0;$i<$num;$i++) + { + $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); + $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + + if ($lines [$i]->subprice < 0) + { + // Negative line, we create a discount line + $discount = new DiscountAbsolute($db); + $discount->fk_soc = $object->socid; + $discount->amount_ht = abs($lines [$i]->total_ht); + $discount->amount_tva = abs($lines [$i]->total_tva); + $discount->amount_ttc = abs($lines [$i]->total_ttc); + $discount->tva_tx = $lines [$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); + if ($discountid > 0) { + $result = $object->insert_discount($discountid); // This include link_to_invoice + } else { + $mesgs [] = $discount->error; + $error ++; + break; + } + } else { + // Positive line + $product_type = ($lines [$i]->product_type ? $lines [$i]->product_type : 0); + + // Date start + $date_start = false; + if ($lines [$i]->date_debut_prevue) + $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 + $date_end = false; + if ($lines [$i]->date_fin_prevue) + $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; + + // Reset fk_parent_line for no child products and special product + if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) { + $lines [$i]->fetch_optionals($lines [$i]->rowid); + $array_option = $lines [$i]->array_options; + } + + $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $date_start, $date_end, 0, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $object->origin, $lines [$i]->rowid, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); + + if ($result > 0) { + $lineid = $result; + } else { + $lineid = 0; + $error ++; + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines [$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) + $error ++; + } else { + $mesgs [] = $srcobject->error; + $error ++; + } + } + } else { + $mesgs [] = $object->error; + $error ++; + } + } // If some invoice's lines already known + else { + $id = $object->create($user); + + for($i = 1; $i <= $NBLINES; $i ++) { + if ($_POST['idprod' . $i]) { + $product = new Product($db); + $product->fetch($_POST['idprod' . $i]); + $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); + $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); + $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); + } + } + } + } + } + + // End of object creation, we show it + if ($id > 0 && ! $error) + { + $db->commit(); + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + exit(); + } + else + { + $db->rollback(); + $action = 'create'; + $_GET ["origin"] = $_POST["origin"]; + $_GET ["originid"] = $_POST["originid"]; + $mesgs [] = '
' . $object->error . '
'; + } + } + + // Add a new line + else if ($action == 'addline' && $user->rights->facture->creer) + { + $langs->load('errors'); + $error = 0; + + // Set if we used free entry or predefined product + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $price_ht = GETPOST('price_ht'); + if (GETPOST('prod_entry_mode') == 'free') + { + $idprod=0; + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { + $idprod=GETPOST('idprod', 'int'); + $tva_tx = ''; + } + + $qty = GETPOST('qty' . $predef); + $remise_percent = GETPOST('remise_percent' . $predef); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key . $predef]); + } + } + + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error ++; + } + if ($qty == '') { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error ++; + } + if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { + setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); + $error ++; + } + + if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + $ret = $object->fetch($id); + if ($ret < 0) { + dol_print_error($db, $object->error); + exit(); + } + $ret = $object->fetch_thirdparty(); + + // Clean parameters + $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); + + // Define special_code for special lines + $special_code = 0; + // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + // Ecrase $base_price_type par celui du produit + if (! empty($idprod)) { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); + + // Update if prices fields are defined + $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); + $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); + + // We define price for product + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + { + $pu_ht = $prod->multiprices[$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; + $price_min = $prod->multiprices_min[$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; + } + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + + $prodcustprice = new Productcustomerprice($db); + + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); + if ($result >= 0) { + if (count($prodcustprice->lines) > 0) { + $found = true; + $pu_ht = price($prodcustprice->lines[0]->price); + $pu_ttc = price($prodcustprice->lines[0]->price_ttc); + $price_base_type = $prodcustprice->lines[0]->price_base_type; + $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; + }else { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + } else { + setEventMessage($prodcustprice->error,'errors'); + } + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + + // if price ht is forced (ie: calculated by margin rate and cost price) + if (! empty($price_ht)) { + $pu_ht = price2num($price_ht, 'MU'); + $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). + elseif ($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'); + } + } + + $desc = ''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if (empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + } else { + $desc = $prod->description; + } + + $desc = dol_concatdesc($desc, $product_desc); + + // Add custom code and origin country into description + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + $tmptxt = '('; + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + $tmptxt .= ')'; + $desc = dol_concatdesc($desc, $tmptxt); + } + + $type = $prod->type; + } else { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); + $buyingprice = price2num(GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $object->client); + $localtax2_tx = get_localtax($tva_tx, 2, $object->client); + + $info_bits = 0; + if ($tva_npr) + $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { + $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); + setEventMessage($mesg, 'errors'); + } else { + // Insert line + $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); + + if ($result > 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang = GETPOST('lang_id', 'alpha'); + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $ret = $object->fetch($id); // Reload to get new records + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST ['prod_entry_mode']); + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + } else { + setEventMessage($object->error, 'errors'); + } + + $action = ''; + } + } + } + + elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) { + if (! $object->fetch($id) > 0) + dol_print_error($db); + $object->fetch_thirdparty(); + + // Clean parameters + $date_start = ''; + $date_end = ''; + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc')); + $pu_ht = GETPOST('price_ht'); + $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) + $info_bits |= 0x01; + + // Define vat_rate + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $object->client); + $localtax2_rate = get_localtax($vat_rate, 2, $object->client); + + // Add buying price + $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $buyingprice = price2num(GETPOST('buying_price') ? GETPOST('buying_price') : ''); + + // Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + // Unset extrafield + if (is_array($extralabelsline)) { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); + } + } + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) { + $product = new Product($db); + $product->fetch($productid); + + $type = $product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + $price_min = $product->multiprices_min [$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); + + // Check price is not lower than minimum (check is done only for standard or replacement invoices) + if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + $error ++; + } + } else { + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); + $error ++; + } + } + + // Update line + if (! $error) { + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); + + if ($result >= 0) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) + $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + + $ret = $object->fetch($id); // Reload to get new records + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + } else { + setEventMessage($object->error, 'errors'); + } + } + } + + else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition exit(); - } else { - setEventMessage($object->error, 'errors'); - $action=''; } -} -// Delete line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); + // Modify line position (up) + else if ($action == 'up' && $user->rights->facture->creer) { + $object->fetch($id); + $object->fetch_thirdparty(); + $object->line_up($_GET ['rowid']); - $result = $object->deleteline($_GET ['lineid'], $user); - if ($result > 0) { // Define output language $outputlangs = $langs; $newlang = ''; @@ -187,1626 +1458,358 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($id); // Reload to get new records - $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '#' . $_GET ['rowid']); + exit(); + } // Modify line position (down) + else if ($action == 'down' && $user->rights->facture->creer) { + $object->fetch($id); + $object->fetch_thirdparty(); + $object->line_down($_GET ['rowid']); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); } - if ($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); - exit(); - } - } else { - setEventMessage($object->error, 'errors'); - $action = ''; - } -} + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); -// Delete link of credit note to invoice -else if ($action == 'unlinkdiscount' && $user->rights->facture->creer) { - $discount = new DiscountAbsolute($db); - $result = $discount->fetch($_GET ["discountid"]); - $discount->unlink_invoice(); -} - -// Validation -else if ($action == 'valid' && $user->rights->facture->creer) { - $object->fetch($id); - - // On verifie signe facture - if ($object->type == Facture::TYPE_CREDIT_NOTE) { - // Si avoir, le signe doit etre negatif - if ($object->total_ht >= 0) { - $mesgs [] = '
' . $langs->trans("ErrorInvoiceAvoirMustBeNegative") . '
'; - $action = ''; - } - } else { - // Si non avoir, le signe doit etre positif - if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) { - $mesgs [] = '
' . $langs->trans("ErrorInvoiceOfThisTypeMustBePositive") . '
'; - $action = ''; - } - } -} - -else if ($action == 'set_thirdparty' && $user->rights->facture->creer) { - $object->fetch($id); - $object->setValueFrom('fk_soc', $socid); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); - exit(); -} - -else if ($action == 'classin' && $user->rights->facture->creer) { - $object->fetch($id); - $object->setProject($_POST['projectid']); -} - -else if ($action == 'setmode' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setinvoicedate' && $user->rights->facture->creer) -{ - $object->fetch($id); - $old_date_lim_reglement = $object->date_lim_reglement; - $date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); - if (empty($date)) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); - exit; - } - $object->date=$date; - $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; - if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; - $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); -} - -else if ($action == 'setconditions' && $user->rights->facture->creer) { - $object->fetch($id); - $object->cond_reglement_code = 0; // To clean property - $object->cond_reglement_id = 0; // To clean property - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) dol_print_error($db, $object->error); - - $old_date_lim_reglement = $object->date_lim_reglement; - $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; - if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; - $result = $object->update($user); - if ($result < 0) dol_print_error($db, $object->error); -} - -else if ($action == 'setpaymentterm' && $user->rights->facture->creer) { - $object->fetch($id); - $object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']); - if ($object->date_lim_reglement < $object->date) { - $object->date_lim_reglement = $object->calculate_date_lim_reglement(); - setEventMessage($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), 'warnings'); - } - $result = $object->update($user); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setrevenuestamp' && $user->rights->facture->creer) { - $object->fetch($id); - $object->revenuestamp = GETPOST('revenuestamp'); - $result = $object->update($user); - $object->update_price(1); - if ($result < 0) - dol_print_error($db, $object->error); -} - -else if ($action == 'setremisepercent' && $user->rights->facture->creer) { - $object->fetch($id); - $result = $object->set_remise($user, $_POST['remise_percent']); -} - -else if ($action == "setabsolutediscount" && $user->rights->facture->creer) { - // POST[remise_id] ou POST[remise_id_for_payment] - if (! empty($_POST["remise_id"])) { - $ret = $object->fetch($id); - if ($ret > 0) { - $result = $object->insert_discount($_POST["remise_id"]); - if ($result < 0) { - $mesgs [] = '
' . $object->error . '
'; - } - } else { - dol_print_error($db, $object->error); - } - } - if (! empty($_POST["remise_id_for_payment"])) { - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; - $discount = new DiscountAbsolute($db); - $discount->fetch($_POST["remise_id_for_payment"]); - - $result = $discount->link_to_invoice(0, $id); - if ($result < 0) { - $mesgs [] = '
' . $discount->error . '
'; - } - } -} - -else if ($action == 'set_ref_client' && $user->rights->facture->creer) { - $object->fetch($id); - $object->set_ref_client($_POST['ref_client']); -} - -// Classify to validated -else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) -{ - $idwarehouse = GETPOST('idwarehouse'); - - $object->fetch($id); - $object->fetch_thirdparty(); - - // Check parameters - - // Check for mandatory prof id - for($i = 1; $i < 6; $i ++) - { - $idprof_mandatory = 'SOCIETE_IDPROF' . ($i) . '_INVOICE_MANDATORY'; - $idprof = 'idprof' . $i; - if (! $object->thirdparty->$idprof && ! empty($conf->global->$idprof_mandatory)) { - if (! $error) - $langs->load("errors"); - $error ++; - - setEventMessage($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId' . $i, $object->thirdparty->country_code)), 'errors'); - } - } - - $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); - } - - // Check for warehouse - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == - 1) { - $error ++; - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors'); - $action = ''; - } - } - - if (! $error) - { - $result = $object->validate($user, '', $idwarehouse); - if ($result >= 0) - { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } else { - if (count($object->errors)) setEventMessage($object->errors, 'errors'); - else setEventMessage($object->error, 'errors'); - } - } -} - -// Go back to draft status (unvalidate) -else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) { - $idwarehouse = GETPOST('idwarehouse'); - - $object->fetch($id); - $object->fetch_thirdparty(); - - $qualified_for_stock_change = 0; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); - } - - // Check parameters - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == - 1) { - $error ++; - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), 'errors'); - $action = ''; - } - } - - if (! $error) { - // On verifie si la facture a des paiements - $sql = 'SELECT pf.amount'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf'; - $sql .= ' WHERE pf.fk_facture = ' . $object->id; - - $result = $db->query($sql); - if ($result) { - $i = 0; - $num = $db->num_rows($result); - - while ($i < $num) { - $objp = $db->fetch_object($result); - $totalpaye += $objp->amount; - $i ++; - } - } else { - dol_print_error($db, ''); - } - - $resteapayer = $object->total_ttc - $totalpaye; - - // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees - $ventilExportCompta = $object->getVentilExportCompta(); - - // On verifie si aucun paiement n'a ete effectue - if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) { - $result=$object->set_draft($user, $idwarehouse); - if ($result<0) setEventMessage($object->error,'errors'); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - } -} - -// Classify "paid" -else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) { - $object->fetch($id); - $result = $object->set_paid($user); - if ($result<0) setEventMessage($object->error,'errors'); -} // Classif "paid partialy" -else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) { - $object->fetch($id); - $close_code = $_POST["close_code"]; - $close_note = $_POST["close_note"]; - if ($close_code) { - $result = $object->set_paid($user, $close_code, $close_note); - if ($result<0) setEventMessage($object->error,'errors'); - } else { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors'); - } -} // Classify "abandoned" -else if ($action == 'confirm_canceled' && $confirm == 'yes') { - $object->fetch($id); - $close_code = $_POST["close_code"]; - $close_note = $_POST["close_note"]; - if ($close_code) { - $result = $object->set_canceled($user, $close_code, $close_note); - if ($result<0) setEventMessage($object->error,'errors'); - } else { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors'); - } -} - -// Convertir en reduc -else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) -{ - $object->fetch($id); - $object->fetch_thirdparty(); - //$object->fetch_lines(); // Already done into fetch - - // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) - $discountcheck=new DiscountAbsolute($db); - $result=$discountcheck->fetch(0,$object->id); - - $canconvert=0; - if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed completely and not already converted (see real condition into condition used to show button converttoreduc) - if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) - if ($canconvert) - { - $db->begin(); - - // Boucle sur chaque taux de tva - $i = 0; - foreach ($object->lines as $line) { - $amount_ht [$line->tva_tx] += $line->total_ht; - $amount_tva [$line->tva_tx] += $line->total_tva; - $amount_ttc [$line->tva_tx] += $line->total_ttc; - $i ++; - } - - // Insert one discount by VAT rate category - $discount = new DiscountAbsolute($db); - if ($object->type == Facture::TYPE_CREDIT_NOTE) - $discount->description = '(CREDIT_NOTE)'; - elseif ($object->type == Facture::TYPE_DEPOSIT) - $discount->description = '(DEPOSIT)'; - else { - setEventMessage($langs->trans('CantConvertToReducAnInvoiceOfThisType'),'errors'); - } - $discount->tva_tx = abs($object->total_ttc); - $discount->fk_soc = $object->socid; - $discount->fk_facture_source = $object->id; - - $error = 0; - foreach ($amount_ht as $tva_tx => $xxx) { - $discount->amount_ht = abs($amount_ht [$tva_tx]); - $discount->amount_tva = abs($amount_tva [$tva_tx]); - $discount->amount_ttc = abs($amount_ttc [$tva_tx]); - $discount->tva_tx = abs($tva_tx); - - $result = $discount->create($user); - if ($result < 0) - { - $error++; - break; - } - } - - if (empty($error)) - { - // Classe facture - $result = $object->set_paid($user); - if ($result >= 0) - { - //$mesgs[]='OK'.$discount->id; - $db->commit(); - } - else - { - setEventMessage($object->error,'errors'); - $db->rollback(); - } - } - else - { - setEventMessage($discount->error,'errors'); - $db->rollback(); - } - } -} - -/* - * Insert new invoice in database -*/ -else if ($action == 'add' && $user->rights->facture->creer) -{ - if ($socid > 0) $object->socid = GETPOST('socid', 'int'); - - $db->begin(); - - $error = 0; - - // Fill array 'array_options' with data from add form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) $error ++; - - // Replacement invoice - if ($_POST['type'] == Facture::TYPE_REPLACEMENT) - { - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($dateinvoice)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); - } - - if (! ($_POST['fac_replacement'] > 0)) { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), 'errors'); - } - - if (! $error) { - // This is a replacement invoice - $result = $object->fetch($_POST['fac_replacement']); - $object->fetch_thirdparty(); - - $object->date = $dateinvoice; - $object->note_public = trim($_POST['note_public']); - $object->note = trim($_POST['note']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = $_POST['cond_reglement_id']; - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - // Proprietes particulieres a facture de remplacement - $object->fk_facture_source = $_POST['fac_replacement']; - $object->type = Facture::TYPE_REPLACEMENT; - - $id = $object->createFromCurrent($user); - if ($id <= 0) - $mesgs [] = $object->error; - } - } - - // Credit note invoice - if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE) - { - if (! ($_POST['fac_avoir'] > 0)) - { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), 'errors'); - } - - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($dateinvoice)) - { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->trans("Date")), 'errors'); - } - - if (! $error) - { - $object->socid = GETPOST('socid','int'); - $object->number = $_POST['facnumber']; - $object->date = $dateinvoice; - $object->note_public = trim($_POST['note_public']); - $object->note = trim($_POST['note']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = 0; - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - // Proprietes particulieres a facture avoir - $object->fk_facture_source = $_POST['fac_avoir']; - $object->type = Facture::TYPE_CREDIT_NOTE; - - $id = $object->create($user); - - if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) - { - $facture_source = new Facture($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source)>0) - { - - foreach($facture_source->lines as $line) - { - $line->fk_facture = $object->id; - - $line->subprice =-$line->subprice; // invert price for object - $line->pa_ht = -$line->pa_ht; - $line->total_ht=-$line->total_ht; - $line->total_tva=-$line->total_tva; - $line->total_ttc=-$line->total_ttc; - $line->total_localtax1=-$line->total_localtax1; - $line->total_localtax2=-$line->total_localtax2; - - $line->insert(); - - $object->lines[] = $line; // insert new line in current object - } - - $object->update_price(1); - } - - } - - if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) { - - $facture_source = new Facture($db); // fetch origin object if not previously defined - if($facture_source->fetch($object->fk_facture_source)>0) { - $totalpaye = $facture_source->getSommePaiement(); - $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); - $totaldeposits = $facture_source->getSumDepositsUsed(); - $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); - - $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); - } - } - - // Add predefined lines - /* - TODO delete - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { - $product = new Product($db); - $product->fetch($_POST['idprod' . $i]); - $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); - $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); - $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); - } - }*/ - } - } - - // Standard invoice or Deposit invoice created from a Predefined invoice - if (($_POST['type'] == 0 || $_POST['type'] == 3) && $_POST['fac_rec'] > 0) - { - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($dateinvoice)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); - } - - if (! $error) - { - $object->socid = GETPOST('socid','int'); - $object->type = $_POST['type']; - $object->number = $_POST['facnumber']; - $object->date = $dateinvoice; - $object->note_public = trim($_POST['note_public']); - $object->note_private = trim($_POST['note_private']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - - // Source facture - $object->fac_rec = $_POST['fac_rec']; - - $id = $object->create($user); - } - } - - // Standard or deposit or proforma invoice - if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0) - { - if (GETPOST('socid', 'int') < 1) - { - $error ++; - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); - } - - $dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($dateinvoice)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); - } - - if (! $error) - { - // Si facture standard - $object->socid = GETPOST('socid','int'); - $object->type = GETPOST('type'); - $object->number = $_POST['facnumber']; - $object->date = $dateinvoice; - $object->note_public = trim($_POST['note_public']); - $object->note_private = trim($_POST['note_private']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->amount = $_POST['amount']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - $object->fetch_thirdparty(); - - // If creation from another object of another module (Example: origin=propal, originid=1) - 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 == 'inter') { - $element = $subelement = 'ficheinter'; - } - if ($element == 'shipping') { - $element = $subelement = 'expedition'; - } - - $object->origin = $_POST['origin']; - $object->origin_id = $_POST['originid']; - - // Possibility to add external linked objects with hooks - $object->linked_objects [$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { - $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); - } - - $id = $object->create($user); - - if ($id > 0) - { - // If deposit invoice - if ($_POST['type'] == 3) - { - $typeamount = GETPOST('typedeposit', 'alpha'); - $valuedeposit = GETPOST('valuedeposit', 'int'); - - if ($typeamount == 'amount') - { - $amountdeposit = $valuedeposit; - } - else - { - $amountdeposit = 0; - - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - - $classname = ucfirst($subelement); - $srcobject = new $classname($db); - - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add deposit lines"); - $result = $srcobject->fetch($object->origin_id); - if ($result > 0) - { - $totalamount = 0; - $lines = $srcobject->lines; - $numlines=count($lines); - for ($i=0; $i<$numlines; $i++) - { - $qualified=1; - if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option - if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) - if ($qualified) $totalamount += $lines[$i]->total_ht; - } - - if ($totalamount != 0) { - $amountdeposit = ($totalamount * $valuedeposit) / 100; - } - } else { - $mesgs [] = $srcobject->error; - $error ++; - } - } - - $result = $object->addline( - $langs->trans('Deposit'), - $amountdeposit, // subprice - 1, // quantity - $lines [$i]->tva_tx, 0, // localtax1_tx - 0, // localtax2_tx - 0, // fk_product - 0, // remise_percent - 0, // date_start - 0, // date_end - 0, $lines [$i]->info_bits, // info_bits - 0, // info_bits - 'HT', - 0, - 0, // product_type - 1, - $lines [$i]->special_code, - $object->origin, - 0, - 0, - 0, - 0, - $langs->trans('Deposit') - ); - } - else - { - - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - - $classname = ucfirst($subelement); - $srcobject = new $classname($db); - - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); - if ($result > 0) - { - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { - $srcobject->fetch_lines(); - $lines = $srcobject->lines; - } - - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - - if ($lines [$i]->subprice < 0) - { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc = $object->socid; - $discount->amount_ht = abs($lines [$i]->total_ht); - $discount->amount_tva = abs($lines [$i]->total_tva); - $discount->amount_ttc = abs($lines [$i]->total_ttc); - $discount->tva_tx = $lines [$i]->tva_tx; - $discount->fk_user = $user->id; - $discount->description = $desc; - $discountid = $discount->create($user); - if ($discountid > 0) { - $result = $object->insert_discount($discountid); // This include link_to_invoice - } else { - $mesgs [] = $discount->error; - $error ++; - break; - } - } else { - // Positive line - $product_type = ($lines [$i]->product_type ? $lines [$i]->product_type : 0); - - // Date start - $date_start = false; - if ($lines [$i]->date_debut_prevue) - $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 - $date_end = false; - if ($lines [$i]->date_fin_prevue) - $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; - - // Reset fk_parent_line for no child products and special product - if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) { - $lines [$i]->fetch_optionals($lines [$i]->rowid); - $array_option = $lines [$i]->array_options; - } - - $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $date_start, $date_end, 0, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $object->origin, $lines [$i]->rowid, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); - - if ($result > 0) { - $lineid = $result; - } else { - $lineid = 0; - $error ++; - break; - } - - // Defined the new fk_parent_line - if ($result > 0 && $lines [$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - } - - // Hooks - $parameters = array('objFrom' => $srcobject); - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if ($reshook < 0) - $error ++; - } else { - $mesgs [] = $srcobject->error; - $error ++; - } - } - } else { - $mesgs [] = $object->error; - $error ++; - } - } // If some invoice's lines already known - else { - $id = $object->create($user); - - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { - $product = new Product($db); - $product->fetch($_POST['idprod' . $i]); - $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); - $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); - $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); - } - } - } - } - } - - // End of object creation, we show it - if ($id > 0 && ! $error) - { - $db->commit(); - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '#' . $_GET ['rowid']); exit(); } - else - { - $db->rollback(); - $action = 'create'; - $_GET ["origin"] = $_POST["origin"]; - $_GET ["originid"] = $_POST["originid"]; - $mesgs [] = '
' . $object->error . '
'; - } -} -// Add a new line -else if ($action == 'addline' && $user->rights->facture->creer) -{ - $langs->load('errors'); - $error = 0; - - // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - if (GETPOST('prod_entry_mode') == 'free') - { - $idprod=0; - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } - else - { - $idprod=GETPOST('idprod', 'int'); - $tva_tx = ''; + // Link invoice to order + if (GETPOST('linkedOrder')) { + $object->fetch($id); + $object->fetch_thirdparty(); + $result = $object->add_object_linked('commande', GETPOST('linkedOrder')); } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key . $predef]); - } - } - - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { - setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' - { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; - } - if ($qty == '') { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; - } - if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error ++; - } - - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { - $ret = $object->fetch($id); - if ($ret < 0) { - dol_print_error($db, $object->error); - exit(); - } - $ret = $object->fetch_thirdparty(); - - // Clean parameters - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); - - // Define special_code for special lines - $special_code = 0; - // if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - // Ecrase $base_price_type par celui du produit - if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - - // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); - - // We define price for product - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - { - $pu_ht = $prod->multiprices[$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; - $price_min = $prod->multiprices_min[$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result >= 0) { - if (count($prodcustprice->lines) > 0) { - $found = true; - $pu_ht = price($prodcustprice->lines[0]->price); - $pu_ttc = price($prodcustprice->lines[0]->price_ttc); - $price_base_type = $prodcustprice->lines[0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines[0]->tva_tx; - }else { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - } else { - setEventMessage($prodcustprice->error,'errors'); - } - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - - // if price ht is forced (ie: calculated by margin rate and cost price) - if (! empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $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). - elseif ($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'); - } - } - - $desc = ''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } - - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } - - $type = $prod->type; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); - } - - // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->client); - $localtax2_tx = get_localtax($tva_tx, 2, $object->client); - - $info_bits = 0; - if ($tva_npr) - $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); - } else { - // Insert line - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option); - - if ($result > 0) { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $ret = $object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST ['prod_entry_mode']); - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - unset($_POST['np_marginRate']); - unset($_POST['np_markRate']); - unset($_POST['dp_desc']); - unset($_POST['idprod']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); - } else { - setEventMessage($object->error, 'errors'); - } - - $action = ''; - } - } -} - -elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel')) { - if (! $object->fetch($id) > 0) - dol_print_error($db); - $object->fetch_thirdparty(); - - // Clean parameters - $date_start = ''; - $date_end = ''; - $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description = dol_htmlcleanlastbr(GETPOST('product_desc')); - $pu_ht = GETPOST('price_ht'); - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) - $info_bits |= 0x01; - - // Define vat_rate - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $object->client); - $localtax2_rate = get_localtax($vat_rate, 2, $object->client); - - // Add buying price - $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') ? GETPOST('buying_price') : ''); - - // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); - // Unset extrafield - if (is_array($extralabelsline)) { - // Get extra fields - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); - } - } - - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { - $product = new Product($db); - $product->fetch($productid); - - $type = $product->type; - - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - $price_min = $product->multiprices_min [$object->client->price_level]; - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - - // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; - } - } else { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - - // Check parameters - if (GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; - } - } - - // Update line - if (! $error) { - $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, 0, $array_option); - - if ($result >= 0) { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $ret = $object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['productid']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - } else { - setEventMessage($object->error, 'errors'); - } - } -} - -else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition - exit(); -} - -// Modify line position (up) -else if ($action == 'up' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); - $object->line_up($_GET ['rowid']); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '#' . $_GET ['rowid']); - exit(); -} // Modify line position (down) -else if ($action == 'down' && $user->rights->facture->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); - $object->line_down($_GET ['rowid']); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '#' . $_GET ['rowid']); - exit(); -} - -// Link invoice to order -if (GETPOST('linkedOrder')) { - $object->fetch($id); - $object->fetch_thirdparty(); - $result = $object->add_object_linked('commande', GETPOST('linkedOrder')); -} - -/* - * Add file in email form - */ -if (GETPOST('addfile')) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; - - dol_add_file_process($upload_dir_tmp, 0, 0); - $action = 'presend'; -} - -/* - * Remove file in email form - */ -if (! empty($_POST['removedfile'])) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir = $conf->user->dir_output . "/" . $user->id; - $upload_dir_tmp = $vardir . '/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST['removedfile'], 0); - $action = 'presend'; -} - -/* - * Send mail - */ -if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { - $langs->load('mails'); - - $actiontypecode = ''; - $subject = ''; - $actionmsg = ''; - $actionmsg2 = ''; - - $result = $object->fetch($id); - $result = $object->fetch_thirdparty(); - - if ($result > 0) { - // $ref = dol_sanitizeFileName($object->ref); - // $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; - - // if (is_readable($file)) - // { - if ($_POST['sendto']) { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST['sendto']; - $sendtoid = 0; - } elseif ($_POST['receiver'] != '-1') { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST['receiver'], 'email'); - $sendtoid = $_POST['receiver']; - } - } - - if (dol_strlen($sendto)) { - $langs->load("commercial"); - - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>'; - $replyto = $_POST['replytoname'] . ' <' . $_POST['replytomail'] . '>'; - $message = $_POST['message']; - $sendtocc = $_POST['sendtocc']; - $deliveryreceipt = $_POST['deliveryreceipt']; - - if ($action == 'send') { - if (dol_strlen($_POST['subject'])) - $subject = $_POST['subject']; - else - $subject = $langs->transnoentities('Bill') . ' ' . $object->ref; - $actiontypecode = 'AC_FAC'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; - } - // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - if ($action == 'relance') { - if (dol_strlen($_POST['subject'])) - $subject = $_POST['subject']; - else - $subject = $langs->transnoentities('Relance facture ' . $object->ref); - $actiontypecode = 'AC_FAC'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; - if ($message) { - $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; - $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; - $actionmsg .= $message; - } - // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - - // Create form object - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles ['paths']; - $filename = $attachedfiles ['names']; - $mimetype = $attachedfiles ['mimes']; - - // Send mail - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); - if ($mailfile->error) { - $mesgs [] = '
' . $mailfile->error . '
'; - } else { - $result = $mailfile->sendfile(); - if ($result) { - $error = 0; - - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; // Long text - $object->actionmsg2 = $actionmsg2; // Short text - $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_SENTBYMAIL', $object, $user, $langs, $conf); - if ($result < 0) { - $error++; - $object->errors = $interface->errors; - } - // Fin appel triggers - - if ($error) { - dol_print_error($db); - } else { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); - setEventMessage($mesg); - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id); - exit(); - } - } else { - $langs->load("other"); - $mesg = '
'; - if ($mailfile->error) { - $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); - $mesg .= '
' . $mailfile->error; - } else { - $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - $mesg .= '
'; - $mesgs [] = $mesg; - } - } - /* } - else - { - $langs->load("other"); - $mesgs[]='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; - dol_syslog('Recipient email is empty'); - }*/ - } else { - $langs->load("errors"); - $mesgs [] = '
' . $langs->trans('ErrorCantReadFile', $file) . '
'; - dol_syslog('Failed to read file: ' . $file); - } - } else { - $langs->load("other"); - $mesgs [] = '
' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Invoice")) . '
'; - dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.'); - } - - $action = 'presend'; -} - -/* - * Generate document - */ -else if ($action == 'builddoc') // En get ou en post -{ - $object->fetch($id); - $object->fetch_thirdparty(); - - // Save last template used to generate document - if (GETPOST('model')) - $object->setDocModel($user, GETPOST('model', 'alpha')); - if (GETPOST('fk_bank')) // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank'); - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - dol_print_error($db, $result); - exit(); - } -} - -// Remove file in doc form -else if ($action == 'remove_file') { - if ($object->fetch($id)) { + /* + * Add file in email form + */ + if (GETPOST('addfile')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + // Set tmp user directory + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; + + dol_add_file_process($upload_dir_tmp, 0, 0); + $action = 'presend'; + } + + /* + * Remove file in email form + */ + if (! empty($_POST['removedfile'])) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir = $conf->user->dir_output . "/" . $user->id; + $upload_dir_tmp = $vardir . '/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process($_POST['removedfile'], 0); + $action = 'presend'; + } + + /* + * Send mail + */ + if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { + $langs->load('mails'); + + $actiontypecode = ''; + $subject = ''; + $actionmsg = ''; + $actionmsg2 = ''; + + $result = $object->fetch($id); + $result = $object->fetch_thirdparty(); + + if ($result > 0) { + // $ref = dol_sanitizeFileName($object->ref); + // $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; + + // if (is_readable($file)) + // { + if ($_POST['sendto']) { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST['sendto']; + $sendtoid = 0; + } elseif ($_POST['receiver'] != '-1') { + // Recipient was provided from combo list + if ($_POST['receiver'] == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST['receiver'], 'email'); + $sendtoid = $_POST['receiver']; + } + } + + if (dol_strlen($sendto)) { + $langs->load("commercial"); + + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>'; + $replyto = $_POST['replytoname'] . ' <' . $_POST['replytomail'] . '>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; + $deliveryreceipt = $_POST['deliveryreceipt']; + + if ($action == 'send') { + if (dol_strlen($_POST['subject'])) + $subject = $_POST['subject']; + else + $subject = $langs->transnoentities('Bill') . ' ' . $object->ref; + $actiontypecode = 'AC_FAC'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + if ($message) { + $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; + $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; + $actionmsg .= $message; + } + // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + if ($action == 'relance') { + if (dol_strlen($_POST['subject'])) + $subject = $_POST['subject']; + else + $subject = $langs->transnoentities('Relance facture ' . $object->ref); + $actiontypecode = 'AC_FAC'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n"; + if ($message) { + $actionmsg .= $langs->transnoentities('MailTopic') . ": " . $subject . "\n"; + $actionmsg .= $langs->transnoentities('TextUsedInTheMessageBody') . ":\n"; + $actionmsg .= $message; + } + // $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + + // Create form object + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles = $formmail->get_attached_files(); + $filepath = $attachedfiles ['paths']; + $filename = $attachedfiles ['names']; + $mimetype = $attachedfiles ['mimes']; + + // Send mail + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, - 1); + if ($mailfile->error) { + $mesgs [] = '
' . $mailfile->error . '
'; + } else { + $result = $mailfile->sendfile(); + if ($result) { + $error = 0; + + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; // Long text + $object->actionmsg2 = $actionmsg2; // Short text + $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_SENTBYMAIL', $object, $user, $langs, $conf); + if ($result < 0) { + $error++; + $object->errors = $interface->errors; + } + // Fin appel triggers + + if ($error) { + dol_print_error($db); + } else { + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); + setEventMessage($mesg); + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id); + exit(); + } + } else { + $langs->load("other"); + $mesg = '
'; + if ($mailfile->error) { + $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); + $mesg .= '
' . $mailfile->error; + } else { + $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg .= '
'; + $mesgs [] = $mesg; + } + } + /* } + else + { + $langs->load("other"); + $mesgs[]='
'.$langs->trans('ErrorMailRecipientIsEmpty').'
'; + dol_syslog('Recipient email is empty'); + }*/ + } else { + $langs->load("errors"); + $mesgs [] = '
' . $langs->trans('ErrorCantReadFile', $file) . '
'; + dol_syslog('Failed to read file: ' . $file); + } + } else { + $langs->load("other"); + $mesgs [] = '
' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Invoice")) . '
'; + dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.'); + } + + $action = 'presend'; + } + + /* + * Generate document + */ + else if ($action == 'builddoc') // En get ou en post + { + $object->fetch($id); $object->fetch_thirdparty(); - $langs->load("other"); - $upload_dir = $conf->facture->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + // Save last template used to generate document + if (GETPOST('model')) + $object->setDocModel($user, GETPOST('model', 'alpha')); + if (GETPOST('fk_bank')) // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank'); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db, $result); + exit(); + } + } + + // Remove file in doc form + else if ($action == 'remove_file') { + if ($object->fetch($id)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + + $object->fetch_thirdparty(); + + $langs->load("other"); + $upload_dir = $conf->facture->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); + if ($ret) + setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else + setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + $action = ''; + } + } + + // Print file + else if ($action == 'print_file' and $user->rights->printipp->read) { + require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; + $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); + $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); + setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); $action = ''; } -} -// Print file -else if ($action == 'print_file' and $user->rights->printipp->read) { - require_once DOL_DOCUMENT_ROOT . '/core/class/dolprintipp.class.php'; - $printer = new dolPrintIPP($db, $conf->global->PRINTIPP_HOST, $conf->global->PRINTIPP_PORT, $user->login, $conf->global->PRINTIPP_USER, $conf->global->PRINTIPP_PASSWORD); - $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha')); - setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file'))); - $action = ''; -} + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { + if ($action == 'addcontact') { + $result = $object->fetch($id); -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { - if ($action == 'addcontact') { - $result = $object->fetch($id); + if ($result > 0 && $id > 0) { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } - if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - $mesgs [] = '
' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '
'; + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); } else { - $mesgs [] = '
' . $object->error . '
'; + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + $mesgs [] = '
' . $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType") . '
'; + } else { + $mesgs [] = '
' . $object->error . '
'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut') { + if ($object->fetch($id)) { + $result = $object->swapContactStatus(GETPOST('ligne')); + } else { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact') { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + exit(); + } else { + dol_print_error($db); } } } - // bascule du statut d'un contact - else if ($action == 'swapstatut') { - if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); - } else { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact') { - $object->fetch($id); - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); - exit(); - } else { - dol_print_error($db); - } - } -} - -if ($action == 'update_extras') { - // Fill array 'array_options' with data from add form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; - - if (! $error) { - // Actions on extra fields (by external module or standard code) - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('invoicedao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) + if ($action == 'update_extras') { + // Fill array 'array_options' with data from add form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) $error ++; - } - if ($error) - $action = 'edit_extras'; + if (! $error) { + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('invoicedao')); + $parameters = array('id' => $object->id); + $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by + // some hooks + if (empty($reshook)) { + $result = $object->insertExtraFields(); + if ($result < 0) { + $error ++; + } + } else if ($reshook < 0) + $error ++; + } + + if ($error) + $action = 'edit_extras'; + } } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 3aafa1c165b..c96ddaa4b9f 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -71,182 +71,184 @@ $hookmanager->initHooks(array('paiementcard')); $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -/* - * Actions - */ -if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) -{ - $error = 0; +if (empty($reshook)) { - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $paiement_id = 0; - $totalpayment = 0; - $atleastonepaymentnotnull = 0; - - // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); - foreach ($_POST as $key => $value) + /* + * Actions + */ + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) { - if (substr($key,0,7) == 'amount_') + $error = 0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $paiement_id = 0; + $totalpayment = 0; + $atleastonepaymentnotnull = 0; + + // Generate payment array and check if there is payment higher than invoice and payment date before invoice date + $tmpinvoice=new Facture($db); + foreach ($_POST as $key => $value) { - $cursorfacid = substr($key,7); - $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) + if (substr($key,0,7) == 'amount_') { - // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) - { - $addwarning=1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { - $langs->load("errors"); - //$error++; - setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings'); - } - } + $cursorfacid = substr($key,7); + $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $totalpayment = $totalpayment + $amounts[$cursorfacid]; + if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result=$tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + if ($amounts[$cursorfacid]) + { + // Check amount + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) + { + $addwarning=1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings'); + } + } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); - } - } - - // Check parameters - if (! GETPOST('paiementcode')) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors'); - $error++; - } - - if (! empty($conf->banque->enabled)) - { - // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); - $error++; - } - } - - if (empty($totalpayment) && empty($atleastonepaymentnotnull)) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors'); - $error++; - } - - if (empty($datepaye)) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors'); - $error++; - } -} - -/* - * Action add_paiement - */ -if ($action == 'add_paiement') -{ - if ($error) - { - $action = 'create'; - } - // Le reste propre a cette action s'affiche en bas de page. -} - -/* - * Action confirm_paiement - */ -if ($action == 'confirm_paiement' && $confirm == 'yes') -{ - $error=0; - - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - - $db->begin(); - - // Clean parameters amount if payment is for a credit note - if (GETPOST('type') == 2) - { - foreach ($amounts as $key => $value) // How payment is dispatch - { - $newvalue = price2num($value,'MT'); - $amounts[$key] = -$newvalue; - } - } - - if (! empty($conf->banque->enabled)) - { - // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement - if (GETPOST('accountid') <= 0) - { - setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); - $error++; - } - } - - // Creation of payment line - $paiement = new Paiement($db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db,$_POST['paiementcode'],'c_paiement'); - $paiement->num_paiement = $_POST['num_paiement']; - $paiement->note = $_POST['comment']; - - if (! $error) - { - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); - if ($paiement_id < 0) - { - setEventMessage($paiement->error, 'errors'); - $error++; - } - } - - if (! $error) - { - $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; - $result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),GETPOST('chqemetteur'),GETPOST('chqbank')); - if ($result < 0) - { - setEventMessage($paiement->error, 'errors'); - $error++; - } - } - - if (! $error) - { - $db->commit(); - - // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid=0; - foreach ($paiement->amounts as $key => $amount) - { - $facid = $key; - if (is_numeric($amount) && $amount <> 0) - { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); } } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id; - header('Location: '.$loc); - exit; + + // Check parameters + if (! GETPOST('paiementcode')) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors'); + $error++; + } + + if (! empty($conf->banque->enabled)) + { + // If bank module is on, account is required to enter a payment + if (GETPOST('accountid') <= 0) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); + $error++; + } + } + + if (empty($totalpayment) && empty($atleastonepaymentnotnull)) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors'); + $error++; + } + + if (empty($datepaye)) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors'); + $error++; + } } - else + + /* + * Action add_paiement + */ + if ($action == 'add_paiement') { - $db->rollback(); + if ($error) + { + $action = 'create'; + } + // Le reste propre a cette action s'affiche en bas de page. + } + + /* + * Action confirm_paiement + */ + if ($action == 'confirm_paiement' && $confirm == 'yes') + { + $error=0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + + $db->begin(); + + // Clean parameters amount if payment is for a credit note + if (GETPOST('type') == 2) + { + foreach ($amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $amounts[$key] = -$newvalue; + } + } + + if (! empty($conf->banque->enabled)) + { + // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement + if (GETPOST('accountid') <= 0) + { + setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); + $error++; + } + } + + // Creation of payment line + $paiement = new Paiement($db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array with all payments dispatching + $paiement->paiementid = dol_getIdFromCode($db,$_POST['paiementcode'],'c_paiement'); + $paiement->num_paiement = $_POST['num_paiement']; + $paiement->note = $_POST['comment']; + + if (! $error) + { + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); + if ($paiement_id < 0) + { + setEventMessage($paiement->error, 'errors'); + $error++; + } + } + + if (! $error) + { + $label='(CustomerInvoicePayment)'; + if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; + $result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),GETPOST('chqemetteur'),GETPOST('chqbank')); + if ($result < 0) + { + setEventMessage($paiement->error, 'errors'); + $error++; + } + } + + if (! $error) + { + $db->commit(); + + // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card + $invoiceid=0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment + else $invoiceid=$facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } } } - /* * View */ diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index c11c1d549a9..7dd671d109f 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -89,473 +89,475 @@ $hookmanager->initHooks(array('expeditioncard')); $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($action == 'add') -{ - $error=0; +if (empty($reshook)) { - $db->begin(); - - $object->note = GETPOST('note','alpha'); - $object->origin = $origin; - $object->origin_id = $origin_id; - $object->weight = GETPOST('weight','int')==''?"NULL":GETPOST('weight','int'); - $object->sizeH = GETPOST('sizeH','int')==''?"NULL":GETPOST('sizeH','int'); - $object->sizeW = GETPOST('sizeW','int')==''?"NULL":GETPOST('sizeW','int'); - $object->sizeS = GETPOST('sizeS','int')==''?"NULL":GETPOST('sizeS','int'); - $object->size_units = GETPOST('size_units','int'); - $object->weight_units = GETPOST('weight_units','int'); - - $date_delivery = dol_mktime(GETPOST('date_deliveryhour','int'), GETPOST('date_deliverymin','int'), 0, GETPOST('date_deliverymonth','int'), GETPOST('date_deliveryday','int'), GETPOST('date_deliveryyear','int')); - - // On va boucler sur chaque ligne du document d'origine pour completer objet expedition - // avec info diverses + qte a livrer - $classname = ucfirst($object->origin); - $objectsrc = new $classname($db); - $objectsrc->fetch($object->origin_id); - - $object->socid = $objectsrc->socid; - $object->ref_customer = $objectsrc->ref_client; - $object->date_delivery = $date_delivery; // Date delivery planed - $object->fk_delivery_address = $objectsrc->fk_delivery_address; - $object->shipping_method_id = GETPOST('shipping_method_id','int'); - $object->tracking_number = GETPOST('tracking_number','alpha'); - $object->ref_int = GETPOST('ref_int','alpha'); - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); - - $num=count($objectsrc->lines); - $totalqty=0; - for ($i = 0; $i < $num; $i++) + if ($action == 'add') { - $qty = "qtyl".$i; - $j=0; - $sub_qty=array(); - $subtotalqty=0; - $idl="idl".$i; - $batch="batchl".$i."_0"; - if (isset($_POST[$batch])) { - //shipment line with batch-enable product - $qty .= '_'.$j; - while (isset($_POST[$batch])) { - $sub_qty[$j]['q']=GETPOST($qty,'int'); - $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); - $subtotalqty+=$sub_qty[$j]['q']; - $j++; - $batch="batchl".$i."_".$j; - $qty = "qtyl".$i.'_'.$j; + $error=0; - } - $batch_line[$i]['detail']=$sub_qty; - $batch_line[$i]['qty']=$subtotalqty; - $batch_line[$i]['ix_l']=GETPOST($idl,'int'); - $totalqty+=$subtotalqty; - } else { - //Standard product - if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); - } - } + $db->begin(); - if ($totalqty > 0) - { - //var_dump($_POST);exit; + $object->note = GETPOST('note','alpha'); + $object->origin = $origin; + $object->origin_id = $origin_id; + $object->weight = GETPOST('weight','int')==''?"NULL":GETPOST('weight','int'); + $object->sizeH = GETPOST('sizeH','int')==''?"NULL":GETPOST('sizeH','int'); + $object->sizeW = GETPOST('sizeW','int')==''?"NULL":GETPOST('sizeW','int'); + $object->sizeS = GETPOST('sizeS','int')==''?"NULL":GETPOST('sizeS','int'); + $object->size_units = GETPOST('size_units','int'); + $object->weight_units = GETPOST('weight_units','int'); + + $date_delivery = dol_mktime(GETPOST('date_deliveryhour','int'), GETPOST('date_deliverymin','int'), 0, GETPOST('date_deliverymonth','int'), GETPOST('date_deliveryday','int'), GETPOST('date_deliveryyear','int')); + + // On va boucler sur chaque ligne du document d'origine pour completer objet expedition + // avec info diverses + qte a livrer + $classname = ucfirst($object->origin); + $objectsrc = new $classname($db); + $objectsrc->fetch($object->origin_id); + + $object->socid = $objectsrc->socid; + $object->ref_customer = $objectsrc->ref_client; + $object->date_delivery = $date_delivery; // Date delivery planed + $object->fk_delivery_address = $objectsrc->fk_delivery_address; + $object->shipping_method_id = GETPOST('shipping_method_id','int'); + $object->tracking_number = GETPOST('tracking_number','alpha'); + $object->ref_int = GETPOST('ref_int','alpha'); + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); + + $num=count($objectsrc->lines); + $totalqty=0; for ($i = 0; $i < $num; $i++) { $qty = "qtyl".$i; - if (! isset($batch_line[$i])) { - if (GETPOST($qty,'int') > 0) - { - $ent = "entl".$i; - $idl = "idl".$i; - $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); - if ($entrepot_id < 0) $entrepot_id=''; + $j=0; + $sub_qty=array(); + $subtotalqty=0; + $idl="idl".$i; + $batch="batchl".$i."_0"; + if (isset($_POST[$batch])) { + //shipment line with batch-enable product + $qty .= '_'.$j; + while (isset($_POST[$batch])) { + $sub_qty[$j]['q']=GETPOST($qty,'int'); + $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); + $subtotalqty+=$sub_qty[$j]['q']; + $j++; + $batch="batchl".$i."_".$j; + $qty = "qtyl".$i.'_'.$j; - $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); - if ($ret < 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } - } else { - if ($batch_line[$i]['qty']>0) { - $ret=$object->addline_batch($batch_line[$i]); - if ($ret < 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } - } + } + $batch_line[$i]['detail']=$sub_qty; + $batch_line[$i]['qty']=$subtotalqty; + $batch_line[$i]['ix_l']=GETPOST($idl,'int'); + $totalqty+=$subtotalqty; + } else { + //Standard product + if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); + } + } + + if ($totalqty > 0) + { + //var_dump($_POST);exit; + for ($i = 0; $i < $num; $i++) + { + $qty = "qtyl".$i; + if (! isset($batch_line[$i])) { + if (GETPOST($qty,'int') > 0) + { + $ent = "entl".$i; + $idl = "idl".$i; + $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); + if ($entrepot_id < 0) $entrepot_id=''; + + $ret=$object->addline($entrepot_id,GETPOST($idl,'int'),GETPOST($qty,'int')); + if ($ret < 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } else { + if ($batch_line[$i]['qty']>0) { + $ret=$object->addline_batch($batch_line[$i]); + if ($ret < 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } + } + + if (! $error) + { + $ret=$object->create($user); + if ($ret <= 0) + { + $mesg='
'.$object->error.'
'; + $error++; + } + } + } + else + { + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")).'
'; + $error++; } if (! $error) { - $ret=$object->create($user); - if ($ret <= 0) - { - $mesg='
'.$object->error.'
'; - $error++; - } - } - } - else - { - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Qty")).'
'; - $error++; - } - - if (! $error) - { - $db->commit(); - header("Location: fiche.php?id=".$object->id); - exit; - } - else - { - $db->rollback(); - $_GET["commande_id"]=GETPOST('commande_id','int'); - $action='create'; - } -} - -/* - * Build a receiving receipt - */ -else if ($action == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) -{ - $result = $object->create_delivery($user); - if ($result > 0) - { - header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); - exit; - } - else - { - $mesg=$object->error; - } -} - -else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->valider) -{ - $object->fetch_thirdparty(); - - $result = $object->valid($user); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($id); // Reload to get new records - $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); - } - if ($result < 0) - { - dol_print_error($db,$result); - exit; - } -} - -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) -{ - $result = $object->delete(); - if ($result > 0) - { - header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); - exit; - } - else - { - $langs->load("errors"); - setEventMessage($langs->trans($object->error),'errors'); - } -} - -else if ($action == 'reopen' && $user->rights->expedition->valider) -{ - $result = $object->setStatut(0); - if ($result < 0) - { - $mesg = $object->error; - } -} - -else if ($action == 'setdate_livraison' && $user->rights->expedition->creer) -{ - //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datedelivery=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'), GETPOST('liv_year','int')); - - $object->fetch($id); - $result=$object->set_date_livraison($user,$datedelivery); - if ($result < 0) - { - $mesg='
'.$object->error.'
'; - } -} - -// Action update description of emailing -else if ($action == 'settrackingnumber' || $action == 'settrackingurl' -|| $action == 'settrueWeight' -|| $action == 'settrueWidth' -|| $action == 'settrueHeight' -|| $action == 'settrueDepth' -|| $action == 'setshipping_method_id') -{ - $error=0; - - if ($action == 'settrackingnumber') $object->tracking_number = trim(GETPOST('trackingnumber','alpha')); - if ($action == 'settrackingurl') $object->tracking_url = trim(GETPOST('trackingurl','int')); - if ($action == 'settrueWeight') { - $object->trueWeight = trim(GETPOST('trueWeight','int')); - $object->weight_units = GETPOST('weight_units','int'); - } - if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth','int')); - if ($action == 'settrueHeight'){ - $object->trueHeight = trim(GETPOST('trueHeight','int')); - $object->size_units = GETPOST('size_units','int'); - } - if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth','int')); - if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id','int')); - - if (! $error) - { - if ($object->update($user) >= 0) - { + $db->commit(); header("Location: fiche.php?id=".$object->id); exit; } - setEventMessage($object->error,'errors'); + else + { + $db->rollback(); + $_GET["commande_id"]=GETPOST('commande_id','int'); + $action='create'; + } } - $action=""; -} - -// Build document -else if ($action == 'builddoc') // En get ou en post -{ - - // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->client->default_lang; - if (! empty($newlang)) + /* + * Build a receiving receipt + */ + else if ($action == 'create_delivery' && $conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + $result = $object->create_delivery($user); + if ($result > 0) + { + header("Location: ".DOL_URL_ROOT.'/livraison/fiche.php?id='.$result); + exit; + } + else + { + $mesg=$object->error; + } } - $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); - if ($result <= 0) + + else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->valider) { - dol_print_error($db,$result); - exit; + $object->fetch_thirdparty(); + + $result = $object->valid($user); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($id); // Reload to get new records + $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); + } + if ($result < 0) + { + dol_print_error($db,$result); + exit; + } } -} -// Delete file in doc form -elseif ($action == 'remove_file') -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $upload_dir = $conf->expedition->dir_output . "/sending"; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); -} - -/* - * Add file in email form -*/ -if (GETPOST('addfile','alpha')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - dol_add_file_process($upload_dir_tmp,0,0); - $action ='presend'; -} - -/* - * Remove file in email form -*/ -if (GETPOST('removedfile','alpha')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process(GETPOST('removedfile','int'),0); - $action ='presend'; -} - -/* - * Send mail -*/ -if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile','alpha') && ! GETPOST('cancel','alpha')) -{ - $langs->load('mails'); - -// $ref = dol_sanitizeFileName($object->ref); -// $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; - -// if (is_readable($file)) -// { - if (GETPOST('sendto','alpha')) - { - // Le destinataire a ete fourni via le champ libre - $sendto = GETPOST('sendto','alpha'); - $sendtoid = 0; - } - elseif (GETPOST('receiver','alpha') != '-1') - { - // Recipient was provided from combo list - if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email'); - $sendtoid = GETPOST('receiver','alpha'); - } - } - - if (dol_strlen($sendto)) - { - $langs->load("commercial"); - - $from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>'; - $replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>'; - $message = GETPOST('message'); - $sendtocc = GETPOST('sendtocc','alpha'); - $deliveryreceipt = GETPOST('deliveryreceipt','alpha'); - - if ($action == 'send') - { - if (dol_strlen(GETPOST('subject','alpha'))) $subject=GETPOST('subject','alpha'); - else $subject = $langs->transnoentities('Shipping').' '.$object->ref; - $actiontypecode='AC_SHIP'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - if ($message) - { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; - } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } - - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - // Send mail - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); - if ($mailfile->error) - { - $mesg='
'.$mailfile->error.'
'; - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - $error=0; - - // Initialisation donnees - $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('SHIPPING_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $object->errors=$interface->errors; - } - // Fin appel triggers - - if ($error) - { - dol_print_error($db); - } - else - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessage($mesg); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } - else - { - $langs->load("other"); - $mesg='
'; - if ($mailfile->error) - { - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $mesg.='
'.$mailfile->error; - } - else - { - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - $mesg.='
'; - } - } - } - else - { - $langs->load("other"); - $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; - $action='presend'; - dol_syslog('Recipient email is empty'); - } -/* } + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) + { + $result = $object->delete(); + if ($result > 0) + { + header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); + exit; + } else { $langs->load("errors"); - $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; - dol_syslog('Failed to read file: '.$file); - }*/ -} + setEventMessage($langs->trans($object->error),'errors'); + } + } -else if ($action == 'classifybilled') -{ - $object->fetch($id); - $object->set_billed(); -} + else if ($action == 'reopen' && $user->rights->expedition->valider) + { + $result = $object->setStatut(0); + if ($result < 0) + { + $mesg = $object->error; + } + } + else if ($action == 'setdate_livraison' && $user->rights->expedition->creer) + { + //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; + $datedelivery=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'), GETPOST('liv_year','int')); + + $object->fetch($id); + $result=$object->set_date_livraison($user,$datedelivery); + if ($result < 0) + { + $mesg='
'.$object->error.'
'; + } + } + + // Action update description of emailing + else if ($action == 'settrackingnumber' || $action == 'settrackingurl' + || $action == 'settrueWeight' + || $action == 'settrueWidth' + || $action == 'settrueHeight' + || $action == 'settrueDepth' + || $action == 'setshipping_method_id') + { + $error=0; + + if ($action == 'settrackingnumber') $object->tracking_number = trim(GETPOST('trackingnumber','alpha')); + if ($action == 'settrackingurl') $object->tracking_url = trim(GETPOST('trackingurl','int')); + if ($action == 'settrueWeight') { + $object->trueWeight = trim(GETPOST('trueWeight','int')); + $object->weight_units = GETPOST('weight_units','int'); + } + if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth','int')); + if ($action == 'settrueHeight'){ + $object->trueHeight = trim(GETPOST('trueHeight','int')); + $object->size_units = GETPOST('size_units','int'); + } + if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth','int')); + if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id','int')); + + if (! $error) + { + if ($object->update($user) >= 0) + { + header("Location: fiche.php?id=".$object->id); + exit; + } + setEventMessage($object->error,'errors'); + } + + $action=""; + } + + // Build document + else if ($action == 'builddoc') // En get ou en post + { + + // Save last template used to generate document + if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + } + + // Delete file in doc form + elseif ($action == 'remove_file') + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $upload_dir = $conf->expedition->dir_output . "/sending"; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + } + + /* + * Add file in email form + */ + if (GETPOST('addfile','alpha')) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + dol_add_file_process($upload_dir_tmp,0,0); + $action ='presend'; + } + + /* + * Remove file in email form + */ + if (GETPOST('removedfile','alpha')) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process(GETPOST('removedfile','int'),0); + $action ='presend'; + } + + /* + * Send mail + */ + if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile','alpha') && ! GETPOST('cancel','alpha')) + { + $langs->load('mails'); + + // $ref = dol_sanitizeFileName($object->ref); + // $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; + + // if (is_readable($file)) + // { + if (GETPOST('sendto','alpha')) + { + // Le destinataire a ete fourni via le champ libre + $sendto = GETPOST('sendto','alpha'); + $sendtoid = 0; + } + elseif (GETPOST('receiver','alpha') != '-1') + { + // Recipient was provided from combo list + if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email'); + $sendtoid = GETPOST('receiver','alpha'); + } + } + + if (dol_strlen($sendto)) + { + $langs->load("commercial"); + + $from = GETPOST('fromname','alpha') . ' <' . GETPOST('frommail','alpha') .'>'; + $replyto = GETPOST('replytoname','alpha'). ' <' . GETPOST('replytomail','alpha').'>'; + $message = GETPOST('message'); + $sendtocc = GETPOST('sendtocc','alpha'); + $deliveryreceipt = GETPOST('deliveryreceipt','alpha'); + + if ($action == 'send') + { + if (dol_strlen(GETPOST('subject','alpha'))) $subject=GETPOST('subject','alpha'); + else $subject = $langs->transnoentities('Shipping').' '.$object->ref; + $actiontypecode='AC_SHIP'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + if ($message) + { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; + $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; + $actionmsg.=$message; + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } + + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Send mail + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); + if ($mailfile->error) + { + $mesg='
'.$mailfile->error.'
'; + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + $error=0; + + // Initialisation donnees + $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('SHIPPING_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $object->errors=$interface->errors; + } + // Fin appel triggers + + if ($error) + { + dol_print_error($db); + } + else + { + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + setEventMessage($mesg); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + else + { + $langs->load("other"); + $mesg='
'; + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + $mesg.='
'; + } + } + } + else + { + $langs->load("other"); + $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + $action='presend'; + dol_syslog('Recipient email is empty'); + } + /* } + else + { + $langs->load("errors"); + $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; + dol_syslog('Failed to read file: '.$file); + }*/ + } + + else if ($action == 'classifybilled') + { + $object->fetch($id); + $object->set_billed(); + } +} /* * View diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index bb84e279ba9..b6a4c5a7925 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -68,164 +68,166 @@ $hookmanager->initHooks(array('paymentsupplier')); $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -/* - * Actions - */ -if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) -{ - $error = 0; +if (empty($reshook)) { - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $paiement_id = 0; - $totalpayment = 0; - $atleastonepaymentnotnull = 0; - - // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new FactureFournisseur($db); - foreach ($_POST as $key => $value) + /* + * Actions + */ + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) { - if (substr($key,0,7) == 'amount_') + $error = 0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $paiement_id = 0; + $totalpayment = 0; + $atleastonepaymentnotnull = 0; + + // Generate payment array and check if there is payment higher than invoice and payment date before invoice date + $tmpinvoice=new FactureFournisseur($db); + foreach ($_POST as $key => $value) { - $cursorfacid = substr($key,7); - $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); - $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); - if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); - if ($amounts[$cursorfacid]) + if (substr($key,0,7) == 'amount_') { - // Check amount - if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) - { - $addwarning=1; - $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier"); - } - // Check date - if ($datepaye && ($datepaye < $tmpinvoice->date)) - { - $langs->load("errors"); - //$error++; - setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings'); - } + $cursorfacid = substr($key,7); + $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); + $totalpayment = $totalpayment + $amounts[$cursorfacid]; + if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result=$tmpinvoice->fetch($cursorfacid); + if ($result <= 0) dol_print_error($db); + $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + if ($amounts[$cursorfacid]) + { + // Check amount + if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) + { + $addwarning=1; + $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier"); + } + // Check date + if ($datepaye && ($datepaye < $tmpinvoice->date)) + { + $langs->load("errors"); + //$error++; + setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings'); + } + } + + $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); } - - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); } - } - // Check parameters - if ($_POST['paiementid'] <= 0) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors'); - $error++; - } - - if (! empty($conf->banque->enabled)) - { - // If bank module is on, account is required to enter a payment - if (GETPOST('accountid') <= 0) + // Check parameters + if ($_POST['paiementid'] <= 0) { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), 'errors'); + $error++; + } + + if (! empty($conf->banque->enabled)) + { + // If bank module is on, account is required to enter a payment + if (GETPOST('accountid') <= 0) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), 'errors'); + $error++; + } + } + + if (empty($totalpayment) && empty($atleastonepaymentnotnull)) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors'); + $error++; + } + + if (empty($datepaye)) + { + setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors'); $error++; } } - if (empty($totalpayment) && empty($atleastonepaymentnotnull)) + /* + * Action add_paiement + */ + if ($action == 'add_paiement') { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->trans('PaymentAmount')), 'errors'); - $error++; - } - - if (empty($datepaye)) - { - setEventMessage($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), 'errors'); - $error++; - } -} - -/* - * Action add_paiement - */ -if ($action == 'add_paiement') -{ - if ($error) - { - $action = 'create'; - } - // Le reste propre a cette action s'affiche en bas de page. -} - - -/* - * Action confirm_paiement - */ -if ($action == 'confirm_paiement' && $confirm == 'yes') -{ - $error=0; - - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - - if (! $error) - { - $db->begin(); - - // Creation de la ligne paiement - $paiement = new PaiementFourn($db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array of amounts - $paiement->paiementid = $_POST['paiementid']; - $paiement->num_paiement = $_POST['num_paiement']; - $paiement->note = $_POST['comment']; - if (! $error) + if ($error) { - $paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0)); - if ($paiement_id < 0) - { - setEventMessage($paiement->error, 'errors'); - $error++; - } + $action = 'create'; } + // Le reste propre a cette action s'affiche en bas de page. + } + + + /* + * Action confirm_paiement + */ + if ($action == 'confirm_paiement' && $confirm == 'yes') + { + $error=0; + + $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); if (! $error) { - $result=$paiement->addPaymentToBank($user,'payment_supplier','(SupplierInvoicePayment)',$_POST['accountid'],'',''); - if ($result < 0) - { - setEventMessage($paiement->error, 'errors'); - $error++; - } - } + $db->begin(); - if (! $error) - { - $db->commit(); - - // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid=0; - foreach ($paiement->amounts as $key => $amount) + // Creation de la ligne paiement + $paiement = new PaiementFourn($db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array of amounts + $paiement->paiementid = $_POST['paiementid']; + $paiement->num_paiement = $_POST['num_paiement']; + $paiement->note = $_POST['comment']; + if (! $error) { - $facid = $key; - if (is_numeric($amount) && $amount <> 0) + $paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0)); + if ($paiement_id < 0) { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + setEventMessage($paiement->error, 'errors'); + $error++; } } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id; - header('Location: '.$loc); - exit; - } - else - { - $db->rollback(); + + if (! $error) + { + $result=$paiement->addPaymentToBank($user,'payment_supplier','(SupplierInvoicePayment)',$_POST['accountid'],'',''); + if ($result < 0) + { + setEventMessage($paiement->error, 'errors'); + $error++; + } + } + + if (! $error) + { + $db->commit(); + + // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card + $invoiceid=0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment + else $invoiceid=$facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } } } } - /* * View */ diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index b4ceb2ae1b0..c98b855cdf9 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -54,40 +54,41 @@ $hookmanager->initHooks(array('suppliercard')); $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -/* - * Action - */ +if (empty($reshook)) { + /* + * Action + */ -if ($action == 'setsupplieraccountancycode') -{ - $cancelbutton = GETPOST('cancel'); + if ($action == 'setsupplieraccountancycode') + { + $cancelbutton = GETPOST('cancel'); - if (!$cancelbutton) { + if (!$cancelbutton) { - $result = $object->fetch($id); - $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; - $result = $object->update($object->id, $user, 1, 0, 1); - if ($result < 0) { - $mesg = join(',', $object->errors); + $result = $object->fetch($id); + $object->code_compta_fournisseur = $_POST["supplieraccountancycode"]; + $result = $object->update($object->id, $user, 1, 0, 1); + if ($result < 0) { + $mesg = join(',', $object->errors); + } + $action = ""; } - $action = ""; + } + // conditions de reglement + if ($action == 'setconditions' && $user->rights->societe->creer) + { + $object->fetch($id); + $result=$object->setPaymentTerms(GETPOST('cond_reglement_supplier_id','int')); + if ($result < 0) dol_print_error($db,$object->error); + } + // mode de reglement + if ($action == 'setmode' && $user->rights->societe->creer) + { + $object->fetch($id); + $result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int')); + if ($result < 0) dol_print_error($db,$object->error); } } -// conditions de reglement -if ($action == 'setconditions' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->setPaymentTerms(GETPOST('cond_reglement_supplier_id','int')); - if ($result < 0) dol_print_error($db,$object->error); -} -// mode de reglement -if ($action == 'setmode' && $user->rights->societe->creer) -{ - $object->fetch($id); - $result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int')); - if ($result < 0) dol_print_error($db,$object->error); -} - /* * View diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 1e8c7b7cd9a..24c8122a3a0 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -76,13 +76,13 @@ $modulepart='produit'; $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if (empty($reshook)) { + /* + * Action envoie fichier + */ -/* - * Action envoie fichier - */ - -include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; - + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php'; +} /* * View diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 527615cc7c4..c5ebe50049a 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -83,125 +83,125 @@ $parameters=array('socid'=>$socid, 'id_prod'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors); -if ($action == 'remove_pf') -{ - $product = new ProductFournisseur($db); - if ($product->fetch($id) > 0) +if (empty($reshook)) { + if ($action == 'remove_pf') { - if ($rowid) + $product = new ProductFournisseur($db); + if ($product->fetch($id) > 0) { - $result=$product->remove_product_fournisseur_price($rowid); - $action = ''; - $mesg = '
'.$langs->trans("PriceRemoved").'.
'; + if ($rowid) + { + $result=$product->remove_product_fournisseur_price($rowid); + $action = ''; + $mesg = '
'.$langs->trans("PriceRemoved").'.
'; + } } } -} -if ($action == 'updateprice' && GETPOST('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"); - $remise_percent=price2num(GETPOST('remise_percent','alpha')); - $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; - $tva_tx = str_replace('*','', GETPOST('tva_tx','alpha')); - $tva_tx = price2num($tva_tx); + if ($action == 'updateprice' && GETPOST('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"); + $remise_percent=price2num(GETPOST('remise_percent','alpha')); + $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; + $tva_tx = str_replace('*','', GETPOST('tva_tx','alpha')); + $tva_tx = price2num($tva_tx); - if ($tva_tx == '') - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("VATRateForSupplierProduct")).'
'; - } - if (empty($quantity)) - { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'
'; - } - if (empty($ref_fourn)) - { - $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($id); - if ($result <= 0) - { - $error++; - $mesg=$product->error; - } - - if (! $error) - { - $db->begin(); - - if (! $error) + if ($tva_tx == '') + { + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("VATRateForSupplierProduct")).'
'; + } + if (empty($quantity)) { - $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++; + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'
'; + } + if (empty($ref_fourn)) + { + $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->fetch($product->product_id_already_linked); - $productLink = $product->getNomUrl(1,'supplier'); - - $mesg='
'.$langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct",$productLink).'
'; - } - else if ($ret < 0) - { - $error++; - $mesg='
'.$product->error.'
'; - } + $product = new ProductFournisseur($db); + $result=$product->fetch($id); + if ($result <= 0) + { + $error++; + $mesg=$product->error; } if (! $error) - { - $supplier=new Fournisseur($db); - $result=$supplier->fetch($id_fourn); - if (isset($_POST['ref_fourn_price_id'])) - $product->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); + { + $db->begin(); - $ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, $npr); - if ($ret < 0) + if (! $error) { - $error++; - $mesg='
'.$product->error.'
'; + $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++; + + $product->fetch($product->product_id_already_linked); + $productLink = $product->getNomUrl(1,'supplier'); + + $mesg='
'.$langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct",$productLink).'
'; + } + else if ($ret < 0) + { + $error++; + $mesg='
'.$product->error.'
'; + } } - } - if (! $error) - { - $db->commit(); - $action=''; - } - else - { - $db->rollback(); - } - } + if (! $error) + { + $supplier=new Fournisseur($db); + $result=$supplier->fetch($id_fourn); + if (isset($_POST['ref_fourn_price_id'])) + $product->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); + + $ret=$product->update_buyprice($quantity, $_POST["price"], $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, $npr); + if ($ret < 0) + { + $error++; + $mesg='
'.$product->error.'
'; + } + } + + if (! $error) + { + $db->commit(); + $action=''; + } + else + { + $db->rollback(); + } + } + } + + if (GETPOST('cancel') == $langs->trans("Cancel")) + { + $action = ''; + header("Location: fournisseurs.php?id=".$_GET["id"]); + exit; + } } -if (GETPOST('cancel') == $langs->trans("Cancel")) -{ - $action = ''; - header("Location: fournisseurs.php?id=".$_GET["id"]); - exit; -} - - - /* * view */ diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 38562557e3a..0dbf21ce881 100755 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -61,58 +61,59 @@ $hookmanager->initHooks(array('resource_card')); $parameters=array('resource_id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if (empty($reshook)) { -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ + /******************************************************************* + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + ********************************************************************/ -if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write ) -{ - $error=0; - - if (empty($ref)) + if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write ) { - $error++; - $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
'; - } + $error=0; - if (! $error) - { - $res = $object->fetch($id); - if ( $res > 0 ) + if (empty($ref)) { - $object->ref = $ref; - $object->description = $description; - $object->fk_code_type_resource = $fk_code_type_resource; - - $result=$object->update($user); - if ($result > 0) + $error++; + $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'
'; + } + + if (! $error) + { + $res = $object->fetch($id); + if ( $res > 0 ) { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; + $object->ref = $ref; + $object->description = $description; + $object->fk_code_type_resource = $fk_code_type_resource; + + $result=$object->update($user); + if ($result > 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + setEventMessage('
'.$object->error.'
'); + $action='edit'; + } + } else { - setEventMessage('
'.$object->error.'
'); + setEventMessage($object->error,'errors'); $action='edit'; } - } - else + else { - setEventMessage($object->error,'errors'); $action='edit'; } } - else - { - $action='edit'; - } } - /*************************************************** * VIEW * From dacec491ff56cc21c784deb11c54d46359c38131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:37:49 +0100 Subject: [PATCH 142/145] Fix: [ bug #1783 ] SQL error when enabling 3rd party module with PostgreSQL and MySQL strict mode ON --- ChangeLog | 2 +- htdocs/core/class/menubase.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..ab27963fd2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules - +- Fix: [ bug #1783 ] SQL error when enabling 3rd party module with PostgreSQL and MySQL strict mode ON ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. - Fix: bug 1588 : relative discount. diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index c04697acd39..2f4049ee460 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -152,7 +152,7 @@ class Menubase $sql.= " '".$this->fk_menu."',"; $sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").","; $sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").","; - $sql.= " '".$this->position."',"; + $sql.= " '".(int) $this->position."',"; $sql.= " '".$this->db->escape($this->url)."',"; $sql.= " '".$this->db->escape($this->target)."',"; $sql.= " '".$this->db->escape($this->titre)."',"; From 003aa5ee4433059b1d68ec7e147996bafd467051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 19:41:31 +0100 Subject: [PATCH 143/145] Fix: [ bug #1717 ] Sorting unpaid invoices by amount received brings due amount --- ChangeLog | 1 + htdocs/compta/facture/impayees.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..83a107cb6e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1717 ] Sorting unpaid invoices by amount received brings due amount ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index d009216bc86..467d2b0636a 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -535,7 +535,7 @@ if ($resql) print_liste_field_titre($langs->trans("Taxes"),$_SERVER["PHP_SELF"],"f.tva","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("AmountTTC"),$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); if (empty($mode)) { From 78905c6af1bd95dd957c4426bb341074b88ff77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 17 Jan 2015 20:29:51 +0100 Subject: [PATCH 144/145] =?UTF-8?q?Fix:=20[=20bug=20#1784=20]=20=C2=AB=20M?= =?UTF-8?q?essage=20page=20de=20connexion=20=C2=BB=20n'appara=C3=AEt=20pas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 1 + htdocs/core/tpl/login.tpl.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2a49b467783..a6231b139ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules +- Fix: [ bug #1784 ] « Message page de connexion » n'apparaît pas ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 82748a69b05..f508a595d23 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -203,7 +203,7 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file -
+
Date: Sun, 18 Jan 2015 02:55:59 +0100 Subject: [PATCH 145/145] Updated bug title --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a6231b139ce..d71dc3e7a01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ English Dolibarr ChangeLog - Fix: amarok is a bugged theme making dolidroid failed. We swith to eldy automatically with dolidroid. - Fix: withdrawal create error if in the same month are deleted previus withdrawals. - Fix: [ bug #1801 ] FAC_FORCE_DATE_VALIDATION constant alters supplier invoice date given to numeration modules -- Fix: [ bug #1784 ] « Message page de connexion » n'apparaît pas +- Fix: [ bug #1784 ] MOTD doesn't show up in Amarok theme ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.